hjtran commented on code in PR #34716:
URL: https://github.com/apache/beam/pull/34716#discussion_r2056320828


##########
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:
   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



-- 
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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to