From 4b92a6f634c4937a3aa5fa2c72edca001d4e7907 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sat, 21 Jun 2025 13:06:52 +0200 Subject: [PATCH] Exclude ray in google provider for Python 3.13 Currently we cannot generate `pypi` constraint for Python 3.13, because released google provider has `ray` as dependency and `ray` does not support Pyton 3.13 yet - so we have to exclude `ray` in released provider before we can merge Python 3.13 support. --- providers/google/pyproject.toml | 2 +- .../providers/google/cloud/hooks/vertex_ai/ray.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/providers/google/pyproject.toml b/providers/google/pyproject.toml index 10816668276e7..ba0d3a7f0aa67 100644 --- a/providers/google/pyproject.toml +++ b/providers/google/pyproject.toml @@ -80,7 +80,7 @@ dependencies = [ # Remove the ray dependency as well as google-cloud-bigquery-storage once linked issue is fixed "google-cloud-aiplatform[evaluation,ray]>=1.73.0;python_version < '3.12'", "google-cloud-aiplatform[evaluation]>=1.73.0;python_version >= '3.12'", - "ray[default]>=2.42.0 ; python_version >= '3.12'", + "ray[default]>=2.42.0 ; python_version >= '3.12' and python_version < '3.13'", "google-cloud-bigquery-storage>=2.31.0; python_version >= '3.12'", "google-cloud-alloydb>=0.4.0", "google-cloud-automl>=2.12.0", diff --git a/providers/google/src/airflow/providers/google/cloud/hooks/vertex_ai/ray.py b/providers/google/src/airflow/providers/google/cloud/hooks/vertex_ai/ray.py index 373c72e13bbe4..5aede4a0465e7 100644 --- a/providers/google/src/airflow/providers/google/cloud/hooks/vertex_ai/ray.py +++ b/providers/google/src/airflow/providers/google/cloud/hooks/vertex_ai/ray.py @@ -22,8 +22,17 @@ import dataclasses from typing import Any -import vertex_ray -from google._upb._message import ScalarMapContainer # type: ignore[attr-defined] +from airflow.exceptions import AirflowOptionalProviderFeatureException + +try: + import vertex_ray + from google._upb._message import ScalarMapContainer # type: ignore[attr-defined] +except ImportError: + # Fallback for environments where the upb module is not available. + raise AirflowOptionalProviderFeatureException( + "google._upb._message.ScalarMapContainer is not available. " + "Please install the ray package to use this feature." + ) from google.cloud import aiplatform from google.cloud.aiplatform.vertex_ray.util import resources from google.cloud.aiplatform_v1 import (