Skip to content

Commit 0c9a4e9

Browse files
authored
Merge pull request #3017 from googlyrahman/refactor-ai-migration-6ca0b3d1ec1a454ea32a74f32993f1c8
Migrate gsutil usage to gcloud storage
2 parents fb4d8c8 + fa5c145 commit 0c9a4e9

File tree

10 files changed

+17
-20
lines changed

10 files changed

+17
-20
lines changed

quests/data-science-on-gcp-edition1_tf2/03_sqlstudio/populate_table.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ bash authorize_cloudshell.sh
1313

1414
# the table name for mysqlimport comes from the filename, so rename our CSV files, changing bucket name as needed
1515
counter=0
16-
#for FILE in $(gsutil ls gs://${BUCKET}/flights/raw/2015*.csv); do
17-
# gsutil cp $FILE flights.csv-${counter}
16+
#for FILE in $(gcloud storage ls gs://${BUCKET}/flights/raw/2015*.csv); do
17+
# gcloud storage cp $FILE flights.csv-${counter}
1818
for FILE in 201501.csv 201507.csv; do
19-
gsutil cp gs://${BUCKET}/flights/raw/$FILE flights.csv-${counter}
19+
gcloud storage cp gs://${BUCKET}/flights/raw/$FILE flights.csv-${counter}
2020
counter=$((counter+1))
2121
done
2222

2323
# import csv files
2424
MYSQLIP=$(gcloud sql instances describe flights --format="value(ipAddresses.ipAddress)")
2525
mysqlimport --local --host=$MYSQLIP --user=root --ignore-lines=1 --fields-terminated-by=',' --password bts flights.csv-*
2626
rm flights.csv-*
27-

quests/data-science-on-gcp-edition1_tf2/04_streaming/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If you didn't go through Chapter 2, the simplest way to get the files you need i
4646
* In CloudShell, type:
4747
```
4848
bq mk flights
49-
gsutil cp airports.csv.gz gs://<BUCKET-NAME>/flights/airports/airports.csv.gz
49+
gcloud storage cp airports.csv.gz gs://<BUCKET-NAME>/flights/airports/airports.csv.gz
5050
./df06.py -p $DEVSHELL_PROJECT_ID -b <BUCKETNAME> --region us-central1
5151
```
5252
* Go to the GCP web console and wait for the Dataflow ch04timecorr job to finish. It might take several
@@ -121,4 +121,4 @@ If you didn't go through Chapter 2, the simplest way to get the files you need i
121121
* Follow the steps in the chapter to connect to Data Studio and create a GeoMap.
122122
* Stop the simulation program in CloudShell.
123123
* From the GCP web console, stop the Dataflow streaming pipeline.
124-
124+

quests/data-science-on-gcp-edition1_tf2/04_streaming/ingest_from_crsbucket.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ FROM=gs://data-science-on-gcp/flights/tzcorr
1010
TO=gs://$BUCKET/flights/tzcorr
1111

1212
#sharded files
13-
CMD="gsutil -m cp "
13+
CMD="gcloud storage cp "
1414
for SHARD in `seq -w 0 35`; do
1515
CMD="$CMD ${FROM}/all_flights-000${SHARD}-of-00036"
1616
done
@@ -19,7 +19,7 @@ echo $CMD
1919
$CMD
2020

2121
# individual files
22-
CMD="gsutil -m cp "
22+
CMD="gcloud storage cp "
2323
for FILE in airports/airports.csv.gz; do
2424
CMD="$CMD gs://data-science-on-gcp/flights/$FILE gs://$BUCKET/flights/$FILE"
2525
done
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
gsutil cat gs://cloud-training-demos-ml/flights/raw/201501.csv | head -1000 > 201501_part.csv
2+
gcloud storage cat gs://cloud-training-demos-ml/flights/raw/201501.csv | head -1000 > 201501_part.csv

quests/data-science-on-gcp-edition1_tf2/05_bqnotebook/load_into_bq.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BUCKET=$1
99

1010
bq show --format=prettyjson flights.simevents > simevents.json
1111

