-
Notifications
You must be signed in to change notification settings - Fork 202
Migrate gsutil usage to gcloud storage #4334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -394,8 +394,7 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "! gsutil mb -l {LOCATION} -p {PROJECT_ID} {BUCKET_URI}" | ||
| ] | ||
| "! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}" ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -467,10 +466,11 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectCreator $BUCKET_URI\n", | ||
| "\n", | ||
| "! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectViewer $BUCKET_URI" | ||
| ] | ||
| "# Note: Migrating scripts using gsutil iam ch is more complex than get or set. You need to replace the single iam ch command with a series of gcloud storage bucket add-iam-policy-binding and/or gcloud storage bucket remove-iam-policy-binding commands, or replicate the read-modify-write loop.\n", | ||
| "# Note: gsutil iam ch does not support modifying IAM policies that contain conditions. gcloud storage commands do support conditions.\n", | ||
| "! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectCreator\n", "\n", | ||
| # Note: Migrating scripts using gsutil iam ch is more complex than get or set. You need to replace the single iam ch command with a series of gcloud storage bucket add-iam-policy-binding and/or gcloud storage bucket remove-iam-policy-binding commands, or replicate the read-modify-write loop. | ||
| ! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectViewer ] | ||
|
Comment on lines
+469
to
+473
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change introduces a syntax error into the notebook's JSON structure. The |
||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -602,7 +602,7 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "! gsutil cp gs://cloud-samples-data/vertex-ai/community-content/datasets/abalone/abalone.data {RAW_INPUT_DATA}" | ||
| "! gcloud storage cp gs://cloud-samples-data/vertex-ai/community-content/datasets/abalone/abalone.data {RAW_INPUT_DATA}" | ||
| ] | ||
| }, | ||
| { | ||
|
|
@@ -1611,8 +1611,7 @@ | |
| "# Delete Cloud Storage bucket\n", | ||
| "delete_bucket = True\n", | ||
| "if delete_bucket:\n", | ||
| " ! gsutil rm -r $BUCKET_URI\n", | ||
| "\n", | ||
| " ! gcloud storage rm --recursive $BUCKET_URI\n", "\n", | ||
| "# Delete the pipeline package file\n", | ||
| "! rm PIPELINE_YAML_PKG_PATH" | ||
| ] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
grepcommand is case-sensitive and will likely fail. The output ofgcloud storage ls --full --bucketsfor the location isLocation Constraint:(with a capital 'C'), but thegrepcommand is searching forLocation constraint:(with a lowercase 'c'). This will causeshell_outputto be empty and the script to fail. Additionally, thesedcommand is also case-sensitive and should be updated.To fix this, please update both
grepandsedto match the new output's capitalization.