Skip to content

Commit 2810548

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
chore: make final updates to include Ray v2.42.0 support on SDK, make 2.42.0 the default Ray version over 2.33.0, allow python 3.11 with v2.42.0
PiperOrigin-RevId: 740062827
1 parent d6f99cb commit 2810548

File tree

15 files changed

+176
-77
lines changed

15 files changed

+176
-77
lines changed

.kokoro/presubmit/unit_ray_2-33.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Run unit tests for Ray 2.33.0 on Python 3.10
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "unit_ray(ray='2.33.0')"
6+
value: "unit_ray-3.10(ray='2.33.0')"
77
}
88

99
# Run unit tests in parallel, splitting up by file

.kokoro/presubmit/unit_ray_2-42.cfg

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Run unit tests for Ray 2.42.0 on Python 3.10
4+
env_vars: {
5+
key: "NOX_SESSION"
6+
value: "unit_ray-3.10(ray='2.42.0')"
7+
}
8+
9+
# Run unit tests in parallel, splitting up by file
10+
env_vars: {
11+
key: "PYTEST_ADDOPTS"
12+
value: "-n=auto --dist=loadscope"
13+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Run unit tests for Ray 2.42.0 on Python 3.11
4+
env_vars: {
5+
key: "NOX_SESSION"
6+
value: "unit_ray-3.11(ray='2.42.0')"
7+
}
8+
9+
# Run unit tests in parallel, splitting up by file
10+
env_vars: {
11+
key: "PYTEST_ADDOPTS"
12+
value: "-n=auto --dist=loadscope"
13+
}

.kokoro/presubmit/unit_ray_2-9.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Run unit tests for Ray 2.9.3 on Python 3.10
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "unit_ray(ray='2.9.3')"
6+
value: "unit_ray-3.10(ray='2.9.3')"
77
}
88

99
# Run unit tests in parallel, splitting up by file

google/cloud/aiplatform/preview/vertex_ray/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# -*- coding: utf-8 -*-
44

5-
# Copyright 2022 Google LLC
5+
# Copyright 2025 Google LLC
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
88
# you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
1919
import sys
2020

2121
from google.cloud.aiplatform.vertex_ray.bigquery_datasource import (
22-
BigQueryDatasource,
22+
_BigQueryDatasource,
2323
)
2424
from google.cloud.aiplatform.vertex_ray.client_builder import (
2525
VertexRayClientBuilder as ClientBuilder,
@@ -44,13 +44,13 @@
4444
get_job_submission_client_cluster_info,
4545
)
4646

47-
if sys.version_info[1] != 10:
47+
if sys.version_info[1] not in (10, 11):
4848
print(
49-
"[Ray on Vertex]: The client environment with Python version 3.10 is required."
49+
"[Ray on Vertex]: The client environment with Python version 3.10 or 3.11 is required."
5050
)
5151

5252
__all__ = (
53-
"BigQueryDatasource",
53+
"_BigQueryDatasource",
5454
"data",
5555
"ClientBuilder",
5656
"get_job_submission_client_cluster_info",

google/cloud/aiplatform/vertex_ray/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# -*- coding: utf-8 -*-
44

5-
# Copyright 2022 Google LLC
5+
# Copyright 2025 Google LLC
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
88
# you may not use this file except in compliance with the License.
@@ -46,9 +46,9 @@
4646
get_job_submission_client_cluster_info,
4747
)
4848

49-
if sys.version_info[1] != 10:
49+
if sys.version_info[1] not in (10, 11):
5050
print(
51-
"[Ray on Vertex]: The client environment with Python version 3.10 is required."
51+
"[Ray on Vertex]: The client environment with Python version 3.10 or 3.11 is required."
5252
)
5353

