tvalentyn commented on code in PR #35647:
URL: https://github.com/apache/beam/pull/35647#discussion_r2240684315
##########
website/www/site/content/en/documentation/transforms/python/other/waiton.md:
##########
@@ -30,27 +30,33 @@ import apache_beam as beam
from apache_beam.transforms.util import WaitOn
# Example 1: Basic usage
-with beam.Pipeline() as p:
+ with beam.Pipeline(options=pipeline_options) as p:
main = p | 'CreateMain' >> beam.Create([1, 2, 3])
- signal = (p | 'CreateSignal' >> beam.Create(['a', 'b', 'c'])
- | 'ProcessSignal' >> beam.Map(lambda x: time.sleep(2) or x))
+ signal = (
+ p | 'CreateSignal' >> beam.Create(['a', 'b'])
+ | 'ProcessSignal' >> beam.Map(lambda x: print(f"Processing signal
element: {x}") or time.sleep(2)))
# Wait for 'signal' to complete before processing 'main'
- # Elements [1, 2, 3] pass through unchanged after 'signal' finishes
result = main | 'WaitOnSignal' >> WaitOn(signal)
- result | beam.Map(print)
+
+ # Print each result to logs.
+ result | 'PrintExample1' >> beam.Map(lambda x: print(f"Example 1 Final
Output: {x}"))
# Example 2: Using multiple signals
-with beam.Pipeline() as p:
- main = p | 'CreateMain' >> beam.Create([1, 2, 3])
- signal1 = (p | 'CreateSignal1' >> beam.Create(['a', 'b', 'c'])
- | 'ProcessSignal1' >> beam.Map(lambda x: time.sleep(1) or
x.upper()))
- signal2 = (p | 'CreateSignal2' >> beam.Create(['x', 'y', 'z'])
- | 'ProcessSignal2' >> beam.Map(lambda x: time.sleep(3) or x *
2))
+ with beam.Pipeline(options=pipeline_options) as p:
Review Comment:
I noticed you added extra indentation in Java and Python examples - was that
intentional?
--
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]