-
Notifications
You must be signed in to change notification settings - Fork 228
Migrate gsutil usage to gcloud storage #4315
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
c24fac0
1115222
5506a3c
ccdb33e
c1378af
ff92ebe
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 |
|---|---|---|
|
|
@@ -296,8 +296,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", | ||
|
|
@@ -369,10 +368,10 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectCreator $BUCKET_URI\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.\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" | ||
| ] | ||
| # 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 ] | ||
|
||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -1068,30 +1067,25 @@ | |
| " + \"/evaluation_metrics\"\n", | ||
| " )\n", | ||
| " if tf.io.gfile.exists(EXECUTE_OUTPUT):\n", | ||
| " ! gsutil cat $EXECUTE_OUTPUT\n", | ||
| " return EXECUTE_OUTPUT\n", | ||
| " ! gcloud storage cat $EXECUTE_OUTPUT\n", " return EXECUTE_OUTPUT\n", | ||
| " elif tf.io.gfile.exists(GCP_RESOURCES):\n", | ||
| " ! gsutil cat $GCP_RESOURCES\n", | ||
| " return GCP_RESOURCES\n", | ||
| " ! gcloud storage cat $GCP_RESOURCES\n", " return GCP_RESOURCES\n", | ||
| " elif tf.io.gfile.exists(EVAL_METRICS):\n", | ||
| " ! gsutil cat $EVAL_METRICS\n", | ||
| " return EVAL_METRICS\n", | ||
| " ! gcloud storage cat $EVAL_METRICS\n", " return EVAL_METRICS\n", | ||
| "\n", | ||
| " return None\n", | ||
| "\n", | ||
| "\n", | ||
| "print(\"model-upload\")\n", | ||
| "artifacts = print_pipeline_output(job, \"model-upload\")\n", | ||
| "print(\"\\n\")\n", | ||
| "output = !gsutil cat $artifacts\n", | ||
| "print(output)\n", | ||
| "output = !gcloud storage cat $artifacts\n", "print(output)\n", | ||
| "output = json.loads(output[0])\n", | ||
| "model_id = output[\"artifacts\"][\"model\"][\"artifacts\"][0][\"metadata\"][\"resourceName\"]\n", | ||
| "print(\"model-batch-predict\")\n", | ||
| "artifacts = print_pipeline_output(job, \"model-batch-predict\")\n", | ||
| "print(\"\\n\")\n", | ||
| "output = !gsutil cat $artifacts\n", | ||
| "output = json.loads(output[0])\n", | ||
| "output = !gcloud storage cat $artifacts\n", "output = json.loads(output[0])\n", | ||
| "batch_job_id = output[\"artifacts\"][\"batchpredictionjob\"][\"artifacts\"][0][\"metadata\"][\n", | ||
| " \"resourceName\"\n", | ||
| "]" | ||
|
|
@@ -1133,8 +1127,7 @@ | |
| "# Delete the Cloud Storage bucket\n", | ||
| "delete_bucket = False # Set True for deletion\n", | ||
| "if delete_bucket:\n", | ||
| " ! gsutil rm -r $BUCKET_URI\n", | ||
| "\n", | ||
| " ! gcloud storage rm --recursive $BUCKET_URI\n", "\n", | ||
| "# Remove the locally generated files\n", | ||
| "! rm custom_model_training_spec.yaml\n", | ||
| "! rm -rf custom" | ||
|
|
||
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 is looking forLocation constraint:, but the note on the previous line correctly states thatgcloud storageuses title case for keys. The output fromgcloud storage ls --full --bucketswill beLocation Constraint:, causing thisgrepcommand to fail and break the logic for retrieving the bucket region.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