-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Improve failure message when passing Pipeline object / PBegin objects… #34716
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
base: master
Are you sure you want to change the base?
Improve failure message when passing Pipeline object / PBegin objects… #34716
Conversation
Assigning reviewers. If you would like to opt out of this review, comment R: @damccorm for label python. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
try: | ||
return inputs[0].windowing | ||
except: | ||
raise AttributeError( | ||
f"'{type(inputs[0]).__name__}' object has no" | ||
" attribute 'windowing'. Expected a PCollection as input," | ||
f" but received '{type(inputs[0]).__name__}'. " | ||
"Did you accidentally pass a Pipeline object or a PBegin?") |
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 error message is much better!
I think when we're catching the exception here is a little late though, and this error message probably won't apply for all calls to get_windowing
.
It might make sense to catch the issue immediately when we apply the PIpeline
/PBegin
object rather than when we attempt to run the pipeline. I think this could be done by modifying PTransform.__ror__
. This would also minimize the risk that we raise this error message when it doesn't actually apply
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 @hjtran I'll check on this. Meanwhile, @tvalentyn do you have any suggestion here ?
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.
Did you accidentally pass a Pipeline object or a PBegin
I agree with @hjtran that it would be better to handle this error earlier in the call stack.
When an error from get_windowing
is raised with the message like Did you accidentally pass a Pipeline object or a PBegin
, the error suggests that a user might have passed a wrong argument to get_windowing
, but it's an internal function that they don't use, so users might be confused.
I think this could be done by modifying PTransform.ror
This sounds like a reasonable path to explore.
… (resolves #34703)
Please add a meaningful description for your change here
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.