public class PythonExternalTransform<InputT extends org.apache.beam.sdk.values.PInput,OutputT extends org.apache.beam.sdk.values.POutput>
extends org.apache.beam.sdk.transforms.PTransform<InputT,OutputT>
| Modifier and Type | Method and Description |
|---|---|
OutputT |
expand(InputT input) |
static <InputT extends org.apache.beam.sdk.values.PInput,OutputT extends org.apache.beam.sdk.values.POutput> |
from(java.lang.String transformName)
Instantiates a cross-language wrapper for a Python transform with a given transform name.
|
static <InputT extends org.apache.beam.sdk.values.PInput,OutputT extends org.apache.beam.sdk.values.POutput> |
from(java.lang.String transformName,
java.lang.String expansionService)
Instantiates a cross-language wrapper for a Python transform with a given transform name.
|
PythonExternalTransform<InputT,OutputT> |
withArgs(java.lang.Object... args)
Positional arguments for the Python cross-language transform.
|
PythonExternalTransform<InputT,OutputT> |
withExtraPackages(java.util.List<java.lang.String> extraPackages)
Specifies that the given Python packages are required for this transform, which will cause them
to be installed in both the construction-time and execution time environment.
|
PythonExternalTransform<InputT,OutputT> |
withKwarg(java.lang.String name,
java.lang.Object value)
Specifies a single keyword argument for the Python cross-language transform.
|
PythonExternalTransform<InputT,OutputT> |
withKwargs(java.util.Map<java.lang.String,java.lang.Object> kwargs)
Specifies keyword arguments for the Python cross-language transform.
|
PythonExternalTransform<InputT,OutputT> |
withKwargs(org.apache.beam.sdk.values.Row kwargs)
Specifies keyword arguments as a Row objects.
|
PythonExternalTransform<InputT,OutputT> |
withOutputCoder(org.apache.beam.sdk.coders.Coder<?> outputCoder)
Specifies the
Coder of the output PCollections produced by this transform. |
PythonExternalTransform<InputT,OutputT> |
withOutputCoders(java.util.Map<java.lang.String,org.apache.beam.sdk.coders.Coder<?>> outputCoders)
Specifies the keys and
Coders of the output PCollections produced by this
transform. |
PythonExternalTransform<InputT,OutputT> |
withTypeHint(java.lang.Class<?> argType,
org.apache.beam.sdk.schemas.Schema.FieldType fieldType)
Specifies the field type of arguments.
|
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validatepublic static <InputT extends org.apache.beam.sdk.values.PInput,OutputT extends org.apache.beam.sdk.values.POutput> PythonExternalTransform<InputT,OutputT> from(java.lang.String transformName)
The given fully qualified name will be imported and called to instantiate the transform.
Often this is the fully qualified name of a Python PTransform class, in which case the
arguments will be passed to its constructor, but any callable will do.
Two special names, __callable__ and __constructor__ can be used to define a
suitable transform inline if none exists.
When __callable__ is provided, the first argument (or source keyword
argument) should be a PythonCallableSource which represents the expand method of the
PTransform accepting and returning a PValue (and may also take additional
arguments and keyword arguments). For example, one might write
PythonExternalTransform
.from("__callable__")
.withArgs(
PythonCallable.of("def expand(pcoll, x, y): return pcoll | ..."),
valueForX,
valueForY);
When __constructor__ is provided, the first argument (or source keyword
argument) should be a PythonCallableSource which will return the desired PTransform
when called with the remaining arguments and keyword arguments. Often this will be a PythonCallableSource representing a PTransform class, for example
PythonExternalTransform
.from("__constructor__")
.withArgs(
PythonCallable.of("class MyPTransform(beam.PTransform): ..."),
...valuesForMyPTransformConstructorIfAny);
InputT - Input PCollection typeOutputT - Output PCollection typetransformName - fully qualified transform name.PythonExternalTransform for the given transform name.public static <InputT extends org.apache.beam.sdk.values.PInput,OutputT extends org.apache.beam.sdk.values.POutput> PythonExternalTransform<InputT,OutputT> from(java.lang.String transformName, java.lang.String expansionService)
See from(String) for the meaning of transformName.
InputT - Input PCollection typeOutputT - Output PCollection typetransformName - fully qualified transform name.expansionService - address and port number for externally launched expansion servicePythonExternalTransform for the given transform name.public PythonExternalTransform<InputT,OutputT> withArgs(java.lang.Object... args)
args - list of arguments.public PythonExternalTransform<InputT,OutputT> withKwarg(java.lang.String name, java.lang.Object value)
name - argument name.value - argument valuepublic PythonExternalTransform<InputT,OutputT> withKwargs(java.util.Map<java.lang.String,java.lang.Object> kwargs)
public PythonExternalTransform<InputT,OutputT> withKwargs(org.apache.beam.sdk.values.Row kwargs)
kwargs - keyword arguments as a Row objects. An empty Row represents zero keyword
arguments.public PythonExternalTransform<InputT,OutputT> withTypeHint(java.lang.Class<?> argType, org.apache.beam.sdk.schemas.Schema.FieldType fieldType)
Type hints are especially useful for logical types since type inference does not work well for logical types.
argType - A class object for the argument type.fieldType - A schema field type for the argument.public PythonExternalTransform<InputT,OutputT> withOutputCoders(java.util.Map<java.lang.String,org.apache.beam.sdk.coders.Coder<?>> outputCoders)
Coders of the output PCollections produced by this
transform.outputCoders - a mapping from output keys to Coders.public PythonExternalTransform<InputT,OutputT> withOutputCoder(org.apache.beam.sdk.coders.Coder<?> outputCoder)
Coder of the output PCollections produced by this transform.
Should only be used if this transform produces a single output.outputCoder - output Coder of the transform.public PythonExternalTransform<InputT,OutputT> withExtraPackages(java.util.List<java.lang.String> extraPackages)
extraPackages - a list of pip-installable package specifications, such as would be found
in a requirements file.