KevinGG commented on a change in pull request #12703:
URL: https://github.com/apache/beam/pull/12703#discussion_r482393739



##########
File path: sdks/python/apache_beam/runners/interactive/recording_manager.py
##########
@@ -258,16 +278,46 @@ def _watch(self, pcolls):
         ie.current_env().watch(
             {'anonymous_pcollection_{}'.format(id(pcoll)): pcoll})
 
-  def clear(self, pcolls):
+  def _clear(self, pipeline_instrument):
     # type: (List[beam.pvalue.PCollection]) -> None
 
-    """Clears the cache of the given PCollections."""
+    """Clears the recording of all non-source PCollections."""
 
     cache_manager = ie.current_env().get_cache_manager(self.user_pipeline)
-    for pc in pcolls:
-      cache_key = self._pipeline_instrument.cache_key(pc)
+
+    # Only clear the PCollections that aren't being populated from the
+    # BackgroundCachingJob.
+    all_cached = set(
+        str(c.to_key()) for c in pipeline_instrument.cacheables.values())
+    source_pcolls = getattr(cache_manager, 'capture_keys', set())
+    to_clear = all_cached - source_pcolls
+
+    for cache_key in to_clear:
       cache_manager.clear('full', cache_key)
 
+  def cancel(self):
+    # type: (None) -> None
+
+    """Cancels the current background recording job."""
+
+    bcj = ie.current_env().get_background_caching_job(self.user_pipeline)
+    if bcj:
+      bcj.cancel()

Review comment:
       You can use `attempt_to_cancel_background_caching_job(user_pipeline)` 
https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/interactive/background_caching_job.py#L220




----------------------------------------------------------------
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]


Reply via email to