Repository: beam Updated Branches: refs/heads/master 26c61f414 -> 412b610ed
Translate flatten to Runner API. Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/d096b19a Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/d096b19a Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/d096b19a Branch: refs/heads/master Commit: d096b19aaf2fa273dd1a13ac7ff96d2e0be030bd Parents: 97c9b17 Author: Robert Bradshaw <[email protected]> Authored: Tue Apr 18 15:51:50 2017 -0700 Committer: Robert Bradshaw <[email protected]> Committed: Wed Apr 26 18:14:12 2017 -0700 ---------------------------------------------------------------------- sdks/python/apache_beam/transforms/core.py | 12 ++++++++++++ sdks/python/apache_beam/utils/urns.py | 1 + 2 files changed, 13 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/d096b19a/sdks/python/apache_beam/transforms/core.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/transforms/core.py b/sdks/python/apache_beam/transforms/core.py index 4709056..14cc620 100644 --- a/sdks/python/apache_beam/transforms/core.py +++ b/sdks/python/apache_beam/transforms/core.py @@ -48,6 +48,7 @@ from apache_beam.typehints import TypeCheckError from apache_beam.typehints import Union from apache_beam.typehints import WithTypeHints from apache_beam.typehints.trivial_inference import element_type +from apache_beam.utils import urns from apache_beam.utils.pipeline_options import TypeOptions @@ -1340,6 +1341,17 @@ class Flatten(PTransform): return Windowing(GlobalWindows()) return super(Flatten, self).get_windowing(inputs) + def to_runner_api_parameter(self, context): + return urns.FLATTEN_TRANSFORM, None + + @staticmethod + def from_runner_api_parameter(unused_parameter, unused_context): + return Flatten() + + +PTransform.register_urn( + urns.FLATTEN_TRANSFORM, None, Flatten.from_runner_api_parameter) + class Create(PTransform): """A transform that creates a PCollection from an iterable.""" http://git-wip-us.apache.org/repos/asf/beam/blob/d096b19a/sdks/python/apache_beam/utils/urns.py ---------------------------------------------------------------------- diff --git a/sdks/python/apache_beam/utils/urns.py b/sdks/python/apache_beam/utils/urns.py index 88fca09..d10dd26 100644 --- a/sdks/python/apache_beam/utils/urns.py +++ b/sdks/python/apache_beam/utils/urns.py @@ -24,3 +24,4 @@ SESSION_WINDOWS_FN = "beam:window_fn:session_windows:v0.1" PICKLED_CODER = "beam:coder:pickled_python:v0.1" PICKLED_TRANSFORM = "beam:ptransform:pickled_python:v0.1" +FLATTEN_TRANSFORM = "beam:ptransform:flatten:v0.1"
