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



##########
File path: 
sdks/python/apache_beam/runners/interactive/interactive_environment.py
##########
@@ -358,18 +361,33 @@ def get_cache_manager(self, pipeline, 
create_if_absent=False):
     create_if_absent is True, creates and returns a new file based cache
     manager for the pipeline."""
     cache_manager = self._cache_managers.get(str(id(pipeline)), None)
+    pipeline_runner = pipeline.runner._underlying_runner
     if not cache_manager and create_if_absent:
-      from apache_beam.runners.interactive import interactive_beam as ib
-      if ib.options.cache_root:
-        #TODO(victorhc): Handle the case when the path starts with "gs://"
-        if ib.options.cache_root.startswith("gs://"):
-          raise ValueError("GCS paths are not currently supported.")
-        cache_dir = tempfile.mkdtemp(dir=ib.options.cache_root)
+      cache_root = self.options.cache_root
+      if cache_root:
+        if cache_root.startswith('gs://'):
+          cache_dir = self.assign_gcs_cache_dir(pipeline, cache_root)

Review comment:
       I might be on a wrong revision of this file. Is the function finalized 
to `assign_gcs_cache_dir` or `get_gcs_cache_dir`?

##########
File path: sdks/python/apache_beam/runners/interactive/utils_test.py
##########
@@ -327,5 +345,29 @@ def test_create_var_in_main(self):
     self.assertIs(getattr(main_session, name, None), value)
 
 
+@patch(
+    'apache_beam.io.gcp.internal.clients.storage.StorageV1',
+    return_value=MockStorageClient())
+class GCSUtilsTest(unittest.TestCase):
+  @patch(
+      'apache_beam.io.gcp.internal.clients.storage.StorageBucketsGetRequest',
+      return_value='test-bucket-not-found')
+  def test_assert_bucket_exists_not_found(self, mock_client, mock):
+    with self.assertRaises(ValueError):
+      utils.assert_bucket_exists('')
+
+  @patch(
+      'apache_beam.io.gcp.internal.clients.storage.StorageBucketsGetRequest',
+      return_value='test-bucket-not-verified')

Review comment:
       Can we add a test to verify if the warning is logged? See 
https://stackoverflow.com/questions/7472863/pydev-unittesting-how-to-capture-text-logged-to-a-logging-logger-in-captured-o
 for `self.assertLogs`.
   
   You need to get the logger with the module name.

##########
File path: 
sdks/python/apache_beam/runners/interactive/interactive_environment.py
##########
@@ -675,3 +693,12 @@ def get_sql_chain(self, pipeline, set_user_pipeline=False):
             pipeline)
       chain.user_pipeline = pipeline
     return chain
+
+  def get_gcs_cache_dir(self, pipeline, cache_dir):

Review comment:
       Can we add unit tests for this function too?




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to