chamikaramj commented on code in PR #23047:
URL: https://github.com/apache/beam/pull/23047#discussion_r974312230
##########
website/www/site/content/en/documentation/programming-guide.md:
##########
@@ -7364,13 +7370,37 @@ When an SDK-specific wrapper isn't available, you will
have to access the cross-
| beam.ExternalTransform(
TEST_PREFIX_URN,
ImplicitSchemaPayloadBuilder({'data': u'0'}),
- <Address of expansion service>))
+ <expansion service>))
assert_that(res, equal_to(['0a', '0b']))
```
For additional examples, see
[addprefix.py](https://github.com/apache/beam/blob/master/examples/multi-language/python/addprefix.py)
and
[javacount.py](https://github.com/apache/beam/blob/master/examples/multi-language/python/javacount.py).
-4. After the job has been submitted to the Beam runner, shut down the
expansion service by terminating the expansion service process.
+4. After the job has been submitted to the Beam runner, shut down any manually
started expansion services by terminating the expansion service process.
+
+**Using the JavaExternalTransform class**
+
+Python has the ability to invoke Java-defined transforms via [proxy
objects](https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.external.html#apache_beam.transforms.external.JavaExternalTransform)
+as if they were Python transforms.
+These are invoked as follows
+
+ ```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']))
+ ```
+
+Python's `getattr` method can be used if the method names in java are reserved
Review Comment:
We should also mention the withExtraPackages() method here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]