diff --git a/generated_samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py b/generated_samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py index fe976d7a5602..ac6c7a822c26 100644 --- a/generated_samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py +++ b/generated_samples/interactive-tutorials/product/setup_product/products_create_gcs_bucket.py @@ -13,6 +13,7 @@ # limitations under the License. import datetime +from pathlib import Path, PurePath import google.auth @@ -20,10 +21,19 @@ project_id = google.auth.default()[1] timestamp_ = datetime.datetime.now().timestamp().__round__() -bucket_name = f"{project_id}_products_{timestamp_}" +BUCKET_NAME = f"{project_id}_products_{timestamp_}" -create_bucket(bucket_name) -upload_blob(bucket_name, "../resources/products.json") -upload_blob(bucket_name, "../resources/products_some_invalid.json") -print(f"\nThe gcs bucket {bucket_name} was created") +def create_gcs_bucket(bucket_name=BUCKET_NAME): + create_bucket(bucket_name) + + path_to_resources_dir = PurePath( + Path.home(), "cloudshell_open/python-retail/samples/interactive-tutorials/resources" + ) + upload_blob(bucket_name, str(path_to_resources_dir / "products.json")) + upload_blob(bucket_name, str(path_to_resources_dir / "products_some_invalid.json")) + print(f"\nThe gcs bucket {bucket_name} was created") + + +if __name__ == "__main__": + create_gcs_bucket()