Bug Bash 2026-08: Make supervised tuning colab executable - #78
Conversation
| "BIGQUERY_TABLE_ID = 'cropped_observations_all' # @param {type:\"string\"}\n", | ||
| "QUERY_LIMIT = 10 # @param {type:\"integer\"}\n", | ||
| "ASSET_TYPE = \"ASSET_CLASS_UTILITY_POLE\" # @param {type:\"string\"}\n", | ||
| "MODEL = \"gemini-2.5-flash\" # @param {type:\"string\"}\n" |
There was a problem hiding this comment.
gemini-2.5-flash will be deprecated in October.
Can this be upgraded?
There was a problem hiding this comment.
FYI: I was able to get it to load with gemini-3.5-flash, but not gemini-3.6-flash
| "\n", | ||
| "# BigQuery Configuration\n", | ||
| "BIGQUERY_DATASET_ID = '' # @param {type:\"string\"}\n", | ||
| "BIGQUERY_TABLE_ID = 'cropped_observations_all' # @param {type:\"string\"}\n", |
There was a problem hiding this comment.
Does this notebook require data from all available historical snapshots?
Or is it sufficient to use cropped_observations_latest?
| "import os\n", | ||
| "\n", | ||
| "# 1. Define the base path and the training file name\n", | ||
| "BASE_URL = \"https://raw.githubusercontent.com/googlemaps-samples/insights-samples/feat/street-view-samples/street_view_insights/cropped/notebooks/Supervised%20fine%20tuning/data/\"\n", |
There was a problem hiding this comment.
Please construct this URL using parameters with these default values:
"GITHUB_REPOSITORY_NAME = 'googlemaps-samples/insights-samples' # @param {type:\"string\"}\n",
"GITHUB_BRANCH_NAME = 'main' # @param {type:\"string\"}\n"
See here for a comparative example.
This will allow you to test from your branch (with variable overrides), but then ensure it still works after your code is merged.
| "outputs": [], | ||
| "source": [ | ||
| "# Install the necessary library\n", | ||
| "!pip install --upgrade --user --quiet google-genai google-cloud-aiplatform\n", |
There was a problem hiding this comment.
P2: This package installation step should move to a separate cell near the top of the file.
| "id": "1-2-3-4-5" | ||
| }, | ||
| "source": [ | ||
| "## Setup\n", |
There was a problem hiding this comment.
Please move this to earlier in the notebook. The user should do these tasks before starting anything.
| "# Provide a bucket name\n", | ||
| "BUCKET_NAME = \"\" # @param {type:\"string\"}\n", | ||
| "BUCKET_URI = f\"gs://{BUCKET_NAME}\"\n", | ||
| "# LOCATION = \"us\"\n", |
There was a problem hiding this comment.
- Uncomment
LOCATIONon line 112. - Change
--location {REGION}->--location {LOCATION}on line 115.
| " AND gcs_uri IS NOT NULL\n", | ||
| " GROUP BY\n", | ||
| " asset_id\n", | ||
| " LIMIT 100\n", |
There was a problem hiding this comment.
LIMIT 100 -> LIMIT {QUERY_LIMIT}
| "BIGQUERY_TABLE_ID = 'cropped_observations_all' # @param {type:\"string\"}\n", | ||
| "QUERY_LIMIT = 10 # @param {type:\"integer\"}\n", | ||
| "ASSET_TYPE = \"ASSET_CLASS_UTILITY_POLE\" # @param {type:\"string\"}\n", | ||
| "MODEL = \"gemini-2.5-flash\" # @param {type:\"string\"}\n" |
There was a problem hiding this comment.
FYI: I was able to get it to load with gemini-3.5-flash, but not gemini-3.6-flash
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Provide a bucket name\n", |
There was a problem hiding this comment.
I got the following error when running with a bucket on my playground project:
400 FAILED_PRECONDITION. {'error': {'code': 400, 'message': 'Service account `[service-631865656917@gcp-sa-vertex-tune.iam.gserviceaccount.com](mailto:service-631865656917@gcp-sa-vertex-tune.iam.gserviceaccount.com)` does not have `[storage.objects.get]` IAM permission(s) to the file "gs://bijanv-geosptial-demos/data/acquity_detector_negative_examples_v2_clean.jsonl". Please either copy the files to the Google Cloud Storage bucket owned by your project, or grant the required IAM permission(s) to the service account.', 'status': 'FAILED_PRECONDITION'}}
Please add a Markdown cell above this indicating that the bucket in use my provide the above service agent (exclude the project ID) with roles/storage.objectViewer access
bijanvakili
left a comment
There was a problem hiding this comment.
This is working well and I have only a few requests. If you get stuck, I got it working here and the tuning was completed in under an error with gemini 3.5
Please resolve the merge conflicts.
| "outputs": [], | ||
| "source": [ | ||
| "from google.cloud import bigquery\n", | ||
| "import vertexai\n", |
There was a problem hiding this comment.
I believe this can be removed since the vertexai module is never used directly.
| "source": [ | ||
| "from google.cloud import bigquery\n", | ||
| "import vertexai\n", | ||
| "from vertexai.generative_models import GenerativeModel, Part\n", |
There was a problem hiding this comment.
Recommend changing to from google.genai.types import Part
GenerativeModel is now deprecated in favor of calling client.models.generate_content (which your new code is now doing)
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# ------------ 2. Initialize Vertex AI and Load Model ------------\n", |
There was a problem hiding this comment.
You can now remove these commented out lines.
| "else:\n", | ||
| " print(f\"Tuning job failed with state: {tuning_job.state.name}\")\n", | ||
| " if hasattr(tuning_job, 'error') and tuning_job.error:\n", | ||
| " print(f\"Error: {tuning_job.error}\")\n", |
There was a problem hiding this comment.
Recommend just raising an exception and removing the fallback logic.
It doesn't make sense for this notebook to continue if we can't use the tuned model.
| "from google.genai import types\n", | ||
| "\n", | ||
| "# Initialize the new Gen AI Client\n", | ||
| "client = genai.Client(vertexai=True, project=PROJECT_ID, location=REGION)" |
There was a problem hiding this comment.
The PROJECT_ID and REGION needs to match the ones contained in the MODEL_ENDPOINT
I would suggest parsing these values out and passing them to this genai.Client() constructor. Otherwise, it can result in endpoint not found errors.
| " print(f\" -> Result: {result_text}\")\n", | ||
| " analysis_results.append(result_text)\n", | ||
| "\n", | ||
| " except Exception as e:\n", |
There was a problem hiding this comment.
I recommend removing this except clause and just letting the notebook fail.
This avoids the user accidentally moving forward in the notebook when this critical step has failed.
Summary of changes:
/Users/...) withwgetto dynamically download the training dataset directly from the GitHub repository.https://URLs from the training dataset, preventing Vertex AI fine-tuning jobs from failing.SELECTquery to use configuration variables instead of the hardcodedsarthaks-labproject andutility_pole_evaluationstable.asset_typeinstead oftype, and aggregating the singulargcs_uricolumn).vertexaiSDK to the newgoogle-genaiSDK.