-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-1833] Preserve inputs names at graph construction and through proto transaltion. #15202
Conversation
…roto translation.
R: @yifanmai |
if not isinstance(leaf_input, pvalue.PValue): | ||
raise TypeError | ||
if not isinstance(inputs, dict): | ||
inputs = {str(ix): input for (ix, input) in enumerate(inputs)} | ||
except TypeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete the except
branch; it is no longer needed because the PValue
check is now done below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This catches a possible failure in enumerate.
tag: input if not input in output_map else output_map[input] | ||
for (tag, input) in transform_node.main_inputs.items() | ||
} | ||
input_replacements[transform_node] = new_inputs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't leave a comment on Line 274 but the type annotation for input_replacements
there needs to change from Dict[AppliedPTransform, Sequence[Union[pvalue.PBegin, pvalue.PCollection]]]
to Dict[AppliedPTransform, Dict[str, Union[pvalue.PBegin, pvalue.PCollection]]]
(or Mapping
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Done.
@@ -262,16 +263,21 @@ def get_named_nested_pvalues(pvalueish): | |||
else: | |||
tagged_values = enumerate(pvalueish) | |||
elif isinstance(pvalueish, list): | |||
if as_inputs: | |||
yield None, pvalueish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for this branch i.e. yielding the whole pvalueish
versus enumerating it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for backwards compatibility with the "eager" mode (e.g. [1, 2, 3] | beam.Map(lambda x: x*x)
)
@@ -253,7 +254,7 @@ def visit(self, node): | |||
return self.visit_nested(node) | |||
|
|||
|
|||
def get_named_nested_pvalues(pvalueish): | |||
def get_named_nested_pvalues(pvalueish, as_inputs=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the invocation of get_named_nested_pvalues()
in pipeline.py
, do we also need to stringify the tags (so that None
becomes 'None'
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done elsewhere as needed.
Codecov Report
@@ Coverage Diff @@
## master #15202 +/- ##
=======================================
Coverage 83.83% 83.83%
=======================================
Files 441 441
Lines 59706 59707 +1
=======================================
+ Hits 50053 50055 +2
+ Misses 9653 9652 -1
Continue to review full report at Codecov.
|
Run Portable_Python PreCommit |
…hrough proto transaltion. (apache#15202)" This reverts commit 939fa99.
…hrough proto transaltion. (apache#15202)" This reverts commit 939fa99.
…roto transaltion. (apache#15202)
…roto transaltion. (apache#15202)
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).[BEAM-XXX] Fixes bug in ApproximateQuantiles
, where you replaceBEAM-XXX
with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
ValidatesRunner
compliance status (on master branch)Examples testing status on various runners
Post-Commit SDK/Transform Integration Tests Status (on master branch)
Pre-Commit Tests Status (on master branch)
See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.