KhaninArtur commented on a change in pull request #16484:
URL: https://github.com/apache/beam/pull/16484#discussion_r802716458
##########
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:
Do we have unit tests for this code?
##########
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:
Do you want to annotate the argument `paths` as a set? If so, it is
better to do so explicitly like `paths: set`
--
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]