Commit a0cf359 3 people authored and committed
1 parent f2f0136 commit a0cf359 Copy full SHA for a0cf359
File tree 1 file changed +15
-5
lines changed
generated_samples/interactive-tutorials/product/setup_product
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
import datetime
16
+ from pathlib import Path , PurePath
16
17
17
18
import google .auth
18
19
19
20
from setup_cleanup import create_bucket , upload_blob
20
21
21
22
project_id = google .auth .default ()[1 ]
22
23
timestamp_ = datetime .datetime .now ().timestamp ().__round__ ()
23
- bucket_name = f"{ project_id } _products_{ timestamp_ } "
24
+ BUCKET_NAME = f"{ project_id } _products_{ timestamp_ } "
24
25
25
- create_bucket (bucket_name )
26
- upload_blob (bucket_name , "../resources/products.json" )
27
- upload_blob (bucket_name , "../resources/products_some_invalid.json" )
28
26
29
- print (f"\n The gcs bucket { bucket_name } was created" )
27
+ def create_gcs_bucket (bucket_name = BUCKET_NAME ):
28
+ create_bucket (bucket_name )
29
+
30
+ path_to_resources_dir = PurePath (
31
+ Path .home (), "cloudshell_open/python-retail/samples/interactive-tutorials/resources"
32
+ )
33
+ upload_blob (bucket_name , str (path_to_resources_dir / "products.json" ))
34
+ upload_blob (bucket_name , str (path_to_resources_dir / "products_some_invalid.json" ))
35
+ print (f"\n The gcs bucket { bucket_name } was created" )
36
+
37
+
38
+ if __name__ == "__main__" :
39
+ create_gcs_bucket ()
You can’t perform that action at this time.
0 commit comments