apache_beam.transforms.external module¶
Defines Transform whose expansion is implemented elsewhere.
No backward compatibility guarantees. Everything in this module is experimental.
-
class
apache_beam.transforms.external.
PayloadBuilder
[source]¶ Bases:
object
Abstract base class for building payloads to pass to ExternalTransform.
-
class
apache_beam.transforms.external.
SchemaBasedPayloadBuilder
[source]¶ Bases:
apache_beam.transforms.external.PayloadBuilder
Base class for building payloads based on a schema that provides type information for each configuration value to encode.
-
payload
()¶ The serialized ExternalConfigurationPayload
Returns: bytes
-
-
class
apache_beam.transforms.external.
ImplicitSchemaPayloadBuilder
(values)[source]¶ Bases:
apache_beam.transforms.external.SchemaBasedPayloadBuilder
Build a payload that generates a schema from the provided values.
-
build
()¶
-
payload
()¶ The serialized ExternalConfigurationPayload
Returns: bytes
-
-
class
apache_beam.transforms.external.
NamedTupleBasedPayloadBuilder
(tuple_instance)[source]¶ Bases:
apache_beam.transforms.external.SchemaBasedPayloadBuilder
Build a payload based on a NamedTuple schema.
Parameters: tuple_instance – an instance of a typing.NamedTuple -
build
()¶
-
payload
()¶ The serialized ExternalConfigurationPayload
Returns: bytes
-
-
class
apache_beam.transforms.external.
AnnotationBasedPayloadBuilder
(transform, **values)[source]¶ Bases:
apache_beam.transforms.external.SchemaBasedPayloadBuilder
Build a payload based on an external transform’s type annotations.
Supported in python 3 only.
Parameters: - transform – a PTransform instance or class. type annotations will be gathered from its __init__ method
- values – values to encode
-
build
()¶
-
payload
()¶ The serialized ExternalConfigurationPayload
Returns: bytes
-
class
apache_beam.transforms.external.
DataclassBasedPayloadBuilder
(transform)[source]¶ Bases:
apache_beam.transforms.external.SchemaBasedPayloadBuilder
Build a payload based on an external transform that uses dataclasses.
Supported in python 3 only.
Parameters: transform – a dataclass-decorated PTransform instance from which to gather type annotations and values -
build
()¶
-
payload
()¶ The serialized ExternalConfigurationPayload
Returns: bytes
-
-
class
apache_beam.transforms.external.
ExternalTransform
(urn, payload, expansion_service=None)[source]¶ Bases:
apache_beam.transforms.ptransform.PTransform
External provides a cross-language transform via expansion services in foreign SDKs.
Experimental; no backwards compatibility guarantees.
Wrapper for an external transform with the given urn and payload.
Parameters: - urn – the unique beam identifier for this transform
- payload – the payload, either as a byte string or a PayloadBuilder
- expansion_service – an expansion service implementing the beam ExpansionService protocol, either as an object with an Expand method or an address (as a str) to a grpc server that provides this method.
-
annotations
() → Dict[str, Union[bytes, str, google.protobuf.message.Message]]¶
-
default_type_hints
()¶
-
display_data
()¶ Returns the display data associated to a pipeline component.
It should be reimplemented in pipeline components that wish to have static display data.
Returns: A dictionary containing key:value
pairs. The value might be an integer, float or string value; aDisplayDataItem
for values that have more data (e.g. short value, label, url); or aHasDisplayData
instance that has more display data that should be picked up. For example:{ 'key1': 'string_value', 'key2': 1234, 'key3': 3.14159265, 'key4': DisplayDataItem('apache.org', url='http://apache.org'), 'key5': subComponent }
Return type: Dict[str, Any]
-
classmethod
from_runner_api
(proto, context)¶
-
get_type_hints
()¶ Gets and/or initializes type hints for this object.
If type hints have not been set, attempts to initialize type hints in this order: - Using self.default_type_hints(). - Using self.__class__ type hints.
-
get_windowing
(inputs)¶ Returns the window function to be associated with transform’s output.
By default most transforms just return the windowing function associated with the input PCollection (or the first input if several).
-
infer_output_type
(unused_input_type)¶
-
label
¶
-
pipeline
= None¶
-
classmethod
register_urn
(urn, parameter_type, constructor=None)¶
-
runner_api_requires_keyed_input
()¶
-
side_inputs
= ()¶
-
to_runner_api
(context, has_parts=False, **extra_kwargs)¶
-
to_runner_api_parameter
(unused_context)¶
-
to_runner_api_pickled
(unused_context)¶
-
type_check_inputs
(pvalueish)¶
-
type_check_inputs_or_outputs
(pvalueish, input_or_output)¶
-
type_check_outputs
(pvalueish)¶
-
with_input_types
(input_type_hint)¶ Annotates the input type of a
PTransform
with a type-hint.Parameters: input_type_hint (type) – An instance of an allowed built-in type, a custom class, or an instance of a TypeConstraint
.Raises: TypeError
– If input_type_hint is not a valid type-hint. Seeapache_beam.typehints.typehints.validate_composite_type_param()
for further details.Returns: A reference to the instance of this particular PTransform
object. This allows chaining type-hinting related methods.Return type: PTransform
-
with_output_types
(type_hint)¶ Annotates the output type of a
PTransform
with a type-hint.Parameters: type_hint (type) – An instance of an allowed built-in type, a custom class, or a TypeConstraint
.Raises: TypeError
– If type_hint is not a valid type-hint. Seevalidate_composite_type_param()
for further details.Returns: A reference to the instance of this particular PTransform
object. This allows chaining type-hinting related methods.Return type: PTransform
-
class
apache_beam.transforms.external.
ExpansionAndArtifactRetrievalStub
(channel, **kwargs)[source]¶ Bases:
apache_beam.portability.api.beam_expansion_api_pb2_grpc.ExpansionServiceStub
-
class
apache_beam.transforms.external.
JavaJarExpansionService
(path_to_jar, extra_args=None)[source]¶ Bases:
object
An expansion service based on an Java Jar file.
This can be passed into an ExternalTransform as the expansion_service argument which will spawn a subprocess using this jar to expand the transform.
-
class
apache_beam.transforms.external.
BeamJarExpansionService
(gradle_target, extra_args=None, gradle_appendix=None)[source]¶ Bases:
apache_beam.transforms.external.JavaJarExpansionService
An expansion service based on an Beam Java Jar file.
Attempts to use a locally-built copy of the jar based on the gradle target, if it exists, otherwise attempts to download and cache the released artifact corresponding to this version of Beam from the apache maven repository.