-
Notifications
You must be signed in to change notification settings - Fork 201
Migrate gsutil usage to gcloud storage #4340
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
Open
googlyrahman
wants to merge
1
commit into
GoogleCloudPlatform:main
Choose a base branch
from
googlyrahman:ai-gsutil-migration-3fa375abfcfd4b25980d15e376856598
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−124
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,8 +325,7 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "! gsutil mb -l $REGION gs://$BUCKET_NAME" | ||
| ] | ||
| "! gcloud storage buckets create --location $REGION gs://$BUCKET_NAME" ] | ||
|
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. For consistency with other files in this PR and for better script clarity, it's recommended to use |
||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -345,8 +344,7 @@ | |
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "! gsutil ls -al gs://$BUCKET_NAME" | ||
| ] | ||
| "! gcloud storage ls --all-versions --long gs://$BUCKET_NAME" ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -659,8 +657,7 @@ | |
| "! rm -f cifar.tar cifar.tar.gz\n", | ||
| "! tar cvf cifar.tar cifar\n", | ||
| "! gzip cifar.tar\n", | ||
| "! gsutil cp cifar.tar.gz gs://$BUCKET_NAME/trainer_cifar.tar.gz" | ||
| ] | ||
| "! gcloud storage cp cifar.tar.gz gs://$BUCKET_NAME/trainer_cifar.tar.gz" ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -1318,8 +1315,7 @@ | |
| " b64str = base64.b64encode(bytes.numpy()).decode(\"utf-8\")\n", | ||
| " f.write(json.dumps({input_name: {\"b64\": b64str}}) + \"\\n\")\n", | ||
| "\n", | ||
| "! gsutil cat $gcs_input_uri" | ||
| ] | ||
| "! gcloud storage cat $gcs_input_uri" ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
|
|
@@ -1643,8 +1639,7 @@ | |
| "source": [ | ||
| "def get_latest_predictions(gcs_out_dir):\n", | ||
| " \"\"\" Get the latest prediction subfolder using the timestamp in the subfolder name\"\"\"\n", | ||
| " folders = !gsutil ls $gcs_out_dir\n", | ||
| " latest = \"\"\n", | ||
| " folders = !gcloud storage ls $gcs_out_dir\n", " latest = \"\"\n", | ||
| " for folder in folders:\n", | ||
| " subfolder = folder.split(\"/\")[-2]\n", | ||
| " if subfolder.startswith(\"prediction-\"):\n", | ||
|
|
@@ -1663,10 +1658,8 @@ | |
| " folder = get_latest_predictions(\n", | ||
| " response.output_config.gcs_destination.output_uri_prefix\n", | ||
| " )\n", | ||
| " ! gsutil ls $folder/prediction*\n", | ||
| "\n", | ||
| " ! gsutil cat $folder/prediction*\n", | ||
| " break\n", | ||
| " ! gcloud storage ls $folder/prediction*\n", "\n", | ||
| " ! gcloud storage cat $folder/prediction*\n", " break\n", | ||
| " time.sleep(60)" | ||
| ] | ||
| }, | ||
|
|
@@ -2234,8 +2227,7 @@ | |
| " print(e)\n", | ||
| "\n", | ||
| "if delete_bucket and \"BUCKET_NAME\" in globals():\n", | ||
| " ! gsutil rm -r gs://$BUCKET_NAME" | ||
| ] | ||
| " ! gcloud storage rm --recursive gs://$BUCKET_NAME" ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For consistency with other files in this PR and for better script clarity, it's recommended to use
--location=$REGIONinstead of--location $REGION. Whilegcloudmight handle both, using the equals sign is more explicit and less prone to parsing errors in shell scripts.