[
https://issues.apache.org/jira/browse/BEAM-8335?focusedWorklogId=342811&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-342811
]
ASF GitHub Bot logged work on BEAM-8335:
----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Nov/19 19:23
Start Date: 13/Nov/19 19:23
Worklog Time Spent: 10m
Work Description: davidyan74 commented on pull request #9953: [BEAM-8335]
Adds support for multi-output TestStream
URL: https://github.com/apache/beam/pull/9953#discussion_r345951349
##########
File path: sdks/python/apache_beam/testing/test_stream_test.py
##########
@@ -125,6 +125,98 @@ def process(self, element=beam.DoFn.ElementParam,
p.run()
+ def test_multiple_outputs(self):
+ """Tests that the TestStream supports emitting to multiple PCollections."""
+ test_stream = (TestStream()
+ .advance_watermark_to(5, tag='letters')
+ .add_elements(['a', 'b', 'c'], tag='letters')
+ .advance_watermark_to(10, tag='numbers')
+ .add_elements(['1', '2', '3'], tag='numbers'))
+
+ class RecordFn(beam.DoFn):
+ def process(self, element=beam.DoFn.ElementParam,
+ timestamp=beam.DoFn.TimestampParam):
+ yield (element, timestamp)
+
+ options = StandardOptions(streaming=True)
+ p = TestPipeline(options=options)
+
+ main = p | test_stream
+ letters = main['letters'] | 'record letters' >> beam.ParDo(RecordFn())
+ numbers = main['numbers'] | 'record numbers' >> beam.ParDo(RecordFn())
+
+ assert_that(letters, equal_to([
+ ('a', Timestamp(5)),
+ ('b', Timestamp(5)),
+ ('c', Timestamp(5))]), label='assert letters')
+
+ assert_that(numbers, equal_to([
+ ('1', Timestamp(10)),
+ ('2', Timestamp(10)),
+ ('3', Timestamp(10))]), label='assert numbers')
+
+ p.run()
+
+ def test_multiple_outputs_with_watermark_advancement(self):
+ """Tests that the TestStream can independently output watermarks."""
+
+ # Purposely set the watmerk of numbers to 20 then letters to 5 to test
+ # that the watermark advancement is per PCollection.
+ test_stream = (TestStream()
+ .advance_watermark_to(20, tag='numbers')
+ .advance_watermark_to(5, tag='letters')
+ .add_elements(['a', 'b', 'c'], tag='letters')
+ .advance_watermark_to(10, tag='letters')
+ .add_elements(['1', '2', '3'], tag='numbers')
+ .advance_watermark_to(30, tag='numbers'))
+
+ options = StandardOptions(streaming=True)
+ p = TestPipeline(options=options)
+
+ main = p | test_stream
+ letters = (main['letters']
+ | 'letter windows' >> beam.WindowInto(
+ FixedWindows(15),
+ trigger=trigger.AfterWatermark(early=trigger.AfterCount(1)),
+ accumulation_mode=trigger.AccumulationMode.DISCARDING)
+ | 'letter with key' >> beam.Map(lambda x: ('k', x))
+ | 'letter gbk' >> beam.GroupByKey())
+
+ numbers = (main['numbers']
+ | 'number windows' >> beam.WindowInto(
+ FixedWindows(15),
+ trigger=trigger.AfterWatermark(early=trigger.AfterCount(1)),
+ accumulation_mode=trigger.AccumulationMode.DISCARDING)
+ | 'number with key' >> beam.Map(lambda x: ('k', x))
+ | 'number gbk' >> beam.GroupByKey())
+
+ expected_letters = {
+ window.IntervalWindow(0, 15): [
+ ('k', ['a', 'b', 'c']),
Review comment:
Thanks for adding this test to verify the watermarks! I assume this line is
for the trigger because of the advancement of watermark to 5 for "letters", and
then the following line is an empty pane because we are discarding after the
trigger because of the accumulation mode. Please add comments to help the
reader understand this test.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 342811)
Time Spent: 24h (was: 23h 50m)
> Add streaming support to Interactive Beam
> -----------------------------------------
>
> Key: BEAM-8335
> URL: https://issues.apache.org/jira/browse/BEAM-8335
> Project: Beam
> Issue Type: Improvement
> Components: runner-py-interactive
> Reporter: Sam Rohde
> Assignee: Sam Rohde
> Priority: Major
> Time Spent: 24h
> Remaining Estimate: 0h
>
> This issue tracks the work items to introduce streaming support to the
> Interactive Beam experience. This will allow users to:
> * Write and run a streaming job in IPython
> * Automatically cache records from unbounded sources
> * Add a replay experience that replays all cached records to simulate the
> original pipeline execution
> * Add controls to play/pause/stop/step individual elements from the cached
> records
> * Add ability to inspect/visualize unbounded PCollections
--
This message was sent by Atlassian Jira
(v8.3.4#803005)