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/08 13:23:49 UTC

[GitHub] [beam] pabloem commented on a change in pull request #12703: [BEAM-10603] Add describe and cancel to RecordingManager

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



##########
File path: sdks/python/apache_beam/runners/interactive/recording_manager.py
##########
@@ -63,6 +63,12 @@ def var(self):
     """Returns the variable named that defined this PCollection."""
     return self._var
 
+  def cache_key(self):

Review comment:
       Generally doing this is not necessary. You can name the attribute `self.cache_key`, and users can access the attribute directly, unless there's a strong reason not to.

##########
File path: sdks/python/apache_beam/runners/interactive/recording_manager.py
##########
@@ -258,16 +278,44 @@ 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())

Review comment:
       It's a little unsafe to use string representation as keys, no? Should CacheKey implement a hash method instead?

##########
File path: sdks/python/apache_beam/runners/interactive/recording_manager.py
##########
@@ -258,16 +278,44 @@ 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())

Review comment:
       It seems that we're using the string representation everywhere, so it may represent a large change - and I see it;s a carefully written repr method, so it's not necessary for this PR.




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