You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2024/11/26 20:50:29 UTC

(beam) branch master updated: Better error messaging for chain-type pipeline (#33210)

This is an automated email from the ASF dual-hosted git repository.

damccorm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d55231a19f Better error messaging for chain-type pipeline (#33210)
0d55231a19f is described below

commit 0d55231a19f890f3377fa3f523afbee0a0ea86d7
Author: Ravi Magham <ma...@gmail.com>
AuthorDate: Tue Nov 26 12:50:23 2024 -0800

    Better error messaging for chain-type pipeline (#33210)
---
 sdks/python/apache_beam/yaml/yaml_transform.py          |  4 ++--
 .../python/apache_beam/yaml/yaml_transform_unit_test.py | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/sdks/python/apache_beam/yaml/yaml_transform.py b/sdks/python/apache_beam/yaml/yaml_transform.py
index ab86a2aaff5..0190fe20413 100644
--- a/sdks/python/apache_beam/yaml/yaml_transform.py
+++ b/sdks/python/apache_beam/yaml/yaml_transform.py
@@ -576,8 +576,8 @@ def chain_as_composite(spec):
         pass
       else:
         raise ValueError(
-            f'Transform {identify_object(transform)} is part of a chain, '
-            'must have implicit inputs and outputs.')
+            f'Transform {identify_object(transform)} is part of a chain. '
+            'Cannot define explicit inputs on chain pipeline')
     if ix == 0:
       if is_explicitly_empty(transform.get('input', None)):
         pass
diff --git a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py
index bc0493509d5..084e03cdb19 100644
--- a/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py
+++ b/sdks/python/apache_beam/yaml/yaml_transform_unit_test.py
@@ -325,6 +325,23 @@ class MainTest(unittest.TestCase):
     self.assertEqual(
         chain_as_composite(spec)['transforms'][0]['input'], {"input": "input"})
 
+  def test_chain_as_composite_with_transform_input(self):
+    spec = '''
+        type: chain
+        transforms:
+        - type: Create
+          config:
+            elements: [0,1,2]
+        - type: LogForTesting
+          input: Create
+      '''
+    spec = yaml.load(spec, Loader=SafeLineLoader)
+    with self.assertRaisesRegex(
+        ValueError,
+        r"Transform .* is part of a chain. "
+        r"Cannot define explicit inputs on chain pipeline"):
+      chain_as_composite(spec)
+
   def test_normalize_source_sink(self):
     spec = '''
         source: