[ https://issues.apache.org/jira/browse/BEAM-8335?focusedWorklogId=408309&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-408309 ]
ASF GitHub Bot logged work on BEAM-8335: ---------------------------------------- Author: ASF GitHub Bot Created on: 23/Mar/20 20:59 Start Date: 23/Mar/20 20:59 Worklog Time Spent: 10m Work Description: robertwb commented on pull request #11148: [BEAM-8335] Adds a streaming wordcount integration test URL: https://github.com/apache/beam/pull/11148#discussion_r396752506 ########## File path: sdks/python/apache_beam/runners/interactive/interactive_runner_test.py ########## @@ -147,6 +150,97 @@ def process(self, element): ] self.assertEqual(actual_reified, expected_reified) + def test_streaming_wordcount(self): + class WordExtractingDoFn(beam.DoFn): + def process(self, element): + text_line = element.strip() + words = text_line.split() + return words + + # Add the TestStream so that it can be cached. + ib.options.capturable_sources.add(TestStream) + ib.options.capture_duration = timedelta(seconds=1) + + p = beam.Pipeline( + runner=interactive_runner.InteractiveRunner(), + options=StandardOptions(streaming=True)) + + data = ( + p + | TestStream() + .advance_watermark_to(0) + .advance_processing_time(1) + .add_elements(['to', 'be', 'or', 'not', 'to', 'be']) + .advance_watermark_to(20) + .advance_processing_time(1) + .add_elements(['to', 'be', 'or', 'not', 'to', 'be']) + .advance_watermark_to(40) + .advance_processing_time(1) + .add_elements(['to', 'be', 'or', 'not', 'to', 'be']) + | beam.WindowInto(beam.window.FixedWindows(10))) # yapf: disable + + counts = ( + data + | 'split' >> beam.ParDo(WordExtractingDoFn()) + | 'pair_with_one' >> beam.Map(lambda x: (x, 1)) + | 'group' >> beam.GroupByKey() + | 'count' >> beam.Map(lambda wordones: (wordones[0], sum(wordones[1])))) + + # Watch the local scope for Interactive Beam so that referenced PCollections + # will be cached. + ib.watch(locals()) + + # This is normally done in the interactive_utils when a transform is + # applied but needs an IPython environment. So we manually run this here. + ie.current_env().track_user_pipelines() + + # This tests that the data was correctly cached. + pane_info = PaneInfo(True, True, PaneInfoTiming.UNKNOWN, 0, 0) + expected_data_df = pd.DataFrame( + [('to', 0, [beam.window.IntervalWindow(0, 10)], pane_info), Review comment: It'd be easier to understand the test if there were less data. ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 408309) Time Spent: 114h (was: 113h 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: 114h > 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)