mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Migrate gsutil usage to gcloud storage (#4301)
* Migrate gsutil usage to gcloud storage
* changes for 4301
* linter changes
* Revert "linter changes"
This reverts commit 6665133b2c.
* Apply automated linter fixes
* Update training-multi-class-classification-model-for-ads-targeting-usecase.ipynb
* Update training-multi-class-classification-model-for-ads-targeting-usecase.ipynb
* removed model_garden folder changes
* Update model_garden_mediapipe_object_detection.ipynb
---------
Co-authored-by: gurusai-voleti <gvoleti@google.com>
This commit is contained in:
co-authored by
gurusai-voleti
parent
9e590d5a9f
commit
f6c8bcf937
@@ -761,7 +761,7 @@
|
||||
"\n",
|
||||
"BUCKET_ID = \"code-samples-\" + str(uuid.uuid1())\n",
|
||||
"\n",
|
||||
"!gsutil mb gs://{BUCKET_ID}"
|
||||
"!gcloud storage buckets create gs://{BUCKET_ID}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -874,7 +874,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# # Delete the Google Cloud Storage bucket and files\n",
|
||||
"# ! gsutil rm -r gs://{BUCKET_ID}\n",
|
||||
"# ! gcloud storage rm --recursive gs://{BUCKET_ID}\n",
|
||||
"# print(f\"Deleted bucket '{BUCKET_ID}'.\")"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil mb -l $REGION $BUCKET_URI"
|
||||
"! gcloud storage buckets create --location=$REGION $BUCKET_URI"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -584,7 +584,7 @@
|
||||
"print(IMPORT_FILE)\n",
|
||||
"\n",
|
||||
"# printing content of uploaded file\n",
|
||||
"! gsutil cat $IMPORT_FILE"
|
||||
"! gcloud storage cat $IMPORT_FILE"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -707,7 +707,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# create placeholder file for instructions for data labeling\n",
|
||||
"! echo \"this is instruction\" >> instruction.txt | gsutil cp instruction.txt $BUCKET_URI"
|
||||
"! echo \"this is instruction\" >> instruction.txt | gcloud storage cp instruction.txt $BUCKET_URI"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -864,7 +864,7 @@
|
||||
"\n",
|
||||
"# Delete the bucket created\n",
|
||||
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
|
||||
" ! gsutil rm -r $BUCKET_URI"
|
||||
" ! gcloud storage rm --recursive $BUCKET_URI"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
+5
-5
@@ -291,7 +291,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
|
||||
"! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -372,13 +372,13 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"count = ! gsutil cat $IMPORT_FILE | wc -l\n",
|
||||
"count = ! gcloud storage cat $IMPORT_FILE | wc -l\n",
|
||||
"print(\"Number of Examples\", int(count[0]))\n",
|
||||
"\n",
|
||||
"print(\"First 10 rows\")\n",
|
||||
"! gsutil cat $IMPORT_FILE | head\n",
|
||||
"! gcloud storage cat $IMPORT_FILE | head\n",
|
||||
"\n",
|
||||
"heading = ! gsutil cat $IMPORT_FILE | head -n1\n",
|
||||
"heading = ! gcloud storage cat $IMPORT_FILE | head -n1\n",
|
||||
"label_column = str(heading).split(\",\")[-1].split(\"'\")[0]\n",
|
||||
"print(\"Label Column Name\", label_column)\n",
|
||||
"if label_column is None:\n",
|
||||
@@ -840,7 +840,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"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -217,7 +217,7 @@
|
||||
"source": [
|
||||
"# Create GCS Bucket\n",
|
||||
"BUCKET_URI = \"gs://your-bucket-name-unique\" # @param {type:\"string\"}\n",
|
||||
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
|
||||
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -309,7 +309,7 @@
|
||||
"IMAGE_URI = \"us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-12:latest\"\n",
|
||||
"\n",
|
||||
"# Copy Test Models to the Bucket\n",
|
||||
"! gsutil -m cp -r \"gs://cloud-samples-data/vertex-ai/prediction/test-models-requests/tensorflow/*\" {ARTIFACT_URI}\n",
|
||||
"! gcloud storage cp --recursive \"gs://cloud-samples-data/vertex-ai/prediction/test-models-requests/tensorflow/*\" {ARTIFACT_URI}\n",
|
||||
"\n",
|
||||
"model = aiplatform.Model.upload(\n",
|
||||
" display_name=DISPLAY_NAME,\n",
|
||||
@@ -786,7 +786,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil rm -r {BUCKET_URI}"
|
||||
"! gcloud storage rm --recursive {BUCKET_URI}"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+4
-4
@@ -347,7 +347,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
|
||||
"! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -720,9 +720,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"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -840,7 +840,7 @@
|
||||
"# Delete GCS bucket.\n",
|
||||
"delete_bucket = False\n",
|
||||
"if delete_bucket:\n",
|
||||
" ! gsutil -m rm -r $BUCKET_URI"
|
||||
" ! gcloud storage rm --recursive $BUCKET_URI"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -350,7 +350,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}"
|
||||
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -846,7 +846,7 @@
|
||||
"# Delete GCS 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}"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
+2
-2
@@ -282,7 +282,7 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"! gsutil mb -l $LOCATION -p $PROJECT_ID $BUCKET_URI"
|
||||
"! gcloud storage buckets create --location=$LOCATION --project=$PROJECT_ID $BUCKET_URI"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -840,7 +840,7 @@
|
||||
"\n",
|
||||
"delete_bucket = False\n",
|
||||
"if delete_bucket:\n",
|
||||
" ! gsutil -m rm -r $BUCKET_URI"
|
||||
" ! gcloud storage rm --recursive $BUCKET_URI"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user