For internal use only; no backwards-compatibility guarantees.
Abstract base class that provides urn registration utilities.
A class that inherits from this class will get a registration-based from_runner_api and to_runner_api method that convert to and from beam_runner_api_pb2.FunctionSpec.
Additionally, register_pickle_urn can be called from the body of a class to register serialization via pickling.
Returns the urn and payload for this Fn.
The returned urn(s) should be registered with register_urn.
register_urn(urn, parameter_type, fn=None)¶
Registers a urn with a constructor.
For example, if ‘beam:fn:foo’ had parameter type FooPayload, one could write RunnerApiFn.register_urn(‘bean:fn:foo’, FooPayload, foo_from_proto) where foo_from_proto took as arguments a FooPayload and a PipelineContext. This function can also be used as a decorator rather than passing the callable in as the final parameter.
A corresponding to_runner_api_parameter method would be expected that returns the tuple (‘beam:fn:foo’, FooPayload)
Registers and implements the given urn via pickling.
Returns an FunctionSpec encoding this Fn.
Prefer overriding self.to_runner_api_parameter.
Converts from an FunctionSpec to a Fn object.
Prefer registering a urn with its parameter type and constructor.