5454
__all__ = (

google/cloud/aiplatform/vertex_ray/cluster_init.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
def create_ray_cluster(
5555
head_node_type: Optional[resources.Resources] = resources.Resources(),
5656
python_version: Optional[str] = "3.10",
57-
ray_version: Optional[str] = "2.33",
57+
ray_version: Optional[str] = "2.42",
5858
network: Optional[str] = None,
5959
service_account: Optional[str] = None,
6060
cluster_name: Optional[str] = None,
@@ -76,17 +76,17 @@ def create_ray_cluster(
7676
head_node_type = Resources(
7777
machine_type="n1-standard-8",
7878
node_count=1,
79-
accelerator_type="NVIDIA_TESLA_K80",
79+
accelerator_type="NVIDIA_TESLA_T4",
8080
accelerator_count=1,
81-
custom_image="us-docker.pkg.dev/my-project/ray-cpu-image.2.9:latest", # Optional
81+
custom_image="us-docker.pkg.dev/my-project/ray-cpu-image.2.33:latest", # Optional
8282
)
8383
8484
worker_node_types = [Resources(
8585
machine_type="n1-standard-8",
8686
node_count=2,
87-
accelerator_type="NVIDIA_TESLA_K80",
87+
accelerator_type="NVIDIA_TESLA_T4",
8888
accelerator_count=1,
89-
custom_image="us-docker.pkg.dev/my-project/ray-gpu-image.2.9:latest", # Optional
89+
custom_image="us-docker.pkg.dev/my-project/ray-gpu-image.2.33:latest", # Optional
9090
)]
9191
9292
cluster_resource_name = vertex_ray.create_ray_cluster(
@@ -95,7 +95,7 @@ def create_ray_cluster(
9595
service_account="[email protected]", # Optional
9696
cluster_name="my-cluster-name", # Optional
9797
worker_node_types=worker_node_types,
98-
ray_version="2.9",
98+
ray_version="2.33",
9999
)
100100
101101
After a ray cluster is set up, you can call
@@ -109,7 +109,7 @@ def create_ray_cluster(
109109
head_node_type: The head node resource. Resources.node_count must be 1.
110110
If not set, default value of Resources() class will be used.
111111
python_version: Python version for the ray cluster.
112-
ray_version: Ray version for the ray cluster. Default is 2.33.0.
112+
ray_version: Ray version for the ray cluster. Default is 2.42.0.
113113
network: Virtual private cloud (VPC) network. For Ray Client, VPC
114114
peering is required to connect to the Ray Cluster managed in the
115115
Vertex API service. For Ray Job API, VPC network is not required
@@ -162,7 +162,7 @@ def create_ray_cluster(
162162
local_ray_verion = _validation_utils.get_local_ray_version()
163163
if ray_version != local_ray_verion:
164164
if custom_images is None and head_node_type.custom_image is None:
165-
install_ray_version = "2.33.0"
165+
install_ray_version = "2.42.0"
166166
logging.info(
167167
"[Ray on Vertex]: Local runtime has Ray version %s"
168168
", but the requested cluster runtime has %s. Please "

google/cloud/aiplatform/vertex_ray/predict/sklearn/register.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@
4545
if TYPE_CHECKING:
4646
import sklearn
4747

48-
except ModuleNotFoundError as mnfe:
49-
raise ModuleNotFoundError("Sklearn isn't installed.") from mnfe
48+
except ImportError as ie:
49+
if ray.__version__ < "2.42.0":
50+
raise ModuleNotFoundError("Sklearn isn't installed.") from ie
51+
else:
52+
sklearn = None
5053

5154

5255
def register_sklearn(
53-
checkpoint: ray_sklearn.SklearnCheckpoint,
56+
checkpoint: "ray_sklearn.SklearnCheckpoint",
5457
artifact_uri: Optional[str] = None,
5558
display_name: Optional[str] = None,
5659
**kwargs,
@@ -120,7 +123,7 @@ def register_sklearn(
120123

121124

122125
def _get_estimator_from(
123-
checkpoint: ray_sklearn.SklearnCheckpoint,
126+
checkpoint: "ray_sklearn.SklearnCheckpoint",
124127
) -> "sklearn.base.BaseEstimator":
125128
"""Converts a SklearnCheckpoint to sklearn estimator.
126129

google/cloud/aiplatform/vertex_ray/util/_validation_utils.py

+27-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
# Copyright 2023 Google LLC
3+
# Copyright 2025 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -28,7 +28,12 @@
2828
SUPPORTED_RAY_VERSIONS = immutabledict(
2929
{"2.9": "2.9.3", "2.33": "2.33.0", "2.42": "2.42.0"}
3030
)
31-
SUPPORTED_PY_VERSION = ["3.10"]
31+
SUPPORTED_RAY_VERSIONS_FROM_PYTHON_VERSIONS = immutabledict(
32+
{
33+
"3.10": ("2.9", "2.33", "2.42"),
34+
"3.11": ("2.42"),
35+
}
36+
)
3237
_V2_4_WARNING_MESSAGE = (
3338
"After google-cloud-aiplatform>1.53.0, using Ray version = 2.4 will result"
3439
" in an error. Please use Ray version = 2.33.0 or 2.42.0 (default) instead."
@@ -102,18 +107,30 @@ def get_image_uri(ray_version, python_version, enable_cuda):
102107
list(SUPPORTED_RAY_VERSIONS.values())[1],
103108
)
104109
)
105-
if python_version not in SUPPORTED_PY_VERSION:
106-
raise ValueError("[Ray on Vertex AI]: The supported Python version is 3.10.")
110+
if python_version not in SUPPORTED_RAY_VERSIONS_FROM_PYTHON_VERSIONS:
111+
raise ValueError(
112+
"[Ray on Vertex AI]: The supported Python versions are 3.10 or 3.11."
113+
)
114+
115+
if ray_version not in SUPPORTED_RAY_VERSIONS_FROM_PYTHON_VERSIONS[python_version]:
116+
raise ValueError(
117+
"[Ray on Vertex AI]: The supported Ray version(s) for Python version %s: %s."
118+
% (
119+
python_version,
120+
SUPPORTED_RAY_VERSIONS_FROM_PYTHON_VERSIONS[python_version],
121+
)
122+
)
107123

108124
location = initializer.global_config.location
109125
region = location.split("-")[0]
110126
if region not in _AVAILABLE_REGIONS:
111127
region = _DEFAULT_REGION
112128
ray_version = ray_version.replace(".", "-")
129+
python_version = python_version.replace(".", "")
113130
if enable_cuda:
114-
return f"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.{ray_version}.py310:latest"
131+
return f"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.{ray_version}.py{python_version}:latest"
115132
else:
116-
return f"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.{ray_version}.py310:latest"
133+
return f"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.{ray_version}.py{python_version}:latest"
117134

118135

119136
def get_versions_from_image_uri(image_uri):
@@ -122,7 +139,10 @@ def get_versions_from_image_uri(image_uri):
122139
image_label = image_uri.split("/")[-1].split(":")[0]
123140
py_version = image_label[-3] + "." + image_label[-2:]
124141
ray_version = image_label.split(".")[1].replace("-", ".")
125-
if ray_version in SUPPORTED_RAY_VERSIONS and py_version in SUPPORTED_PY_VERSION:
142+
if (
143+
py_version in SUPPORTED_RAY_VERSIONS_FROM_PYTHON_VERSIONS
144+
and ray_version in SUPPORTED_RAY_VERSIONS_FROM_PYTHON_VERSIONS[py_version]
145+
):
126146
return py_version, ray_version
127147
else:
128148
# May not parse custom image and get the versions correctly

google/cloud/aiplatform/vertex_ray/util/resources.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,22 @@ class Resources:
6969
class NodeImages:
7070
"""Custom images for a ray cluster.
7171
72-
We currently support Ray v2.9 and v2.33 and python v3.10.
72+
We currently support Ray v2.9, v2.33, v2.42 and python v3.10.
73+
We also support python v3.11 for Ray v2.42.
7374
The custom images must be extended from the following base images:
7475
"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.2-9.py310:latest",
7576
"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.2-9.py310:latest",
76-
"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.2-33.py310:latest", or
77-
"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.2-33.py310:latest". In
77+
"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.2-33.py310:latest",
78+
"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.2-33.py310:latest",
79+
"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.2-42.py310:latest",
80+
"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.2-42.py310:latest",
81+
"{region}-docker.pkg.dev/vertex-ai/training/ray-cpu.2-42.py311:latest", or
82+
"{region}-docker.pkg.dev/vertex-ai/training/ray-gpu.2-42.py311:latest". In
7883
order to use custom images, need to specify both head and worker images.
7984
8085
Attributes:
81-
head: image for head node (eg. us-docker.pkg.dev/my-project/ray-cpu.2-9.py310-tf:latest).
82-
worker: image for all worker nodes (eg. us-docker.pkg.dev/my-project/ray-gpu.2-9.py310-tf:latest).
86+
head: image for head node (eg. us-docker.pkg.dev/my-project/ray-cpu.2-33.py310-tf:latest).
87+
worker: image for all worker nodes (eg. us-docker.pkg.dev/my-project/ray-gpu.2-33.py310-tf:latest).
8388
"""
8489

8590
head: str = None
@@ -147,7 +152,7 @@ class Cluster:
147152
the cluster.
148153
state: Describes the cluster state (defined in PersistentResource.State).
149154
python_version: Python version for the ray cluster (e.g. "3.10").
150-
ray_version: Ray version for the ray cluster (e.g. "2.9").
155+
ray_version: Ray version for the ray cluster (e.g. "2.33").
151156
head_node_type: The head node resource. Resources.node_count must be 1.
152157
If not set, by default it is a CPU node with machine_type of n1-standard-8.
153158
worker_node_types: The list of Resources of the worker nodes. Should not

noxfile.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
UNIT_TEST_LANGCHAIN_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
5656
UNIT_TEST_AG2_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
5757
UNIT_TEST_LLAMA_INDEX_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
58+
PYTHON_TO_RAY_VERSIONS = {
59+
"3.10": ["2.9.3", "2.33.0", "2.42.0"],
60+
"3.11": ["2.42.0"],
61+
}
5862
UNIT_TEST_STANDARD_DEPENDENCIES = [
5963
"mock",
6064
"asyncmock",
@@ -255,9 +259,13 @@ def unit_genai_minimal_dependencies(session):
255259
)
256260

257261

258-
@nox.session(python="3.10")
259-
@nox.parametrize("ray", ["2.9.3", "2.33.0"])
262+
@nox.session(python=["3.10", "3.11"])
263+
@nox.parametrize("ray", ["2.9.3", "2.33.0", "2.42.0"])
260264
def unit_ray(session, ray):
265+
# check if ray version is supported
266+
if ray not in PYTHON_TO_RAY_VERSIONS[session.python]:
267+
session.skip(f"Ray version {ray} is not supported for python {session.python}")
268+
261269
# Install all test dependencies, then install this package in-place.
262270

263271
constraints_path = str(CURRENT_DIRECTORY / "testing" / f"constraints-ray-{ray}.txt")
@@ -271,7 +279,7 @@ def unit_ray(session, ray):
271279
session.run(
272280
"py.test",
273281
"--quiet",
274-
f"--junitxml=unit_ray_{ray}_sponge_log.xml",
282+
f"--junitxml=unit_ray_{ray}_py_{session.python}_sponge_log.xml",
275283
"--cov=google",
276284
"--cov-append",
277285
"--cov-config=.coveragerc",

testing/constraints-ray-2.42.0.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ray==2.42.0
2+
# Below constraints are inherited from constraints-3.10.txt
3+
google-api-core
4+
proto-plus==1.22.3
5+
protobuf
6+
mock==4.0.2
7+
google-cloud-storage==2.2.1 # Increased for kfp 2.0 compatibility
8+
packaging==24.1 # Increased to unbreak canonicalize_version error (b/377774673)
9+
grpcio-testing==1.34.0
10+
mlflow==1.30.1 # Pinned to speed up installation
11+
pytest-xdist==3.3.1 # Pinned to unbreak unit tests
12+
IPython # Added to test supernova rich html buttons
13+

0 commit comments

Comments
 (0)