-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(sdk:python): Avoid AttributeError for transforms without hints #36251
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ab72f58
fix(sdk:python): Avoid AttributeError for transforms without hints
liferoad da45b26
fix annotations
liferoad 7bf0a95
fixed more
liferoad 15974f8
fixed more
liferoad 17b7ab6
more fixes
liferoad 6413d29
one more
liferoad 0432c22
Merge branch 'master' into fix-resource-hints
liferoad a3d05eb
Merge branch 'master' into fix-resource-hints
liferoad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Rather than doing all of these attribute checks, can we just set these property to empty values when we initialize the object?
beam/sdks/python/apache_beam/transforms/ptransform.py
Line 359 in 0432c22
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.
The reason is not to set these property. It is caused by the nested
MaybeReshuffle. Any fix inMaybeReshufflecould cause the update-compatibly issue. That is why we did #36238There 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 don't quite follow - are you saying adding these properties to the
PTransformclass would cause update incompatibility?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.
check https://github.com/apache/beam/pull/36184/files#r2359516983: MaybeReshuffle is defined dynamically (inside Create.expand?) which is affecting the inheritance.
The fields should be there if MaybeReshuffle was not nested.
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.
Thanks, chimed in on that thread. I think we should fix the core label issue which is causing this issue.
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 think this fix is much better since it can handle other nested transforms.
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.
So would updating
beam/sdks/python/apache_beam/transforms/ptransform.py
Line 359 in 0432c22
The reason https://github.com/apache/beam/pull/36184/files#r2359516983 was breaking is because:
Map(<lambda at bigquery_file_loads.py:1157>)in https://github.com/apache/beam/pull/34807/filesSo if we:
beam/sdks/python/apache_beam/transforms/ptransform.py
Line 359 in 0432c22
Then we should fix this issue while avoiding any breaking changes.
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 don't know what you mean here. The nested transform misses many fields (check the rest of my PR), which are not needed when the transform is nested. My PR can make sure any future nested transform should work.
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 agree your PR works. But it is quite messy - for example, we check for the existence of a side_inputs property 3 times when the object is always a
PTransformobject. It seems much cleaner to just guarantee that this property will always exist onPTransformobjects. This also means that if we use these properties elsewhere (now or in the future), we don't need to do more of these kinds of checks.It seem reasonable to me that
PTransformshould have these fields in all cases. An alternative would bePTransformproviding some functions to get these properties if they exist.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.
Regardless, this is a minor code quality issue and not a correctness one. It doesn't need to block the PR if you disagree.