gemini-code-assist[bot] commented on code in PR #35754:
URL: https://github.com/apache/beam/pull/35754#discussion_r2245990047


##########
sdks/python/apache_beam/typehints/typed_pipeline_test.py:
##########
@@ -239,6 +239,27 @@ def process(self, element):
     with self.assertRaises(ValueError):
       _ = res['undeclared tag']
 
+  def test_typed_dofn_multi_output_default_main(self):
+    """
+    Test that the main pcollection of a multi-output pcoll pardo
+    is used by default when a PTransform is applied to it.
+    """
+    class NoEvenTagMyDoFn(beam.DoFn):
+      def process(self, element):
+        if element % 2:
+          yield beam.pvalue.TaggedOutput('odd', element)
+        else:
+          yield element
+
+    with beam.Pipeline() as p:
+      res = (
+          p
+          | beam.Create([1, 2, 3])
+          | beam.ParDo(NoEvenTagMyDoFn(tag_even=False)).with_outputs('odd'))

Review Comment:
   ![critical](https://www.gstatic.com/codereviewagent/critical.svg)
   
   The `NoEvenTagMyDoFn` class is instantiated with a `tag_even=False` keyword 
argument. However, the class does not define an `__init__` method that accepts 
this argument, which will cause a `TypeError` when the test is run. Please 
remove this unexpected argument.
   
   ```suggestion
             | beam.ParDo(NoEvenTagMyDoFn()).with_outputs('odd'))
   ```



##########
sdks/python/apache_beam/pvalue.py:
##########
@@ -254,6 +254,9 @@ def __init__(
     # Dictionary of PCollections already associated with tags.
     self._pcolls: Dict[Optional[str], PCollection] = {}
 
+  def __or__(self, other):
+    return self[self._main_tag].__or__(other)

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   This `print` statement appears to be for debugging purposes. It should be 
removed before this change is merged to avoid polluting stdout during runs.
   
   ```suggestion
       return self[self._main_tag].__or__(other)
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to