robertwb commented on code in PR #30771:
URL: https://github.com/apache/beam/pull/30771#discussion_r1548638602


##########
sdks/python/apache_beam/testing/util.py:
##########
@@ -261,6 +261,19 @@ def assert_that(
   """
   assert isinstance(actual, pvalue.PCollection), (
       '%s is not a supported type for Beam assert' % type(actual))
+  pipeline = actual.pipeline
+  if getattr(pipeline, 'result', None) is not None:
+    # The pipeline was already run. The user most likely called assert_that
+    # after the pipeleline context.
+    raise RuntimeError(
+        'assert_that must be used within a beam.Pipeline context')
+
+  # If label is already in use, just append a number to it.

Review Comment:
   Can you add a comment as to why this is OK to do in this context?



##########
sdks/python/apache_beam/testing/util.py:
##########
@@ -261,6 +261,19 @@ def assert_that(
   """
   assert isinstance(actual, pvalue.PCollection), (
       '%s is not a supported type for Beam assert' % type(actual))
+  pipeline = actual.pipeline
+  if getattr(pipeline, 'result', None) is not None:

Review Comment:
   Nit: If pipeline is not used elsewhere, just do `getattr(actual.pipeline, 
'result', None)`



##########
sdks/python/apache_beam/testing/util.py:
##########
@@ -261,6 +261,19 @@ def assert_that(
   """
   assert isinstance(actual, pvalue.PCollection), (
       '%s is not a supported type for Beam assert' % type(actual))
+  pipeline = actual.pipeline
+  if getattr(pipeline, 'result', None) is not None:
+    # The pipeline was already run. The user most likely called assert_that
+    # after the pipeleline context.
+    raise RuntimeError(

Review Comment:
   +1, nice.



-- 
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]

Reply via email to