shahar1 commented on code in PR #68665:
URL: https://github.com/apache/airflow/pull/68665#discussion_r3556554528
##########
providers/google/tests/system/google/cloud/gen_ai/example_gen_ai_generative_model_tuning.py:
##########
@@ -118,16 +126,21 @@ def _get_actual_model(key) -> str:
) as dag:
@task
- def get_gemini_api_key():
- return get_secret(GEMINI_API_KEY)
-
- get_gemini_api_key_task = get_gemini_api_key()
-
- @task
- def get_actual_model(key):
- return _get_actual_model(key)
-
- get_actual_model_task = get_actual_model(get_gemini_api_key_task)
+ def get_actual_model():
+ latest_available_model = max(
+ filter(lambda model: model["sft_availability"] ==
"GenerallyAvailable", STABLE_SFT_MODELS),
+ key=lambda model: model["guaranteed_until"],
+ )
+
+ if datetime.now(timezone.utc).date() >
latest_available_model["guaranteed_until"]:
+ msg = (
+ f"The model: {latest_available_model} guarantee date has
expired. "
+ f"Please check and update the stable SFT models list according
to the official documentation: "
+
f"https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/tuning/supervised-tuning#limitations"
+ )
+ raise ValueError(msg)
+
+ return latest_available_model
Review Comment:
Instead of returning the entire dictionary, maybe just return
`latest_available_model["model_id"]`? (should simplify later references)
##########
providers/google/tests/system/google/cloud/gen_ai/example_gen_ai_generative_model_tuning.py:
##########
@@ -118,16 +126,21 @@ def _get_actual_model(key) -> str:
) as dag:
@task
- def get_gemini_api_key():
- return get_secret(GEMINI_API_KEY)
-
- get_gemini_api_key_task = get_gemini_api_key()
-
- @task
- def get_actual_model(key):
- return _get_actual_model(key)
-
- get_actual_model_task = get_actual_model(get_gemini_api_key_task)
+ def get_actual_model():
+ latest_available_model = max(
+ filter(lambda model: model["sft_availability"] ==
"GenerallyAvailable", STABLE_SFT_MODELS),
+ key=lambda model: model["guaranteed_until"],
+ )
Review Comment:
All three GA entries share `guaranteed_until=date(2026, 10, 16)`, so max()
tie-breaks to the first listed: gemini-2.5-pro, the most expensive model to
fine-tune. The old logic deliberately preferred flash models. If system-test
run cost matters, list flash first or filter to flash.
##########
providers/google/tests/system/google/cloud/gen_ai/example_gen_ai_generative_model_tuning.py:
##########
@@ -41,60 +39,70 @@
except ImportError:
# Compatibility for Airflow < 3.1
from airflow.utils.trigger_rule import TriggerRule # type:
ignore[no-redef,attr-defined]
+try:
+ from airflow.sdk import timezone
+except ImportError:
+ # Airflow 2.x fallback path
+ from airflow.utils import timezone # type: ignore[no-redef,attr-defined]
Review Comment:
nit: The new airflow.sdk/airflow.utils timezone compat try/except is
unnecessary: stdlib from datetime import timezone provides timezone.utc for
exactly this use, dropping 5 lines and a type-ignore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]