beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhalp...@apache.org
Subject [1/2] incubator-beam git commit: Fixing the custom ptransform snippet in the comments
Date Fri, 02 Sep 2016 17:48:54 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/python-sdk 5aee3cd73 -> 95656d1fa


Fixing the custom ptransform snippet in the comments


Project: http://git-wip-us.apache.org/repos/asf/incubator-beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-beam/commit/06a5bb4c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-beam/tree/06a5bb4c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-beam/diff/06a5bb4c

Branch: refs/heads/python-sdk
Commit: 06a5bb4cc05bfb93718822ed56de307032e0d109
Parents: 5aee3cd
Author: Ahmet Altay <altay@google.com>
Authored: Thu Sep 1 17:07:54 2016 -0700
Committer: Dan Halperin <dhalperi@google.com>
Committed: Fri Sep 2 10:48:49 2016 -0700

----------------------------------------------------------------------
 sdks/python/apache_beam/transforms/ptransform.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/06a5bb4c/sdks/python/apache_beam/transforms/ptransform.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/ptransform.py b/sdks/python/apache_beam/transforms/ptransform.py
index 7fb7caf..0713c59 100644
--- a/sdks/python/apache_beam/transforms/ptransform.py
+++ b/sdks/python/apache_beam/transforms/ptransform.py
@@ -685,8 +685,13 @@ def ptransform_fn(fn):
   The equivalent approach using PTransform subclassing::
 
     class CustomMapper(PTransform):
-      def apply(self, pcoll, mapfn):
-        return pcoll | ParDo(mapfn)
+
+      def __init__(self, mapfn):
+        super(CustomMapper, self).__init__()
+        self.mapfn = mapfn
+
+      def apply(self, pcoll):
+        return pcoll | ParDo(self.mapfn)
 
   With either method the custom PTransform can be used in pipelines as if
   it were one of the "native" PTransforms::


Mime
View raw message