12-
ONE_FILE=$(gsutil ls gs://${BUCKET}/flights/tzcorr/all_flights-00001*)
12+
ONE_FILE=$(gcloud storage ls gs://${BUCKET}/flights/tzcorr/all_flights-00001*)
1313
echo "Creating table definition from $ONE_FILE"
1414
bq mk --external_table_definition=./tzcorr.json@CSV=$ONE_FILE flights.fedtzcorr
1515

quests/data-science-on-gcp-edition1_tf2/09_cloudml/deploy_model.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ REGION=$3
1616

1717
MODEL_NAME=flights
1818
VERSION_NAME=tf2
19-
EXPORT_PATH=$(gsutil ls gs://$BUCKET/flights/trained_model/${BEST_MODEL}export | tail -1)
19+
EXPORT_PATH=$(gcloud storage ls gs://$BUCKET/flights/trained_model/${BEST_MODEL}export | tail -1)
2020
echo $EXPORT_PATH
2121

2222
if [[ $(gcloud ai-platform models list --format='value(name)' --region=$REGION | grep $MODEL_NAME) ]]; then

quests/data-science-on-gcp-edition1_tf2/09_cloudml/flights_model_tf2.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"metadata": {},
134134
"outputs": [],
135135
"source": [
136-
"!gsutil ls $DATA_BUCKET"
136+
"!gcloud storage ls $DATA_BUCKET"
137137
]
138138
},
139139
{
@@ -329,7 +329,7 @@
329329
"metadata": {},
330330
"outputs": [],
331331
"source": [
332-
"!gsutil -m rm -rf $OUTDIR"
332+
"!gcloud storage rm --recursive --continue-on-error $OUTDIR"
333333
]
334334
},
335335
{
@@ -457,7 +457,7 @@
457457
"outputs": [],
458458
"source": [
459459
"%%bash\n",
460-
"model_dir=$(gsutil ls ${OUTDIR}/export | tail -1)\n",
460+
"model_dir=$(gcloud storage ls ${OUTDIR}/export | tail -1)\n",
461461
"echo $model_dir\n",
462462
"saved_model_cli show --tag_set serve --signature_def serving_default --dir $model_dir"
463463
]
@@ -474,7 +474,7 @@
474474
"REGION=us-east1\n",
475475
"MODEL_NAME=flights\n",
476476
"VERSION_NAME=tf2\n",
477-
"EXPORT_PATH=$(gsutil ls ${OUTDIR}/export | tail -1)\n",
477+
"EXPORT_PATH=$(gcloud storage ls ${OUTDIR}/export | tail -1)\n",
478478
"\n",
479479
"if [[ $(gcloud ai-platform models list --format='value(name)' | grep $MODEL_NAME) ]]; then\n",
480480
" echo \"$MODEL_NAME already exists\"\n",

quests/data-science-on-gcp-edition1_tf2/10_realtime/eval.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ fi
88
BUCKET=$1
99
PROJECT=$2
1010

11-
gsutil -m rm -rf gs://$BUCKET/flights/chapter10/eval
11+
gcloud storage rm --recursive --continue-on-error gs://$BUCKET/flights/chapter10/eval
1212

1313
cd chapter10
1414

1515
mvn compile exec:java \
1616
-Dexec.mainClass=com.google.cloud.training.flights.EvaluateModel \
1717
-Dexec.args="--fullDataset --maxNumWorkers=10 --autoscalingAlgorithm=THROUGHPUT_BASED --bucket=$BUCKET --project=$PROJECT"
18-

quests/data-science-on-gcp-edition1_tf2/10_realtime/ingest_2016.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export YEAR=2016
1111
bash ../02_ingest/download.sh
1212
bash ../02_ingest/zip_to_csv.sh
1313
bash ../02_ingest/quotes_comma.sh
14-
gsutil -m cp *.csv gs://$BUCKET/flights2016/raw
14+
gcloud storage cp *.csv gs://$BUCKET/flights2016/raw
1515
rm *.csv

quests/data-science-on-gcp-edition1_tf2/10_realtime/predict.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ fi
88
BUCKET=$1
99
PROJECT=$2
1010

11-
gsutil -m rm -rf gs://$BUCKET/flights/chapter10/output
11+
gcloud storage rm --recursive --continue-on-error gs://$BUCKET/flights/chapter10/output
1212
bq rm -f flights.predictions
1313

1414
cd chapter10
1515

1616
mvn compile exec:java \
1717
-Dexec.mainClass=com.google.cloud.training.flights.AddRealtimePrediction \
1818
-Dexec.args="--realtime --speedupFactor=60 --maxNumWorkers=10 --autoscalingAlgorithm=THROUGHPUT_BASED --bucket=$BUCKET --project=$PROJECT"
19-

0 commit comments

Comments
 (0)