You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/09/22 22:42:44 UTC

[GitHub] [beam] rohdesamuel commented on a change in pull request #12800: [BEAM-10603] Add the ib.recordings API

rohdesamuel commented on a change in pull request #12800:
URL: https://github.com/apache/beam/pull/12800#discussion_r493073961



##########
File path: sdks/python/apache_beam/runners/interactive/interactive_environment.py
##########
@@ -348,6 +352,48 @@ def evict_cache_manager(self, pipeline=None):
       return self._cache_managers.pop(str(id(pipeline)), None)
     self._cache_managers.clear()
 
+  def set_recording_manager(self, recording_manager, pipeline):
+    """Sets the recording manager for the given pipeline."""
+    if self.get_recording_manager(pipeline) is recording_manager:
+      # NOOP if setting to the same recording_manager.
+      return
+    self._recording_managers[str(id(pipeline))] = recording_manager
+
+  def get_recording_manager(self, pipeline, create_if_absent=False):
+    """Gets the recording manager for the given pipeline."""
+    recording_manager = self._recording_managers.get(str(id(pipeline)), None)
+    if not recording_manager and create_if_absent:
+      recording_manager = RecordingManager(pipeline)
+      self._recording_managers[str(id(pipeline))] = recording_manager
+    return recording_manager
+
+  def evict_recording_manager(self, pipeline):
+    """Evicts the recording manager for the given pipeline.
+
+    This stops the background caching job and clears the cache.
+    Noop if the pipeline is absent from the environment. If no
+    pipeline is specified, evicts for all pipelines.
+    """
+    if not pipeline:
+      for rm in self._recording_managers.values():
+        rm.cancel()
+        rm.clear()
+      self._recording_managers = {}
+      return
+
+    recording_manager = self.get_recording_manager(pipeline)

Review comment:
       Added a del




----------------------------------------------------------------
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:
users@infra.apache.org