You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "robertwb (via GitHub)" <gi...@apache.org> on 2023/05/18 23:58:40 UTC

[GitHub] [beam] robertwb commented on a diff in pull request #26771: Allow for same name and type, if it is not ambiguous in yaml inputs

robertwb commented on code in PR #26771:
URL: https://github.com/apache/beam/pull/26771#discussion_r1198403538


##########
sdks/python/apache_beam/yaml/yaml_transform_test.py:
##########
@@ -280,6 +280,50 @@ def test_windowing_on_outer(self):
           providers=TEST_PROVIDERS)
       assert_that(result, equal_to([6, 9]))
 
+  def test_name_is_not_ambiguous(self):
+    with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions(
+        pickle_library='cloudpickle')) as p:
+
+      result = p | YamlTransform(
+          '''
+          type: composite
+          transforms:
+            - type: Create
+              name: Create
+              elements: [0, 1, 3, 4]
+            - type: PyFilter
+              name: Filter
+              keep: "lambda elem: elem > 2"
+              input: Create
+          output: Filter
+          ''')
+      # No exception raised
+      assert_that(result, equal_to([3, 4]))
+
+  def test_name_is_ambiguous(self):
+    with beam.Pipeline(options=beam.options.pipeline_options.PipelineOptions(
+        pickle_library='cloudpickle')) as p:
+
+      with self.assertRaises(ValueError):
+        result = p | YamlTransform(
+            '''
+            type: composite
+            transforms:
+              - type: Create
+                name: CreateData
+                elements: [0, 1, 3, 4]
+              - type: PyFilter
+                name: PyFilter
+                keep: "lambda elem: elem > 2"
+                input: CreateData
+              - type: PyFilter
+                name: AnotherFilter
+                keep: "lambda elem: elem > 3"
+                input: PyFilter

Review Comment:
   I'm fine with this being an error--it's still a bit ambiguous and if we really want to change our minds later we can (but not the other way around). 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org