You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2019/11/01 22:29:00 UTC

[jira] [Work logged] (BEAM-8491) Add ability for multiple output PCollections from composites

     [ https://issues.apache.org/jira/browse/BEAM-8491?focusedWorklogId=337585&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-337585 ]

ASF GitHub Bot logged work on BEAM-8491:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Nov/19 22:28
            Start Date: 01/Nov/19 22:28
    Worklog Time Spent: 10m 
      Work Description: rohdesamuel commented on pull request #9912: [BEAM-8491] Add ability for replacing transforms with multiple outputs
URL: https://github.com/apache/beam/pull/9912#discussion_r341771747
 
 

 ##########
 File path: sdks/python/apache_beam/pipeline.py
 ##########
 @@ -263,31 +262,29 @@ def _replace_if_needed(self, original_transform_node):
 
           new_output = replacement_transform.expand(input_node)
 
-          new_output.element_type = None
-          self.pipeline._infer_result_type(replacement_transform, inputs,
-                                           new_output)
-
+          if isinstance(new_output, pvalue.PValue):
+            new_output.element_type = None
+            self.pipeline._infer_result_type(replacement_transform, inputs,
+                                             new_output)
           replacement_transform_node.add_output(new_output)
-          if not new_output.producer:
-            new_output.producer = replacement_transform_node
-
-          # We only support replacing transforms with a single output with
-          # another transform that produces a single output.
-          # TODO: Support replacing PTransforms with multiple outputs.
-          if (len(original_transform_node.outputs) > 1 or
-              not isinstance(original_transform_node.outputs[None],
-                             (PCollection, PDone)) or
-              not isinstance(new_output, (PCollection, PDone))):
-            raise NotImplementedError(
-                'PTransform overriding is only supported for PTransforms that '
-                'have a single output. Tried to replace output of '
-                'AppliedPTransform %r with %r.'
-                % (original_transform_node, new_output))
 
           # Recording updated outputs. This cannot be done in the same visitor
           # since if we dynamically update output type here, we'll run into
           # errors when visiting child nodes.
-          output_map[original_transform_node.outputs[None]] = new_output
+          if isinstance(new_output, pvalue.PValue):
+            if not new_output.producer:
+              new_output.producer = replacement_transform_node
+            output_map[original_transform_node.outputs[None]] = new_output
+          elif isinstance(new_output, (pvalue.DoOutputsTuple, tuple)):
+            for pcoll in new_output:
+              if not pcoll.producer:
+                pcoll.producer = replacement_transform_node
+              output_map[original_transform_node.outputs[pcoll.tag]] = pcoll
 
 Review comment:
   Done
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 337585)
    Time Spent: 1h  (was: 50m)

> Add ability for multiple output PCollections from composites
> ------------------------------------------------------------
>
>                 Key: BEAM-8491
>                 URL: https://issues.apache.org/jira/browse/BEAM-8491
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core
>            Reporter: Sam Rohde
>            Assignee: Sam Rohde
>            Priority: Major
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> The Python SDK has DoOutputTuples which allows for a single transform to have multiple outputs. However, this does not include the ability for a composite transform to have multiple outputs PCollections from different transforms.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)