pavel-avilov commented on a change in pull request #16484:
URL: https://github.com/apache/beam/pull/16484#discussion_r803613949



##########
File path: playground/infrastructure/cd_helper.py
##########
@@ -103,12 +103,49 @@ def _save_to_cloud_storage(self, examples: List[Example]):
     """
     self._storage_client = storage.Client()
     self._bucket = self._storage_client.bucket(Config.BUCKET_NAME)
+
+    default_examples_paths = {}
     for example in tqdm(examples):
       file_names = self._write_to_local_fs(example)
+
+      if example.tag.default_example:
+        default_examples_paths[Sdk.Name(example.sdk)] = Path(
+            [*file_names].pop()).parent.__str__()

Review comment:
       Done

##########
File path: playground/infrastructure/cd_helper.py
##########
@@ -103,12 +103,49 @@ def _save_to_cloud_storage(self, examples: List[Example]):
     """
     self._storage_client = storage.Client()
     self._bucket = self._storage_client.bucket(Config.BUCKET_NAME)
+
+    default_examples_paths = {}
     for example in tqdm(examples):
       file_names = self._write_to_local_fs(example)
+
+      if example.tag.default_example:
+        default_examples_paths[Sdk.Name(example.sdk)] = Path(
+            [*file_names].pop()).parent.__str__()
+
       for cloud_file_name, local_file_name in file_names.items():
         self._upload_blob(
             source_file=local_file_name, destination_blob_name=cloud_file_name)
 
+    if len(default_examples_paths) > 0:
+      cloud_path = self._write_default_examples_paths_to_local_fs(
+          default_examples_paths)
+      self._upload_blob(
+          source_file=os.path.join(Config.TEMP_FOLDER, cloud_path),
+          destination_blob_name=cloud_path)
+
+  def _write_default_examples_paths_to_local_fs(self, paths: {}) -> str:
+    """
+    Write paths to default examples to the file (in temp folder)
+
+    Args:
+        paths: dict with paths
+
+    Returns: name of the file
+
+    """
+    cloud_path = os.path.join([*paths].pop(),
+                              Config.DEFAULT_PRECOMPILED_OBJECTS)
+
+    path_to_file = os.path.join(Config.TEMP_FOLDER, [*paths].pop())
+    Path(path_to_file).mkdir(parents=True, exist_ok=True)
+
+    local_path = os.path.join(path_to_file, Config.DEFAULT_PRECOMPILED_OBJECTS)
+    content = json.dumps(paths)
+    with open(local_path, "x", encoding="utf-8") as file:

Review comment:
       Done

##########
File path: playground/infrastructure/cd_helper.py
##########
@@ -103,12 +103,49 @@ def _save_to_cloud_storage(self, examples: List[Example]):
     """
     self._storage_client = storage.Client()
     self._bucket = self._storage_client.bucket(Config.BUCKET_NAME)
+
+    default_examples_paths = {}
     for example in tqdm(examples):
       file_names = self._write_to_local_fs(example)
+
+      if example.tag.default_example:
+        default_examples_paths[Sdk.Name(example.sdk)] = Path(
+            [*file_names].pop()).parent.__str__()
+
       for cloud_file_name, local_file_name in file_names.items():
         self._upload_blob(
             source_file=local_file_name, destination_blob_name=cloud_file_name)
 
+    if len(default_examples_paths) > 0:
+      cloud_path = self._write_default_examples_paths_to_local_fs(
+          default_examples_paths)
+      self._upload_blob(
+          source_file=os.path.join(Config.TEMP_FOLDER, cloud_path),
+          destination_blob_name=cloud_path)
+
+  def _write_default_examples_paths_to_local_fs(self, paths: {}) -> str:

Review comment:
       Done




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