Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION gs://$BUCKET_NAME"
]
"! gcloud storage buckets create --location=$REGION gs://$BUCKET_NAME" ]
},
{
"cell_type": "markdown",
Expand All @@ -356,8 +355,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al gs://$BUCKET_NAME"
]
"! gcloud storage ls --all-versions --long gs://$BUCKET_NAME" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -483,8 +481,7 @@
},
"outputs": [],
"source": [
"! gsutil cat $IMPORT_FILE | head -n 10"
]
"! gcloud storage cat $IMPORT_FILE | head -n 10" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1140,8 +1137,7 @@
},
"outputs": [],
"source": [
"test_item = ! gsutil cat $IMPORT_FILE | head -n1\n",
"test_item, test_label = str(test_item[0]).split(\",\")\n",
"test_item = ! gcloud storage cat $IMPORT_FILE | head -n1\n", "test_item, test_label = str(test_item[0]).split(\",\")\n",
"\n",
"print(test_item, test_label)"
]
Expand Down Expand Up @@ -1175,9 +1171,7 @@
},
"outputs": [],
"source": [
"! gsutil cat $gcs_input_uri\n",
"! gsutil cat $test_item_uri"
]
"! gcloud storage cat $gcs_input_uri\n", "! gcloud storage cat $test_item_uri" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1325,9 +1319,7 @@
"source": [
"destination_uri = output_config[\"gcs_destination\"][\"output_uri_prefix\"][:-1]\n",
"\n",
"! gsutil ls $destination_uri/*\n",
"! gsutil cat $destination_uri/prediction*/*.jsonl"
]
"! gcloud storage ls $destination_uri/*\n", "! gcloud storage cat $destination_uri/prediction*/*.jsonl" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1441,8 +1433,7 @@
},
"outputs": [],
"source": [
"test_item = ! gsutil cat $IMPORT_FILE | head -n1\n",
"test_item, test_label = str(test_item[0]).split(\",\")"
"test_item = ! gcloud storage cat $IMPORT_FILE | head -n1\n", "test_item, test_label = str(test_item[0]).split(\",\")"
]
},
{
Expand Down Expand Up @@ -1635,8 +1626,7 @@
"\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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
"! gcloud storage buckets create --location=$REGION $BUCKET_URI" ]
},
{
"cell_type": "markdown",
Expand All @@ -455,8 +454,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
]
"! gcloud storage ls --all-versions --long $BUCKET_URI" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -850,8 +848,7 @@
"! bq extract -m $param\n",
"\n",
"MODEL_DIR = f\"{BUCKET_URI}/{BQ_DATASET_NAME}\"\n",
"! gsutil ls $MODEL_DIR"
]
"! gcloud storage ls $MODEL_DIR" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1398,8 +1395,7 @@
"delete_storage = False\n",
"if delete_storage or os.getenv(\"IS_TESTING\"):\n",
" # Delete the created GCS bucket\n",
" ! gsutil rm -r $BUCKET_URI"
]
" ! gcloud storage rm --recursive $BUCKET_URI" ]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
"! gcloud storage buckets create --location=$REGION $BUCKET_URI" ]
},
{
"cell_type": "markdown",
Expand All @@ -482,8 +481,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
]
"! gcloud storage ls --all-versions --long $BUCKET_URI" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -552,10 +550,9 @@
},
"outputs": [],
"source": [
"! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectCreator $BUCKET_URI\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.\n",
"! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectCreator\n", "\n",
"! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectViewer" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -801,10 +798,8 @@
"outputs": [],
"source": [
"GCS_WC_PY = BUCKET_URI + \"/wc.py\"\n",
"! gsutil cp wc.py $GCS_WC_PY\n",
"GCS_REQUIREMENTS_TXT = BUCKET_URI + \"/requirements.txt\"\n",
"! gsutil cp requirements.txt $GCS_REQUIREMENTS_TXT\n",
"\n",
"! gcloud storage cp wc.py $GCS_WC_PY\n", "GCS_REQUIREMENTS_TXT = BUCKET_URI + \"/requirements.txt\"\n",
"! gcloud storage cp requirements.txt $GCS_REQUIREMENTS_TXT\n", "\n",
"GCS_WC_OUT = BUCKET_URI + \"/wc_out.txt\""
]
},
Expand Down Expand Up @@ -872,8 +867,7 @@
"\n",
"pipeline.run()\n",
"\n",
"! gsutil cat {GCS_WC_OUT}* | head -n10\n",
"\n",
"! gcloud storage cat {GCS_WC_OUT}* | head -n10\n", "\n",
"! rm -f dataflow_wc.json wc.py requirements.txt"
]
},
Expand Down Expand Up @@ -1097,12 +1091,10 @@
"outputs": [],
"source": [
"GCS_SPLIT_PY = BUCKET_URI + \"/split.py\"\n",
"! gsutil cp split.py $GCS_SPLIT_PY\n",
"GCS_REQUIREMENTS_TXT = BUCKET_URI + \"/requirements.txt\"\n",
"! gsutil cp requirements.txt $GCS_REQUIREMENTS_TXT\n",
"! gcloud storage cp split.py $GCS_SPLIT_PY\n", "GCS_REQUIREMENTS_TXT = BUCKET_URI + \"/requirements.txt\"\n",
"! gcloud storage cp requirements.txt $GCS_REQUIREMENTS_TXT\n",
"GCS_SETUP_PY = BUCKET_URI + \"/setup.py\"\n",
"! gsutil cp setup.py $GCS_SETUP_PY"
]
"! gcloud storage cp setup.py $GCS_SETUP_PY" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1202,8 +1194,7 @@
"\n",
"pipeline.run()\n",
"\n",
"! gsutil ls {BUCKET_URI}/exported_data\n",
"\n",
"! gcloud storage ls {BUCKET_URI}/exported_data\n", "\n",
"! rm -f dataflow_split.json split.py requirements.txt"
]
},
Expand Down Expand Up @@ -1258,8 +1249,7 @@
"delete_bucket = False\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
" ! gcloud storage rm --recursive $BUCKET_URI" ]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
"! gcloud storage buckets create --location=$REGION $BUCKET_URI" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -427,10 +426,9 @@
},
"outputs": [],
"source": [
"! gsutil iam ch serviceAccount:{SERVICE_ACCOUNT}:roles/storage.objectCreator $BUCKET_URI\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.\n",
"! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectCreator\n", "\n",
"! gcloud storage buckets add-iam-policy-binding $BUCKET_URI --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.objectViewer" ]
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -1386,8 +1384,7 @@
"delete_bucket = False\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
" ! gcloud storage rm --recursive $BUCKET_URI" ]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,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".
" 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",
Expand All @@ -215,8 +214,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",
"\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_NAME --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.admin\n", "\n",
"! gcloud config set project $PROJECT_ID\n",
"! gcloud projects add-iam-policy-binding --no-user-output-enabled {PROJECT_ID} --member=serviceAccount:{SERVICE_ACCOUNT} --role=\"roles/storage.admin\"\n",
"! gcloud projects add-iam-policy-binding --no-user-output-enabled {PROJECT_ID} --member=serviceAccount:{SERVICE_ACCOUNT} --role=\"roles/aiplatform.user\""
Expand Down Expand Up @@ -335,9 +334,7 @@
"if dataset_validation_util.is_gcs_path(pretrained_model_id):\n",
" # Download tokenizer.\n",
" ! mkdir tokenizer\n",
" ! gsutil cp {pretrained_model_id}/tokenizer.json ./tokenizer\n",
" ! gsutil cp {pretrained_model_id}/config.json ./tokenizer\n",
" tokenizer_path = \"./tokenizer\"\n",
" ! gcloud storage cp {pretrained_model_id}/tokenizer.json ./tokenizer\n", " ! gcloud storage cp {pretrained_model_id}/config.json ./tokenizer\n", " tokenizer_path = \"./tokenizer\"\n",
" access_token = \"\"\n",
"else:\n",
" tokenizer_path = pretrained_model_id\n",
Expand Down Expand Up @@ -891,8 +888,7 @@
"\n",
"delete_bucket = False # @param {type:\"boolean\"}\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_NAME"
]
" ! gcloud storage rm --recursive $BUCKET_NAME" ]
}
],
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,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".
" 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",
Expand All @@ -215,7 +214,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.\n",
"! gcloud storage buckets add-iam-policy-binding $BUCKET_NAME --member=serviceAccount:{SERVICE_ACCOUNT} --role=roles/storage.admin\n",
"\n",
"! gcloud config set project $PROJECT_ID\n",
"! gcloud projects add-iam-policy-binding --no-user-output-enabled {PROJECT_ID} --member=serviceAccount:{SERVICE_ACCOUNT} --role=\"roles/storage.admin\"\n",
Expand Down Expand Up @@ -335,9 +335,7 @@
"if dataset_validation_util.is_gcs_path(pretrained_model_id):\n",
" # Download tokenizer.\n",
" ! mkdir tokenizer\n",
" ! gsutil cp {pretrained_model_id}/tokenizer.json ./tokenizer\n",
" ! gsutil cp {pretrained_model_id}/config.json ./tokenizer\n",
" tokenizer_path = \"./tokenizer\"\n",
" ! gcloud storage cp {pretrained_model_id}/tokenizer.json ./tokenizer\n", " ! gcloud storage cp {pretrained_model_id}/config.json ./tokenizer\n", " tokenizer_path = \"./tokenizer\"\n",
" access_token = \"\"\n",
"else:\n",
" tokenizer_path = pretrained_model_id\n",
Expand Down Expand Up @@ -897,8 +895,7 @@
"\n",
"delete_bucket = False # @param {type:\"boolean\"}\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_NAME"
]
" ! gcloud storage rm --recursive $BUCKET_NAME" ]
}
],
"metadata": {
Expand Down
Loading
Loading