Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
"! gcloud storage buckets create --location $REGION $BUCKET_URI"
]
},
{
Expand All @@ -476,7 +476,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
"! gcloud storage ls --all-versions --long $BUCKET_URI"
]
},
{
Expand Down Expand Up @@ -546,9 +546,9 @@
},
"outputs": [],
"source": [
"! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectCreator $BUCKET_URI\n",
"! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectCreator\n",
"\n",
"! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectViewer $BUCKET_URI"
"! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectViewer"
]
},
{
Expand Down Expand Up @@ -678,7 +678,7 @@
"outputs": [],
"source": [
"GCS_AVRO_SCHEMA = BUCKET_URI + \"/gaming_schema.avsc\"\n",
"! gsutil cp gaming_schema.avsc $GCS_AVRO_SCHEMA\n",
"! gcloud storage cp gaming_schema.avsc $GCS_AVRO_SCHEMA\n",
"\n",
"GCS_FLEX_TEMPLATE_PATH = \"gs://dataflow-templates/latest/flex/File_Format_Conversion\"\n",
"GCS_CONVERT_IN = \"gs://dataflow-samples/game/5000_gaming_data.csv\"\n",
Expand Down Expand Up @@ -757,7 +757,7 @@
"\n",
"pipeline.run()\n",
"\n",
"! gsutil ls $GCS_CONVERT_OUT\n",
"! gcloud storage ls $GCS_CONVERT_OUT\n",
"\n",
"! rm -f dataflow_file_conversion.yaml gaming_schema.avsc"
]
Expand Down Expand Up @@ -813,7 +813,7 @@
"delete_bucket = False\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}"
]
},
{
Expand Down Expand Up @@ -394,11 +394,11 @@
"else:\n",
" FILE = IMPORT_FILE\n",
"\n",
"count = ! gsutil cat $FILE | wc -l\n",
"count = ! gcloud storage cat $FILE | wc -l\n",
"print(\"Number of Examples\", int(count[0]))\n",
"\n",
"print(\"First 10 rows\")\n",
"! gsutil cat $FILE | head"
"! gcloud storage cat $FILE | head"
]
},
{
Expand Down Expand Up @@ -580,7 +580,7 @@
},
"outputs": [],
"source": [
"test_items = !gsutil cat $IMPORT_FILE | head -n2\n",
"test_items = !gcloud storage cat $IMPORT_FILE | head -n2\n",
"if len(str(test_items[0]).split(\",\")) == 3:\n",
" _, test_item_1, test_label_1 = str(test_items[0]).split(\",\")\n",
" _, test_item_2, test_label_2 = str(test_items[1]).split(\",\")\n",
Expand Down Expand Up @@ -614,8 +614,8 @@
"file_1 = test_item_1.split(\"/\")[-1]\n",
"file_2 = test_item_2.split(\"/\")[-1]\n",
"\n",
"! gsutil cp $test_item_1 $BUCKET_URI/$file_1\n",
"! gsutil cp $test_item_2 $BUCKET_URI/$file_2\n",
"! gcloud storage cp $test_item_1 $BUCKET_URI/$file_1\n",
"! gcloud storage cp $test_item_2 $BUCKET_URI/$file_2\n",
"\n",
"test_item_1 = BUCKET_URI + \"/\" + file_1\n",
"test_item_2 = BUCKET_URI + \"/\" + file_2"
Expand Down Expand Up @@ -659,7 +659,7 @@
" f.write(json.dumps(data) + \"\\n\")\n",
"\n",
"print(gcs_input_uri)\n",
"! gsutil cat $gcs_input_uri"
"! gcloud storage cat $gcs_input_uri"
]
},
{
Expand Down Expand Up @@ -803,7 +803,7 @@
"# Delete the cloud storage bucket\n",
"delete_bucket = False # set True for deletion\n",
"if delete_bucket:\n",
" ! gsutil rm -r $BUCKET_URI"
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $LOCATION $BUCKET_URI"
"! gcloud storage buckets create --location=$LOCATION $BUCKET_URI"
]
},
{
Expand Down Expand Up @@ -386,7 +386,7 @@
"source": [
"#### Copying data between Google Cloud Storage Buckets\n",
"\n",
"In this step, you prevent access issues for the images in your original dataset. The code below extracts folder paths from image paths, constructs destination paths for Cloud Storage, copies images using gsutil commands, updates image paths in the DataFrame, and finally saves the modified DataFrame back to Cloud Storage as a CSV file."
"In this step, you prevent access issues for the images in your original dataset. The code below extracts folder paths from image paths, constructs destination paths for Cloud Storage, copies images using gcloud storage commands, updates image paths in the DataFrame, and finally saves the modified DataFrame back to Cloud Storage as a CSV file."
]
},
{
Expand Down Expand Up @@ -415,7 +415,7 @@
"\n",
"# Copy images using gsutil commands directly\n",
"for src, dest in zip(df.iloc[:, 0], df[\"destination_path\"]):\n",
" ! gsutil -m cp {src} {dest}\n",
" ! gcloud storage cp {src} {dest}\n",
"\n",
"print(f\"Files copied to {BUCKET_URI}\")"
]
Expand Down Expand Up @@ -496,11 +496,11 @@
"else:\n",
" FILE = IMPORT_FILE\n",
"\n",
"count = ! gsutil cat $FILE | wc -l\n",
"count = ! gcloud storage cat $FILE | wc -l\n",
"print(\"Number of Examples\", int(count[0]))\n",
"\n",
"print(\"First 10 rows\")\n",
"! gsutil cat $FILE | head"
"! gcloud storage cat $FILE | head"
]
},
{
Expand Down Expand Up @@ -706,7 +706,7 @@
},
"outputs": [],
"source": [
"test_items = !gsutil cat $IMPORT_FILE | head -n1\n",
"test_items = !gcloud storage cat $IMPORT_FILE | head -n1\n",
"cols = str(test_items[0]).split(\",\")\n",
"if len(cols) == 11:\n",
" test_item = str(cols[1])\n",
Expand Down Expand Up @@ -834,7 +834,7 @@
"dag.delete()\n",
"\n",
"if delete_bucket:\n",
" ! gsutil rm -r $BUCKET_URI"
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
"! gcloud storage buckets create {BUCKET_URI} --location={LOCATION} --project={PROJECT_ID}"
]
},
{
Expand Down Expand Up @@ -778,7 +778,7 @@
"# Delete Cloud Storage objects that were created\n",
"delete_bucket = False # set True for deletion\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_URI"
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
"):\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"-aip-\" + UUID\n",
"\n",
"! gsutil mb -l $LOCATION -p $PROJECT_ID $BUCKET_URI"
"! gcloud storage buckets create --location=$LOCATION --project=$PROJECT_ID $BUCKET_URI"
]
},
{
Expand Down Expand Up @@ -519,7 +519,7 @@
"outputs": [],
"source": [
"examples.to_json(\"evaluation_dataset.json\", orient=\"records\", lines=True)\n",
"! gsutil cp evaluation_dataset.json $BUCKET_URI/input/evaluation_dataset.json\n",
"! gcloud storage cp evaluation_dataset.json $BUCKET_URI/input/evaluation_dataset.json\n",
"DATASET = f\"{BUCKET_URI}/input/evaluation_dataset.json\""
]
},
Expand Down Expand Up @@ -765,7 +765,7 @@
"# Delete Cloud Storage objects that were created\n",
"delete_bucket = False\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_URI"
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $LOCATION -p $PROJECT_ID $BUCKET_URI"
"! gcloud storage buckets create --location=$LOCATION --project=$PROJECT_ID $BUCKET_URI"
]
},
{
Expand Down Expand Up @@ -480,7 +480,7 @@
"outputs": [],
"source": [
"# Download the sample code\n",
"! gsutil cp gs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz - | tar -xzv\n",
"! gcloud storage cp gs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz - | tar -xzv\n",
"%cd hello-custom-sample/"
]
},
Expand Down Expand Up @@ -664,7 +664,7 @@
"outputs": [],
"source": [
"GCS_BUCKET_TRAINING = f\"{BUCKET_URI}/data/\"\n",
"! gsutil cp dist/hello-custom-training-3.0.tar.gz {GCS_BUCKET_TRAINING}"
"! gcloud storage cp dist/hello-custom-training-3.0.tar.gz {GCS_BUCKET_TRAINING}"
]
},
{
Expand Down Expand Up @@ -787,7 +787,7 @@
"# Delete GCS bucket.\n",
"delete_bucket = False\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_URI\n",
" ! gcloud storage rm --recursive $BUCKET_URI\n",
"\n",
"!rm -rf ../hello-custom-sample/"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}"
]
},
{
Expand Down Expand Up @@ -696,11 +696,11 @@
},
"outputs": [],
"source": [
"!cd {PYTHON_PACKAGE_APPLICATION_DIR} && python3 setup.py sdist --formats=gztar\n",
"! cd {PYTHON_PACKAGE_APPLICATION_DIR} && python3 setup.py sdist --formats=gztar\n",
"\n",
"!gsutil cp {source_package_file_name} {python_package_gcs_uri}\n",
"! gcloud storage cp {source_package_file_name} {python_package_gcs_uri}\n",
"\n",
"!gsutil ls -l {python_package_gcs_uri}"
"! gcloud storage ls --long {python_package_gcs_uri}"
]
},
{
Expand Down Expand Up @@ -833,7 +833,7 @@
"# delete the bucket\n",
"delete_bucket = False # set True for deletion\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_URI"
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
Expand Down