From 2cea9b2b464b5ae93b4c2c08ab23edcbc27648ee Mon Sep 17 00:00:00 2001 From: manish0820 Date: Wed, 26 Aug 2026 13:54:44 +0530 Subject: [PATCH] Fix issues 8253 12325 11942 11566 12580 14117 --- AUTHORING_GUIDE.md | 4 +- cloud-sql/mysql/sqlalchemy/connect_tcp.py | 3 -- cloud-sql/postgres/sqlalchemy/connect_tcp.py | 3 -- .../sql-server/sqlalchemy/connect_tcp.py | 3 -- composer/tools/composer_dags.py | 26 ++++++++----- eventarc/storage_handler/Dockerfile | 38 +++++++++++++++++++ eventarc/storage_handler/Procfile | 1 - .../chat_completions_credentials_refresher.py | 2 +- ...chat_completions_function_calling_basic.py | 2 +- ...hat_completions_function_calling_config.py | 2 +- .../chat_completions_non_streaming_image.py | 2 +- .../chat_completions_non_streaming_text.py | 2 +- .../chat_completions_streaming_image.py | 2 +- .../chat_completions_streaming_text.py | 2 +- .../chat_function_calling_basic.py | 2 +- .../chat_function_calling_config.py | 2 +- generative_ai/prompts/prompt_create.py | 2 +- generative_ai/prompts/prompt_delete.py | 2 +- generative_ai/prompts/prompt_get.py | 2 +- generative_ai/prompts/prompt_list_version.py | 2 +- .../prompts/prompt_restore_version.py | 2 +- generative_ai/prompts/prompt_template.py | 2 +- .../test_resources/sample_configuration.json | 2 +- logging/cloud-client/requirements.txt | 1 + 24 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 eventarc/storage_handler/Dockerfile delete mode 100644 eventarc/storage_handler/Procfile create mode 100644 logging/cloud-client/requirements.txt diff --git a/AUTHORING_GUIDE.md b/AUTHORING_GUIDE.md index 6ae8d0a0372..1f451409eac 100644 --- a/AUTHORING_GUIDE.md +++ b/AUTHORING_GUIDE.md @@ -27,8 +27,8 @@ as covered below. We recommend referencing the following samples and sample tests: -* [Storage client - samples](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/storage/cloud-client) +* [BigQuery client + samples](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/bigquery/cloud-client) ### Where should I put my samples? diff --git a/cloud-sql/mysql/sqlalchemy/connect_tcp.py b/cloud-sql/mysql/sqlalchemy/connect_tcp.py index cb95d72d156..3f0a5f63342 100644 --- a/cloud-sql/mysql/sqlalchemy/connect_tcp.py +++ b/cloud-sql/mysql/sqlalchemy/connect_tcp.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# TODO (https://github.com/GoogleCloudPlatform/python-docs-samples/issues/8253): remove old region tags # [START cloud_sql_mysql_sqlalchemy_connect_tcp] -# [START cloud_sql_mysql_sqlalchemy_sslcerts] # [START cloud_sql_mysql_sqlalchemy_connect_tcp_sslcerts] import os @@ -94,5 +92,4 @@ def connect_tcp_socket() -> sqlalchemy.engine.base.Engine: # [END cloud_sql_mysql_sqlalchemy_connect_tcp_sslcerts] -# [END cloud_sql_mysql_sqlalchemy_sslcerts] # [END cloud_sql_mysql_sqlalchemy_connect_tcp] diff --git a/cloud-sql/postgres/sqlalchemy/connect_tcp.py b/cloud-sql/postgres/sqlalchemy/connect_tcp.py index 739843efe62..be531413b1f 100644 --- a/cloud-sql/postgres/sqlalchemy/connect_tcp.py +++ b/cloud-sql/postgres/sqlalchemy/connect_tcp.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# TODO (https://github.com/GoogleCloudPlatform/python-docs-samples/issues/8253): remove old region tags # [START cloud_sql_postgres_sqlalchemy_connect_tcp] -# [START cloud_sql_postgres_sqlalchemy_sslcerts] # [START cloud_sql_postgres_sqlalchemy_connect_tcp_sslcerts] import os import ssl @@ -98,5 +96,4 @@ def connect_tcp_socket() -> sqlalchemy.engine.base.Engine: # [END cloud_sql_postgres_sqlalchemy_connect_tcp_sslcerts] -# [END cloud_sql_postgres_sqlalchemy_sslcerts] # [END cloud_sql_postgres_sqlalchemy_connect_tcp] diff --git a/cloud-sql/sql-server/sqlalchemy/connect_tcp.py b/cloud-sql/sql-server/sqlalchemy/connect_tcp.py index 4ab469a4f70..06314d1a9a7 100644 --- a/cloud-sql/sql-server/sqlalchemy/connect_tcp.py +++ b/cloud-sql/sql-server/sqlalchemy/connect_tcp.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# TODO (https://github.com/GoogleCloudPlatform/python-docs-samples/issues/8253): remove old region tags # [START cloud_sql_sqlserver_sqlalchemy_connect_tcp] -# [START cloud_sql_sqlserver_sqlalchemy_sslcerts] # [START cloud_sql_sqlserver_sqlalchemy_connect_tcp_sslcerts] import os @@ -100,5 +98,4 @@ def connect_tcp_socket() -> sqlalchemy.engine.base.Engine: # [END cloud_sql_sqlserver_sqlalchemy_connect_tcp_sslcerts] -# [END cloud_sql_sqlserver_sqlalchemy_sslcerts] # [END cloud_sql_sqlserver_sqlalchemy_connect_tcp] diff --git a/composer/tools/composer_dags.py b/composer/tools/composer_dags.py index a5306fa52d5..c480135d97a 100644 --- a/composer/tools/composer_dags.py +++ b/composer/tools/composer_dags.py @@ -32,8 +32,13 @@ class DAG: """Provides necessary utils for Composer DAGs.""" + # The Composer portion of the image version (e.g. "2.9.1" or just "3") and + # the Airflow patch number (e.g. the trailing ".3" in "2.9.3") are both + # optional in some image version strings, such as "composer-3-airflow-2.10" + # or "composer-2.9.1-airflow-2.9". Both are matched as optional groups so + # the regex still matches those versions instead of returning None. COMPOSER_AF_VERSION_RE = re.compile( - "composer-(\d+)(?:\.(\d+)\.(\d+))?.*?-airflow-(\d+)\.(\d+)\.(\d+)" + r"composer-(\d+)(?:\.(\d+)\.(\d+))?.*?-airflow-(\d+)\.(\d+)(?:\.(\d+))?" ) @staticmethod @@ -162,14 +167,17 @@ def main( location=location, sdk_endpoint=sdk_endpoint, ) - versions = DAG.COMPOSER_AF_VERSION_RE.match( - environment_info["config"]["softwareConfig"]["imageVersion"] - ).groups() - logger.info( - "Image version: %s", - environment_info["config"]["softwareConfig"]["imageVersion"], - ) - airflow_version = (int(versions[3]), int(versions[4]), int(versions[5])) + image_version = environment_info["config"]["softwareConfig"]["imageVersion"] + version_match = DAG.COMPOSER_AF_VERSION_RE.match(image_version) + if not version_match: + raise ValueError( + f"Could not parse Airflow version out of image version: {image_version!r}" + ) + versions = version_match.groups() + logger.info("Image version: %s", image_version) + # The Airflow patch number is optional in the image version string, so it + # may be None; default it to 0 in that case (e.g. "2.9" -> (2, 9, 0)). + airflow_version = (int(versions[3]), int(versions[4]), int(versions[5] or 0)) list_of_dags = DAG.get_list_of_dags( project_name=project_name, environment=environment, diff --git a/eventarc/storage_handler/Dockerfile b/eventarc/storage_handler/Dockerfile new file mode 100644 index 00000000000..e4f1889dc5b --- /dev/null +++ b/eventarc/storage_handler/Dockerfile @@ -0,0 +1,38 @@ +# Copyright 2020 Google, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use the official Python image. +# https://hub.docker.com/_/python +FROM python:3.14-slim + +# Allow statements and log messages to immediately appear in the Cloud Run logs +ENV PYTHONUNBUFFERED True + +# Copy application dependency manifests to the container image. +# Copying this separately prevents re-running pip install on every code change. +COPY requirements.txt ./ + +# Install production dependencies. +RUN pip install -r requirements.txt + +# Copy local code to the container image. +ENV APP_HOME /app +WORKDIR $APP_HOME +COPY . ./ + +# Run the web service on container startup. +# Use gunicorn webserver with one worker process and 8 threads. +# For environments with multiple CPU cores, increase the number of workers +# to be equal to the cores available. +CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app diff --git a/eventarc/storage_handler/Procfile b/eventarc/storage_handler/Procfile deleted file mode 100644 index 1ba043977de..00000000000 --- a/eventarc/storage_handler/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app \ No newline at end of file diff --git a/generative_ai/chat_completions/chat_completions_credentials_refresher.py b/generative_ai/chat_completions/chat_completions_credentials_refresher.py index a60d2391a1c..0c4a7b72323 100644 --- a/generative_ai/chat_completions/chat_completions_credentials_refresher.py +++ b/generative_ai/chat_completions/chat_completions_credentials_refresher.py @@ -55,7 +55,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object: ) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=[{"role": "user", "content": "Why is the sky blue?"}], ) diff --git a/generative_ai/chat_completions/chat_completions_function_calling_basic.py b/generative_ai/chat_completions/chat_completions_function_calling_basic.py index d64c9aa1494..38f85cb68e7 100644 --- a/generative_ai/chat_completions/chat_completions_function_calling_basic.py +++ b/generative_ai/chat_completions/chat_completions_function_calling_basic.py @@ -68,7 +68,7 @@ def generate_text() -> object: messages.append({"role": "user", "content": "What is the weather in Boston?"}) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=messages, tools=tools, ) diff --git a/generative_ai/chat_completions/chat_completions_function_calling_config.py b/generative_ai/chat_completions/chat_completions_function_calling_config.py index 80b00ac993d..b38c801ba85 100644 --- a/generative_ai/chat_completions/chat_completions_function_calling_config.py +++ b/generative_ai/chat_completions/chat_completions_function_calling_config.py @@ -68,7 +68,7 @@ def generate_text() -> object: messages.append({"role": "user", "content": "What is the weather in Boston, MA?"}) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=messages, tools=tools, tool_choice="auto", diff --git a/generative_ai/chat_completions/chat_completions_non_streaming_image.py b/generative_ai/chat_completions/chat_completions_non_streaming_image.py index 2bfe8cf96fa..c2fe9b44c0a 100644 --- a/generative_ai/chat_completions/chat_completions_non_streaming_image.py +++ b/generative_ai/chat_completions/chat_completions_non_streaming_image.py @@ -36,7 +36,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object: ) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=[ { "role": "user", diff --git a/generative_ai/chat_completions/chat_completions_non_streaming_text.py b/generative_ai/chat_completions/chat_completions_non_streaming_text.py index 20de139d62c..5839b89a4e0 100644 --- a/generative_ai/chat_completions/chat_completions_non_streaming_text.py +++ b/generative_ai/chat_completions/chat_completions_non_streaming_text.py @@ -35,7 +35,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object: ) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=[{"role": "user", "content": "Why is the sky blue?"}], ) diff --git a/generative_ai/chat_completions/chat_completions_streaming_image.py b/generative_ai/chat_completions/chat_completions_streaming_image.py index 05630ef15fe..df416f046c8 100644 --- a/generative_ai/chat_completions/chat_completions_streaming_image.py +++ b/generative_ai/chat_completions/chat_completions_streaming_image.py @@ -35,7 +35,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object: ) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=[ { "role": "user", diff --git a/generative_ai/chat_completions/chat_completions_streaming_text.py b/generative_ai/chat_completions/chat_completions_streaming_text.py index 42e98809ad9..79f52f4c610 100644 --- a/generative_ai/chat_completions/chat_completions_streaming_text.py +++ b/generative_ai/chat_completions/chat_completions_streaming_text.py @@ -35,7 +35,7 @@ def generate_text(project_id: str, location: str = "us-central1") -> object: ) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=[{"role": "user", "content": "Why is the sky blue?"}], stream=True, ) diff --git a/generative_ai/function_calling/chat_function_calling_basic.py b/generative_ai/function_calling/chat_function_calling_basic.py index 9731a41582f..23a30c82975 100644 --- a/generative_ai/function_calling/chat_function_calling_basic.py +++ b/generative_ai/function_calling/chat_function_calling_basic.py @@ -71,7 +71,7 @@ def generate_text() -> object: messages.append({"role": "user", "content": "What is the weather in Boston?"}) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=messages, tools=tools, ) diff --git a/generative_ai/function_calling/chat_function_calling_config.py b/generative_ai/function_calling/chat_function_calling_config.py index 720d72db70e..6caac2e99b8 100644 --- a/generative_ai/function_calling/chat_function_calling_config.py +++ b/generative_ai/function_calling/chat_function_calling_config.py @@ -71,7 +71,7 @@ def generate_text() -> object: messages.append({"role": "user", "content": "What is the weather in Boston, MA?"}) response = client.chat.completions.create( - model="google/gemini-2.0-flash-001", + model="google/gemini-2.5-flash", messages=messages, tools=tools, tool_choice="auto", diff --git a/generative_ai/prompts/prompt_create.py b/generative_ai/prompts/prompt_create.py index a18fbd986f8..bc221d7907f 100644 --- a/generative_ai/prompts/prompt_create.py +++ b/generative_ai/prompts/prompt_create.py @@ -39,7 +39,7 @@ def prompt_create() -> Prompt: {"movie1": "The Lion King", "movie2": "Frozen"}, {"movie1": "Inception", "movie2": "Interstellar"}, ], - model_name="gemini-2.0-flash-001", + model_name="gemini-2.5-flash", system_instruction="You are a movie critic. Answer in a short sentence.", # generation_config=GenerationConfig, # Optional, # safety_settings=SafetySetting, # Optional, diff --git a/generative_ai/prompts/prompt_delete.py b/generative_ai/prompts/prompt_delete.py index 80c2f6940f1..ec44bb41637 100644 --- a/generative_ai/prompts/prompt_delete.py +++ b/generative_ai/prompts/prompt_delete.py @@ -35,7 +35,7 @@ def delete_prompt() -> None: {"movie1": "The Lion King", "movie2": "Frozen"}, {"movie1": "Inception", "movie2": "Interstellar"}, ], - model_name="gemini-2.0-flash-001", + model_name="gemini-2.5-flash", system_instruction="You are a movie critic. Answer in a short sentence.", ) diff --git a/generative_ai/prompts/prompt_get.py b/generative_ai/prompts/prompt_get.py index 59cf9c0bbc7..6d146a2f3a3 100644 --- a/generative_ai/prompts/prompt_get.py +++ b/generative_ai/prompts/prompt_get.py @@ -33,7 +33,7 @@ def get_prompt() -> Prompt: prompt = Prompt( prompt_name="meteorologist", prompt_data="How should I dress for weather in August?", - model_name="gemini-2.0-flash-001", + model_name="gemini-2.5-flash", system_instruction="You are a meteorologist. Answer in a short sentence.", ) diff --git a/generative_ai/prompts/prompt_list_version.py b/generative_ai/prompts/prompt_list_version.py index 1fc200673fc..95b7f6e7429 100644 --- a/generative_ai/prompts/prompt_list_version.py +++ b/generative_ai/prompts/prompt_list_version.py @@ -32,7 +32,7 @@ def list_prompt_version() -> list: prompt = Prompt( prompt_name="zoologist", prompt_data="Which animal is the fastest on earth?", - model_name="gemini-2.0-flash-001", + model_name="gemini-2.5-flash", system_instruction="You are a zoologist. Answer in a short sentence.", ) # Save Prompt to online resource. diff --git a/generative_ai/prompts/prompt_restore_version.py b/generative_ai/prompts/prompt_restore_version.py index f2496dfccb8..343e64e2a43 100644 --- a/generative_ai/prompts/prompt_restore_version.py +++ b/generative_ai/prompts/prompt_restore_version.py @@ -32,7 +32,7 @@ # prompt = Prompt( # prompt_name="zoologist", # prompt_data="Which animal is the fastest on earth?", -# model_name="gemini-2.0-flash-001", +# model_name="gemini-2.5-flash", # system_instruction="You are a zoologist. Answer in a short sentence.", # ) # # Save Prompt to online resource. diff --git a/generative_ai/prompts/prompt_template.py b/generative_ai/prompts/prompt_template.py index 7517c7bb666..21640c31915 100644 --- a/generative_ai/prompts/prompt_template.py +++ b/generative_ai/prompts/prompt_template.py @@ -38,7 +38,7 @@ def prompt_template_example() -> list[GenerationResponse]: # define prompt template prompt = Prompt( prompt_data="Do {animal} {activity}?", - model_name="gemini-2.0-flash-001", + model_name="gemini-2.5-flash", variables=variables, system_instruction="You are a helpful zoologist" # generation_config=generation_config, # Optional diff --git a/generative_ai/prompts/test_resources/sample_configuration.json b/generative_ai/prompts/test_resources/sample_configuration.json index 6b43b41f563..a11263b3162 100644 --- a/generative_ai/prompts/test_resources/sample_configuration.json +++ b/generative_ai/prompts/test_resources/sample_configuration.json @@ -2,7 +2,7 @@ "project": "$PROJECT_ID", "system_instruction_path": "gs://$CLOUD_BUCKET/sample_system_instruction.txt", "prompt_template_path": "gs://$CLOUD_BUCKET/sample_prompt_template.txt", -"target_model": "gemini-2.0-flash-001", +"target_model": "gemini-2.5-flash", "eval_metrics_types": ["safety"], "optimization_mode": "instruction", "input_data_path": "gs://$CLOUD_BUCKET/sample_prompts.jsonl", diff --git a/logging/cloud-client/requirements.txt b/logging/cloud-client/requirements.txt new file mode 100644 index 00000000000..e470934013e --- /dev/null +++ b/logging/cloud-client/requirements.txt @@ -0,0 +1 @@ +google-cloud-logging>=3.4.0