Skip to content

Commit 63efc78

Browse files
bhandarivijay-pngm-strzelczyk
authored andcommitted
Migrate gsutil usage to gcloud storage
1 parent 0021386 commit 63efc78

12 files changed

Lines changed: 19 additions & 20 deletions

File tree

dataflow/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def bucket_name(test_name: str, location: str, unique_id: str) -> Iterator[str]:
8585
# Try to remove all files before deleting the bucket.
8686
# Deleting a bucket with too many files results in an error.
8787
try:
88-
run_cmd("gsutil", "-m", "rm", "-rf", f"gs://{bucket_name}/*")
88+
run_cmd("gcloud", "storage", "rm", "--recursive", "--continue-on-error", f"gs://{bucket_name}/*")
8989
except RuntimeError:
9090
# If no files were found and it fails, ignore the error.
9191
pass

dataflow/encryption-keys/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Additionally, for this sample you need the following:
2525

2626
```sh
2727
export BUCKET=your-gcs-bucket
28-
gsutil mb gs://$BUCKET
28+
gcloud storage buckets create gs://$BUCKET
2929
```
3030

3131
1. [Create a symmetric key ring](https://cloud.google.com/kms/docs/creating-keys).
@@ -174,10 +174,10 @@ To avoid incurring charges to your GCP account for the resources used:
174174

175175
```sh
176176
# Remove only the files created by this sample.
177-
gsutil -m rm -rf "gs://$BUCKET/samples/dataflow/kms"
177+
gcloud storage rm --recursive --continue-on-error "gs://$BUCKET/samples/dataflow/kms"
178178

179179
# [optional] Remove the Cloud Storage bucket.
180-
gsutil rb gs://$BUCKET
180+
gcloud storage buckets delete gs://$BUCKET
181181

182182
# Remove the BigQuery table.
183183
bq rm -f -t $PROJECT:$DATASET.$TABLE

dataflow/flex-templates/getting_started/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Make sure you have followed the
99

1010
```sh
1111
export BUCKET="your--bucket"
12-
gsutil mb gs://$BUCKET
12+
gcloud storage buckets create gs://$BUCKET
1313
```
1414

1515
## create an Artifact Registry repository
@@ -51,4 +51,3 @@ gcloud dataflow flex-template run "flex-`date +%Y%m%d-%H%M%S`" \
5151

5252
For more information about building and running flex templates, see
5353
📝 [Use Flex Templates](https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates).
54-

dataflow/flex-templates/pipeline_with_dependencies/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ rules. It is optional.
7373
export PROJECT="project-id"
7474
export BUCKET="your-bucket"
7575
export REGION="us-central1"
76-
gsutil mb -p $PROJECT gs://$BUCKET
76+
gcloud storage buckets create gs://$BUCKET --project=$PROJECT
7777
```
7878

7979
## Create an Artifact Registry repository
@@ -165,7 +165,7 @@ gcloud dataflow flex-template run "flex-`date +%Y%m%d-%H%M%S`" \
165165
After the pipeline finishes, use the following command to inspect the output:
166166

167167
```bash
168-
gsutil cat gs://$BUCKET/output*
168+
gcloud storage cat gs://$BUCKET/output*
169169
```
170170

171171
## Optional: Update the dependencies in the requirements file and rebuild the Docker images

dataflow/flex-templates/streaming_beam/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Additionally, for this sample you need the following:
2525

2626
```sh
2727
export BUCKET="your-gcs-bucket"
28-
gsutil mb gs://$BUCKET
28+
gcloud storage buckets create gs://$BUCKET
2929
```
3030

3131
1. Create a
@@ -231,7 +231,7 @@ The following sections describe how to delete or turn off these resources.
231231
1. Delete the template spec file from Cloud Storage.
232232

233233
```sh
234-
gsutil rm $TEMPLATE_PATH
234+
gcloud storage rm $TEMPLATE_PATH
235235
```
236236

237237
1. Delete the Flex Template container image from Container Registry.
@@ -277,7 +277,7 @@ The following sections describe how to delete or turn off these resources.
277277
> These objects cannot be recovered.
278278
>
279279
> ```sh
280-
> gsutil rm -r gs://$BUCKET
280+
> gcloud storage rm --recursive gs://$BUCKET
281281
> ```
282282

283283
## Limitations

dataflow/gemma-flex-template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Click [here to create a GCS bucket](https://console.cloud.google.com/storage/cre
4343

4444
```sh
4545
export GCS_BUCKET="your--bucket"
46-
gsutil mb gs://$GCS_BUCKET
46+
gcloud storage buckets create gs://$GCS_BUCKET
4747
```
4848

4949
Make sure your GCS bucket name does __not__ include the `gs://` prefix

dataflow/gemma-flex-template/e2e_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def responses_subscription(
9292

9393
@pytest.fixture(scope="session")
9494
def flex_template_image(utils: Utils) -> str:
95-
conftest.run_cmd("gsutil", "cp", "-r", GEMMA_GCS, ".")
95+
conftest.run_cmd("gcloud", "storage", "cp", "--recursive", GEMMA_GCS, ".")
9696
yield from utils.cloud_build_submit(NAME)
9797

9898

dataflow/gemma/e2e_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_name() -> str:
6060
@pytest.fixture(scope="session")
6161
def container_image(utils: Utils) -> str:
6262
# Copy Gemma onto the local environment
63-
conftest.run_cmd("gsutil", "cp", "-r", GEMMA_GCS, ".")
63+
conftest.run_cmd("gcloud", "storage", "cp", "--recursive", GEMMA_GCS, ".")
6464
yield from utils.cloud_build_submit(NAME)
6565

6666

dataflow/run-inference/tests/e2e_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def dataflow_job(
9595
) -> Iterator[str]:
9696
# Upload the state dict to Cloud Storage.
9797
state_dict_gcs = f"gs://{bucket_name}/temp/state_dict.pt"
98-
conftest.run_cmd("gsutil", "cp", "-n", state_dict_path, state_dict_gcs)
98+
conftest.run_cmd("gcloud", "storage", "cp", "--no-clobber", state_dict_path, state_dict_gcs)
9999

100100
# Launch the streaming Dataflow pipeline.
101101
conftest.run_cmd(

dataflow/run_template/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Additionally, for this sample you need the following:
2929

3030
```sh
3131
export BUCKET=your-gcs-bucket
32-
gsutil mb gs://$BUCKET
32+
gcloud storage buckets create gs://$BUCKET
3333
```
3434

3535
1. Clone the `python-docs-samples` repository.

0 commit comments

Comments
 (0)