linter changes

This commit is contained in:
gurusai-voleti
2025-12-12 06:32:48 +00:00
parent f60dd906f5
commit 6665133b2c
10 changed files with 55 additions and 31 deletions
@@ -761,7 +761,8 @@
"\n",
"BUCKET_ID = \"code-samples-\" + str(uuid.uuid1())\n",
"\n",
"!gcloud storage buckets create gs://{BUCKET_ID}" ]
"!gcloud storage buckets create gs://{BUCKET_ID}"
]
},
{
"cell_type": "markdown",
@@ -873,7 +874,8 @@
"outputs": [],
"source": [
"# # Delete the Google Cloud Storage bucket and files\n",
"# ! gcloud storage rm --recursive gs://{BUCKET_ID}\n", "# print(f\"Deleted bucket '{BUCKET_ID}'.\")"
"# ! gcloud storage rm --recursive gs://{BUCKET_ID}\n",
"# print(f\"Deleted bucket '{BUCKET_ID}'.\")"
]
}
],
@@ -353,7 +353,8 @@
},
"outputs": [],
"source": [
"! gcloud storage buckets create --location={REGION} --project={PROJECT_ID} {BUCKET_URI}" ]
"! gcloud storage buckets create --location={REGION} --project={PROJECT_ID} {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
@@ -581,7 +582,9 @@
"source": [
"# Move Flower data from local directory to Cloud Storage.\n",
"# This step takes around 2 mins to finish.\n",
"! gcloud storage cp --recursive $local_flower_data_directory/train/* $FLOWER_DATA_GCS_PATH/train/\n", "! gcloud storage cp --recursive $local_flower_data_directory/test/* $FLOWER_DATA_GCS_PATH/test/" ]
"! gcloud storage cp --recursive $local_flower_data_directory/train/* $FLOWER_DATA_GCS_PATH/train/\n",
"! gcloud storage cp --recursive $local_flower_data_directory/test/* $FLOWER_DATA_GCS_PATH/test/"
]
},
{
"cell_type": "markdown",
@@ -782,7 +785,7 @@
" serving_container_args=[],\n",
" location=REGION,\n",
" serving_container_environment_variables=serving_env,\n",
" model_garden_source_model_name=\"publishers/google/models/vit-jax\"\n",
" model_garden_source_model_name=\"publishers/google/models/vit-jax\",\n",
")\n",
"\n",
"jax_vit_endpoint = jax_vit_model.deploy(\n",
@@ -793,9 +796,7 @@
" accelerator_count=1,\n",
" min_replica_count=1,\n",
" max_replica_count=1,\n",
" system_labels={\n",
" \"NOTEBOOK_NAME\": \"model_garden_jax_vision_transformer.ipynb\"\n",
" },\n",
" system_labels={\"NOTEBOOK_NAME\": \"model_garden_jax_vision_transformer.ipynb\"},\n",
")"
]
},
@@ -864,7 +865,8 @@
"# Delete Cloud Storage objects that were created.\n",
"delete_bucket = False\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gcloud storage rm --recursive $BUCKET_URI" ]
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
"metadata": {
@@ -242,7 +242,7 @@
" local_metrics_path = os.path.join(temp_dir.name, label_map_yaml_filename)\n",
"\n",
" ! gcloud storage cp $label_map_yaml_filepath $local_metrics_path\n",
" with open(local_metrics_path, \"r\") as input_file:\n",
" with open(local_metrics_path) as input_file:\n",
" label_map = yaml.safe_load(input_file.read())[\"label_map\"]\n",
" temp_dir.cleanup()\n",
" return label_map\n",
@@ -501,7 +501,7 @@
" [\"gcloud\", \"storage\", \"cp\", evaluation_result_path, eval_result_filename],\n",
" stderr=subprocess.STDOUT,\n",
" )\n",
" with open(eval_result_filename, \"r\") as input_file:\n",
" with open(eval_result_filename) as input_file:\n",
" evalutation_result = json.loads(input_file.read())\n",
" return evalutation_result[\"loss\"], evalutation_result[\"coco_metrics\"]\n",
" except:\n",
@@ -381,7 +381,8 @@
},
"outputs": [],
"source": [
"! gcloud storage buckets create --location=$REGION $BUCKET_URI" ]
"! gcloud storage buckets create --location=$REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
@@ -583,7 +584,8 @@
"print(IMPORT_FILE)\n",
"\n",
"# printing content of uploaded file\n",
"! gcloud storage cat $IMPORT_FILE" ]
"! gcloud storage cat $IMPORT_FILE"
]
},
{
"cell_type": "markdown",
@@ -705,7 +707,8 @@
"outputs": [],
"source": [
"# create placeholder file for instructions for data labeling\n",
"! echo \"this is instruction\" >> instruction.txt | gcloud storage cp instruction.txt $BUCKET_URI" ]
"! echo \"this is instruction\" >> instruction.txt | gcloud storage cp instruction.txt $BUCKET_URI"
]
},
{
"cell_type": "code",
@@ -861,7 +864,8 @@
"\n",
"# Delete the bucket created\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gcloud storage rm --recursive $BUCKET_URI" ]
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
"metadata": {
@@ -291,7 +291,8 @@
},
"outputs": [],
"source": [
"! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}" ]
"! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
@@ -371,11 +372,14 @@
},
"outputs": [],
"source": [
"count = ! gcloud storage cat $IMPORT_FILE | wc -l\n", "print(\"Number of Examples\", int(count[0]))\n",
"count = ! gcloud storage cat $IMPORT_FILE | wc -l\n",
"print(\"Number of Examples\", int(count[0]))\n",
"\n",
"print(\"First 10 rows\")\n",
"! gcloud storage cat $IMPORT_FILE | head\n", "\n",
"heading = ! gcloud storage cat $IMPORT_FILE | head -n1\n", "label_column = str(heading).split(\",\")[-1].split(\"'\")[0]\n",
"! gcloud storage cat $IMPORT_FILE | head\n",
"\n",
"heading = ! gcloud storage cat $IMPORT_FILE | head -n1\n",
"label_column = str(heading).split(\",\")[-1].split(\"'\")[0]\n",
"print(\"Label Column Name\", label_column)\n",
"if label_column is None:\n",
" raise Exception(\"label column missing\")"
@@ -836,7 +840,8 @@
"# Delete the Cloud Storage bucket\n",
"delete_bucket = False # set True for deletion\n",
"if delete_bucket:\n",
" ! gcloud storage rm --recursive $BUCKET_URI" ]
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
"metadata": {
@@ -217,7 +217,8 @@
"source": [
"# Create GCS Bucket\n",
"BUCKET_URI = \"gs://your-bucket-name-unique\" # @param {type:\"string\"}\n",
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}" ]
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
@@ -308,7 +309,8 @@
"IMAGE_URI = \"us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-12:latest\"\n",
"\n",
"# Copy Test Models to the Bucket\n",
"! gcloud storage cp --recursive \"gs://cloud-samples-data/vertex-ai/prediction/test-models-requests/tensorflow/*\" {ARTIFACT_URI}\n", "\n",
"! gcloud storage cp --recursive \"gs://cloud-samples-data/vertex-ai/prediction/test-models-requests/tensorflow/*\" {ARTIFACT_URI}\n",
"\n",
"model = aiplatform.Model.upload(\n",
" display_name=DISPLAY_NAME,\n",
" artifact_uri=ARTIFACT_URI,\n",
@@ -784,7 +786,8 @@
},
"outputs": [],
"source": [
"! gcloud storage rm --recursive {BUCKET_URI}" ]
"! gcloud storage rm --recursive {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
@@ -347,7 +347,8 @@
},
"outputs": [],
"source": [
"! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}" ]
"! gcloud storage buckets create --location {LOCATION} --project {PROJECT_ID} {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
@@ -719,8 +720,10 @@
},
"outputs": [],
"source": [
"! 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" ]
"! 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",
@@ -837,7 +840,8 @@
"# Delete GCS bucket.\n",
"delete_bucket = False\n",
"if delete_bucket:\n",
" ! gcloud storage rm --recursive $BUCKET_URI" ]
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
"metadata": {
@@ -350,7 +350,8 @@
},
"outputs": [],
"source": [
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}" ]
"! gcloud storage buckets create --location={LOCATION} --project={PROJECT_ID} {BUCKET_URI}"
]
},
{
"cell_type": "markdown",
@@ -845,7 +846,8 @@
"# Delete GCS bucket.\n",
"delete_bucket = False # set True for deletion\n",
"if delete_bucket:\n",
" ! gcloud storage rm --recursive {BUCKET_URI}" ]
" ! gcloud storage rm --recursive {BUCKET_URI}"
]
}
],
"metadata": {
@@ -282,7 +282,8 @@
},
"outputs": [],
"source": [
"! gcloud storage buckets create --location=$LOCATION --project=$PROJECT_ID $BUCKET_URI" ]
"! gcloud storage buckets create --location=$LOCATION --project=$PROJECT_ID $BUCKET_URI"
]
},
{
"cell_type": "markdown",
@@ -839,7 +840,8 @@
"\n",
"delete_bucket = False\n",
"if delete_bucket:\n",
" ! gcloud storage rm --recursive $BUCKET_URI" ]
" ! gcloud storage rm --recursive $BUCKET_URI"
]
}
],
"metadata": {