beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rober...@apache.org
Subject [01/12] incubator-beam git commit: Fix error messages for externally named PTransforms.
Date Sat, 23 Jul 2016 23:47:07 GMT
Repository: incubator-beam
Updated Branches:
  refs/heads/python-sdk 9fe102a5c -> 38d9dea2e


Fix error messages for externally named PTransforms.


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

Branch: refs/heads/python-sdk
Commit: 7c186ce4ce18c98cf3979b6f0f07c72a47b42ec9
Parents: 031c4cc
Author: Robert Bradshaw <robertwb@google.com>
Authored: Fri Jul 22 15:55:26 2016 -0700
Committer: Robert Bradshaw <robertwb@gmail.com>
Committed: Sat Jul 23 16:43:45 2016 -0700

----------------------------------------------------------------------
 sdks/python/apache_beam/pipeline.py | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/7c186ce4/sdks/python/apache_beam/pipeline.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/pipeline.py b/sdks/python/apache_beam/pipeline.py
index 30ad315..aeed9f9 100644
--- a/sdks/python/apache_beam/pipeline.py
+++ b/sdks/python/apache_beam/pipeline.py
@@ -201,6 +201,15 @@ class Pipeline(object):
     if not isinstance(transform, ptransform.PTransform):
       raise TypeError("Expected a PTransform object, got %s" % transform)
 
+    if label:
+      # Fix self.label as it is inspected by some PTransform operations
+      # (e.g. to produce error messages for type hint violations).
+      try:
+        old_label, transform.label = transform.label, label
+        return self.apply(transform, pvalueish)
+      finally:
+        transform.label = old_label
+
     full_label = '/'.join([self._current_transform().full_label,
                            label or transform.label]).lstrip('/')
     if full_label in self.applied_labels:


Mime
View raw message