-
Notifications
You must be signed in to change notification settings - Fork 228
Migrate gsutil usage to gcloud storage #4299
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
Changes from 1 commit
0f5d5ec
ca51487
4b426b1
0960f34
dfb710b
fe15792
4fb41a8
9f5cf1f
af53475
9aa9994
919212d
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -148,11 +148,10 @@ | |||||
| "if BUCKET_URI is None or BUCKET_URI.strip() == \"\" or BUCKET_URI == \"gs://\":\n", | ||||||
| " BUCKET_URI = f\"gs://{PROJECT_ID}-tmp-{now}-{str(uuid.uuid4())[:4]}\"\n", | ||||||
| " BUCKET_NAME = \"/\".join(BUCKET_URI.split(\"/\")[:3])\n", | ||||||
| " ! gsutil mb -l {REGION} {BUCKET_URI}\n", | ||||||
| "else:\n", | ||||||
| " ! gcloud storage buckets create --location={REGION} {BUCKET_URI}\n", "else:\n", | ||||||
| " assert BUCKET_URI.startswith(\"gs://\"), \"BUCKET_URI must start with `gs://`.\"\n", | ||||||
| " shell_output = ! gsutil ls -Lb {BUCKET_NAME} | grep \"Location constraint:\" | sed \"s/Location constraint://\"\n", | ||||||
| " bucket_region = shell_output[0].strip().lower()\n", | ||||||
| " # Note: The format of the full listing output is different. gcloud storage uses a title case for keys and will not display a field if its value is \"None\".\n", | ||||||
| " shell_output = ! gcloud storage ls --full --buckets {BUCKET_NAME} | grep \"Location constraint:\" | sed \"s/Location constraint://\"\n", " bucket_region = shell_output[0].strip().lower()\n", | ||||||
| " if bucket_region != REGION:\n", | ||||||
| " raise ValueError(\n", | ||||||
| " \"Bucket region %s is different from notebook region %s\"\n", | ||||||
|
|
@@ -174,7 +173,8 @@ | |||||
| "\n", | ||||||
| "\n", | ||||||
| "# Provision permissions to the SERVICE_ACCOUNT with the GCS bucket\n", | ||||||
| "! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.admin $BUCKET_NAME\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. | ||||||
|
||||||
| # 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. | |
| "# 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.", |
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.
[Resolved] fixed
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 automated migration has introduced a syntax error that will corrupt the notebook file. The
sourcefield in a notebook cell must be an array of strings. In this change, the comment on line 548 and the shell command on line 549 are not enclosed in quotes, making the JSON invalid. Additionally, the closing bracket]for the array has been moved to the end of line 549, which is also incorrect.Uh oh!
There was an error while loading. Please reload this page.
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.
[Resolved] fixed