This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/asf-site by this push: new e7b02bd8edb Publishing website 2022/09/30 04:17:21 at commit cc623db e7b02bd8edb is described below commit e7b02bd8edba3b882aa9d1e192e478ce8911db4e Author: jenkins <bui...@apache.org> AuthorDate: Fri Sep 30 04:17:21 2022 +0000 Publishing website 2022/09/30 04:17:21 at commit cc623db --- website/generated-content/documentation/index.xml | 35 ++++++++++++++++++---- .../documentation/programming-guide/index.html | 27 +++++++++++++++-- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/website/generated-content/documentation/index.xml b/website/generated-content/documentation/index.xml index e2f61fc1bba..0b3ef341241 100644 --- a/website/generated-content/documentation/index.xml +++ b/website/generated-content/documentation/index.xml @@ -12880,11 +12880,17 @@ version = “v” 1*(DIGIT / “.”) ; For example, ‘v1.2’</code></pr <p>Make sure you have any runtime environment dependencies (like the JRE) installed on your local machine. See the expansion service section for more details.</p> </li> <li> -<p>Start up the expansion service for the SDK that is in the language of the transform you&rsquo;re trying to consume, if not available.</p> -<p>Make sure the transform you&rsquo;re trying to use is available and can be used by the expansion service. For Java, make sure the builder and registrar for the transform are available in the classpath of the expansion service.</p> +<p>Start up the expansion service for the SDK that is in the language of the transform you&rsquo;re trying to consume, if not available. +Python provides several classes for automatically starting expansion java services such as +<a href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.JavaJarExpansionService">JavaJarExpansionService</a> +and <a href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.BeamJarExpansionService">BeamJarExpansionService</a> +which can be passed directly as an expansion service to <code>beam.ExternalTransform</code>. +Make sure the transform you&rsquo;re trying to use is available and can be used by the expansion service.</p> +<p>For Java, make sure the builder and registrar for the transform are available in the classpath of the expansion service.</p> </li> <li> -<p>Include <code>ExternalTransform</code> when instantiating your pipeline. Reference the URN, payload, and expansion service. You can use one of the available <a href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.PayloadBuilder"><code>PayloadBuilder</code></a> classes to build the payload for <code>ExternalTransform</code>.</p> +<p>Include <code>ExternalTransform</code> when instantiating your pipeline. Reference the URN, payload, and expansion service. +You can use one of the available <a href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.PayloadBuilder"><code>PayloadBuilder</code></a> classes to build the payload for <code>ExternalTransform</code>.</p> <div class="highlight"><pre class="chroma"><code class="language-py" data-lang="py"><span class="k">with</span> <span class="n">pipeline</span> <span class="k">as</span> <span class="n">p</span><span class="p">:</span> <span class="n">res</span> <span class="o">=</span> <span class="p">(</span> <span class="n">p</span> @@ -12892,14 +12898,33 @@ version = “v” 1*(DIGIT / “.”) ; For example, ‘v1.2’</code></pr <span class="o">|</span> <span class="n">beam</span><span class="o">.</span><span class="n">ExternalTransform</span><span class="p">(</span> <span class="n">TEST_PREFIX_URN</span><span class="p">,</span> <span class="n">ImplicitSchemaPayloadBuilder</span><span class="p">({</span><span class="s1">&#39;data&#39;</span><span class="p">:</span> <span class="sa">u</span><span class="s1">&#39;0&#39;</span><span class="p">}),</span> -<span class="o">&lt;</span><span class="n">Address</span> <span class="n">of</span> <span class="n">expansion</span> <span class="n">service</span><span class="o">&gt;</span><span class="p">))</span> +<span class="o">&lt;</span><span class="n">expansion</span> <span class="n">service</span><span class="o">&gt;</span><span class="p">))</span> <span class="n">assert_that</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="n">equal_to</span><span class="p">([</span><span class="s1">&#39;0a&#39;</span><span class="p">,</span> <span class="s1">&#39;0b&#39;</span><span class="p">]))</span> </code></pre></div><p>For additional examples, see <a href="https://github.com/apache/beam/blob/master/examples/multi-language/python/addprefix.py">addprefix.py</a> and <a href="https://github.com/apache/beam/blob/master/examples/multi-language/python/javacount.py">javacount.py</a>.</p> </li> <li> -<p>After the job has been submitted to the Beam runner, shut down the expansion service by terminating the expansion service process.</p> +<p>After the job has been submitted to the Beam runner, shut down any manually started expansion services by terminating the expansion service process.</p> </li> </ol> +<p><strong>Using the JavaExternalTransform class</strong></p> +<p>Python has the ability to invoke Java-defined transforms via <a href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.JavaExternalTransform">proxy objects</a> +as if they were Python transforms. +These are invoked as follows</p> +<pre><code>```py +MyJavaTransform = beam.JavaExternalTransform('fully.qualified.ClassName', classpath=[jars]) +with pipeline as p: +res = ( +p +| beam.Create(['a', 'b']).with_output_types(unicode) +| MyJavaTransform(javaConstructorArg, ...).builderMethod(...) +assert_that(res, equal_to(['0a', '0b'])) +``` +</code></pre> +<p>Python&rsquo;s <code>getattr</code> method can be used if the method names in java are reserved +Python keywords such as <code>from</code>.</p> +<p>As with other external transforms, either a pre-started expansion service can +be provided, or jar files that include the transform, its dependencies, and +Beam&rsquo;s expansion service in which case an expansion service will be auto-started.</p> <h4 id="1323-using-cross-language-transforms-in-a-go-pipeline">13.2.3. Using cross-language transforms in a Go pipeline</h4> <p>If a Go-specific wrapper for a cross-language is available, use that. Otherwise, you have to use the lower-level <a href="https://pkg.go.dev/github.com/apache/beam/sdks/v2/go/pkg/beam#CrossLanguage">CrossLanguage</a> diff --git a/website/generated-content/documentation/programming-guide/index.html b/website/generated-content/documentation/programming-guide/index.html index 4623d962365..186fd89d1de 100644 --- a/website/generated-content/documentation/programming-guide/index.html +++ b/website/generated-content/documentation/programming-guide/index.html @@ -4791,16 +4791,37 @@ version = “v” 1*(DIGIT / “.”) ; For example, ‘v1.2’</code></pre></d <span class=n>topics</span><span class=o>=</span><span class=p>[</span><span class=bp>self</span><span class=o>.</span><span class=n>topic</span><span class=p>],</span> <span class=n>max_num_records</span><span class=o>=</span><span class=n>max_num_records</span><span class=p>,</span> <span class=n>expansion_service</span><span class=o>=<</span><span class=n>Address</span> <span class=n>of</span> <span class=n>expansion</span> <span class=n>service</span><span class=o>></span><span class=p>))</span> -</code></pre></div><p><strong>Using the ExternalTransform class</strong></p><p>When an SDK-specific wrapper isn’t available, you will have to access the cross-language transform through the <code>ExternalTransform</code> class.</p><ol><li><p>Make sure you have any runtime environment dependencies (like the JRE) installed on your local machine. See the expansion service section for more details.</p></li><li><p>Start up the expansion service for the SDK that is in the language of the [...] +</code></pre></div><p><strong>Using the ExternalTransform class</strong></p><p>When an SDK-specific wrapper isn’t available, you will have to access the cross-language transform through the <code>ExternalTransform</code> class.</p><ol><li><p>Make sure you have any runtime environment dependencies (like the JRE) installed on your local machine. See the expansion service section for more details.</p></li><li><p>Start up the expansion service for the SDK that is in the language of the [...] +Python provides several classes for automatically starting expansion java services such as +<a href=https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.JavaJarExpansionService>JavaJarExpansionService</a> +and <a href=https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.BeamJarExpansionService>BeamJarExpansionService</a> +which can be passed directly as an expansion service to <code>beam.ExternalTransform</code>. +Make sure the transform you’re trying to use is available and can be used by the expansion service.</p><p>For Java, make sure the builder and registrar for the transform are available in the classpath of the expansion service.</p></li><li><p>Include <code>ExternalTransform</code> when instantiating your pipeline. Reference the URN, payload, and expansion service. +You can use one of the available <a href=https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.PayloadBuilder><code>PayloadBuilder</code></a> classes to build the payload for <code>ExternalTransform</code>.</p><div class=highlight><pre class=chroma><code class=language-py data-lang=py><span class=k>with</span> <span class=n>pipeline</span> <span class=k>as</span> <span class=n>p</span><span class=p>:</span> <span class=n>res</span> <span class=o>=</span> <span class=p>(</span> <span class=n>p</span> <span class=o>|</span> <span class=n>beam</span><span class=o>.</span><span class=n>Create</span><span class=p>([</span><span class=s1>'a'</span><span class=p>,</span> <span class=s1>'b'</span><span class=p>])</span><span class=o>.</span><span class=n>with_output_types</span><span class=p>(</span><span class=nb>unicode</span><span class=p>)</span> <span class=o>|</span> <span class=n>beam</span><span class=o>.</span><span class=n>ExternalTransform</span><span class=p>(</span> <span class=n>TEST_PREFIX_URN</span><span class=p>,</span> <span class=n>ImplicitSchemaPayloadBuilder</span><span class=p>({</span><span class=s1>'data'</span><span class=p>:</span> <span class=sa>u</span><span class=s1>'0'</span><span class=p>}),</span> - <span class=o><</span><span class=n>Address</span> <span class=n>of</span> <span class=n>expansion</span> <span class=n>service</span><span class=o>></span><span class=p>))</span> + <span class=o><</span><span class=n>expansion</span> <span class=n>service</span><span class=o>></span><span class=p>))</span> <span class=n>assert_that</span><span class=p>(</span><span class=n>res</span><span class=p>,</span> <span class=n>equal_to</span><span class=p>([</span><span class=s1>'0a'</span><span class=p>,</span> <span class=s1>'0b'</span><span class=p>]))</span> -</code></pre></div><p>For additional examples, see <a href=https://github.com/apache/beam/blob/master/examples/multi-language/python/addprefix.py>addprefix.py</a> and <a href=https://github.com/apache/beam/blob/master/examples/multi-language/python/javacount.py>javacount.py</a>.</p></li><li><p>After the job has been submitted to the Beam runner, shut down the expansion service by terminating the expansion service process.</p></li></ol><h4 id=1323-using-cross-language-transforms-in-a-go-p [...] +</code></pre></div><p>For additional examples, see <a href=https://github.com/apache/beam/blob/master/examples/multi-language/python/addprefix.py>addprefix.py</a> and <a href=https://github.com/apache/beam/blob/master/examples/multi-language/python/javacount.py>javacount.py</a>.</p></li><li><p>After the job has been submitted to the Beam runner, shut down any manually started expansion services by terminating the expansion service process.</p></li></ol><p><strong>Using the JavaExternalTr [...] +as if they were Python transforms. +These are invoked as follows</p><pre><code>```py +MyJavaTransform = beam.JavaExternalTransform('fully.qualified.ClassName', classpath=[jars]) + +with pipeline as p: + res = ( + p + | beam.Create(['a', 'b']).with_output_types(unicode) + | MyJavaTransform(javaConstructorArg, ...).builderMethod(...) + assert_that(res, equal_to(['0a', '0b'])) +``` +</code></pre><p>Python’s <code>getattr</code> method can be used if the method names in java are reserved +Python keywords such as <code>from</code>.</p><p>As with other external transforms, either a pre-started expansion service can +be provided, or jar files that include the transform, its dependencies, and +Beam’s expansion service in which case an expansion service will be auto-started.</p><h4 id=1323-using-cross-language-transforms-in-a-go-pipeline>13.2.3. Using cross-language transforms in a Go pipeline</h4><p>If a Go-specific wrapper for a cross-language is available, use that. Otherwise, you have to use the lower-level <a href=https://pkg.go.dev/github.com/apache/beam/sdks/v2/go/pkg/beam#CrossLanguage>CrossLanguage</a> function to access the transform.</p><p><strong>Expansion Services</strong></p><p>The Go SDK supports automatically starting Java expansion services if an expansion address is not provided, although this is slower than providing a persistent expansion service. Many wrapped Java transforms manage perform this automatically; if you wish to do this manually, use the <code>xlangx</code> package’s