[ 
https://issues.apache.org/jira/browse/BEAM-8335?focusedWorklogId=323578&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-323578
 ]

ASF GitHub Bot logged work on BEAM-8335:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Oct/19 17:01
            Start Date: 04/Oct/19 17:01
    Worklog Time Spent: 10m 
      Work Description: aaltay commented on pull request #9720: [BEAM-8335] Add 
initial modules for interactive streaming support
URL: https://github.com/apache/beam/pull/9720#discussion_r331591095
 
 

 ##########
 File path: sdks/python/apache_beam/testing/interactive_stream.py
 ##########
 @@ -0,0 +1,123 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import grpc
+import time
+
+from apache_beam.portability.api import beam_interactive_api_pb2
+from apache_beam.portability.api import beam_interactive_api_pb2_grpc
+from apache_beam.portability.api.beam_interactive_api_pb2_grpc import 
InteractiveServiceServicer
+from concurrent.futures import ThreadPoolExecutor
+
+
+def to_api_state(state):
+  if state == 'STOPPED':
+    return beam_interactive_api_pb2.StatusResponse.STOPPED
+  if state == 'PAUSED':
+    return beam_interactive_api_pb2.StatusResponse.PAUSED
+  return beam_interactive_api_pb2.StatusResponse.RUNNING
+
+class InteractiveStreamController(InteractiveServiceServicer):
+  def __init__(self, endpoint, streaming_cache):
+    self._endpoint = endpoint
+    self._server = grpc.server(ThreadPoolExecutor(max_workers=10))
+    beam_interactive_api_pb2_grpc.add_InteractiveServiceServicer_to_server(
+        self, self._server)
+    self._server.add_insecure_port(self._endpoint)
+    self._server.start()
+
+    self._streaming_cache = streaming_cache
+    self._state = 'STOPPED'
+    self._playback_speed = 1.0
+
+  def Start(self, request, context):
+    """Requests that the Service starts emitting elements.
+    """
+
+    self._next_state('RUNNING')
+    self._playback_speed = request.playback_speed or 1.0
+    self._playback_speed = max(min(self._playback_speed, 1000000.0), 0.001)
+    return beam_interactive_api_pb2.StartResponse()
+
+  def Stop(self, request, context):
+    """Requests that the Service stop emitting elements.
+    """
+    self._next_state('STOPPED')
+    return beam_interactive_api_pb2.StartResponse()
+
+  def Pause(self, request, context):
+    """Requests that the Service pause emitting elements.
+    """
+    self._next_state('PAUSED')
+    return beam_interactive_api_pb2.PauseResponse()
+
+  def Step(self, request, context):
+    """Requests that the Service emit a single element from each cached source.
+    """
+    self._next_state('STEP')
+    return beam_interactive_api_pb2.StepResponse()
+
+  def Status(self, request, context):
+    """Returns the status of the service.
+    """
+    resp = beam_interactive_api_pb2.StatusResponse()
+    resp.stream_time.GetCurrentTime()
+    resp.state = to_api_state(self._state)
+    return resp
+
+  def _reset_state(self):
+    self._reader = None
+    self._playback_speed = 1.0
+    self._state = 'STOPPED'
+
+  def _next_state(self, state):
+    if not self._state or self._state == 'STOPPED':
 
 Review comment:
   When would `not self._state` be true. It seems to be alway set to something.
 
----------------------------------------------------------------
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: 323578)
    Time Spent: 1h 20m  (was: 1h 10m)

> 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: 1h 20m
>  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)

Reply via email to