tvalentyn commented on code in PR #34716:
URL: https://github.com/apache/beam/pull/34716#discussion_r2072170431
##########
sdks/python/apache_beam/transforms/ptransform.py:
##########
@@ -560,7 +560,14 @@ def get_windowing(self, inputs):
with the input PCollection (or the first input if several).
"""
if inputs:
- return inputs[0].windowing
+ 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?")
Review Comment:
> 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.
--
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]