Skip to content

Commit bc79040

Browse files
CrowiantAnton Nitochkin
andauthored
Adjust ray operators in google provider. Add ray package as a dependency. (#53182)
Co-authored-by: Anton Nitochkin <nitochkin@google.com>
1 parent 8d18c69 commit bc79040

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

providers/google/docs/operators/cloud/vertex_ai.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ Interacting with Ray on Vertex AI Cluster
756756
To create a Ray cluster you can use
757757
:class:`~airflow.providers.google.cloud.operators.vertex_ai.ray.CreateRayClusterOperator`.
758758

759+
Please note that you need to specify python_version and ray_version in :class:`~airflow.providers.google.cloud.operators.vertex_ai.ray.CreateRayClusterOperator`.
760+
Currently supported versions of ray package in ray cluster are: 2.9.3, 2.33, 2.42.
761+
For more information you can check: https://github.com/googleapis/python-aiplatform/blob/main/setup.py#L101
762+
759763
.. exampleinclude:: /../../google/tests/system/google/cloud/vertex_ai/example_vertex_ai_ray.py
760764
:language: python
761765
:dedent: 4

providers/google/pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ dependencies = [
7777
# google-cloud-aiplatform doesn't install ray for python 3.12 (issue: https://github.com/googleapis/python-aiplatform/issues/5252).
7878
# Temporarily lock in ray 2.42.0 which is compatible with python 3.12 until linked issue is solved.
7979
# Remove the ray dependency as well as google-cloud-bigquery-storage once linked issue is fixed
80-
"google-cloud-aiplatform[evaluation,ray]>=1.73.0;python_version < '3.12'",
81-
"google-cloud-aiplatform[evaluation]>=1.73.0;python_version >= '3.12'",
82-
"ray[default]>=2.42.0 ; python_version >= '3.12' and python_version < '3.13'",
83-
"google-cloud-bigquery-storage>=2.31.0; python_version >= '3.12'",
80+
"google-cloud-aiplatform[evaluation]>=1.73.0",
81+
"ray[default]>=2.42.0 ; python_version < '3.13'",
82+
"google-cloud-bigquery-storage>=2.31.0 ; python_version < '3.13'",
8483
"google-cloud-alloydb>=0.4.0",
8584
"google-cloud-automl>=2.12.0",
8685
"google-cloud-bigquery>=3.24.0",

providers/google/src/airflow/providers/google/cloud/operators/vertex_ai/ray.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from collections.abc import Sequence
2323
from functools import cached_property
24-
from typing import TYPE_CHECKING
24+
from typing import TYPE_CHECKING, Literal
2525

2626
from google.api_core.exceptions import NotFound
2727
from google.cloud.aiplatform.vertex_ray.util import resources
@@ -93,8 +93,10 @@ class CreateRayClusterOperator(RayBaseOperator):
9393
:param location: Required. The ID of the Google Cloud region that the service belongs to.
9494
:param head_node_type: The head node resource. Resources.node_count must be 1. If not set, default
9595
value of Resources() class will be used.
96-
:param python_version: Python version for the ray cluster.
97-
:param ray_version: Ray version for the ray cluster. Default is 2.33.0.
96+
:param python_version: Required. Python version for the ray cluster.
97+
:param ray_version: Required. Ray version for the ray cluster.
98+
Currently only 3 version are available: 2.9.3, 2.33, 2.42. For more information please refer to
99+
https://github.com/googleapis/python-aiplatform/blob/main/setup.py#L101
98100
:param network: Virtual private cloud (VPC) network. For Ray Client, VPC peering is required to
99101
connect to the Ray Cluster managed in the Vertex API service. For Ray Job API, VPC network is not
100102
required because Ray Cluster connection can be accessed through dashboard address.
@@ -136,9 +138,9 @@ class CreateRayClusterOperator(RayBaseOperator):
136138

137139
def __init__(
138140
self,
141+
python_version: str,
142+
ray_version: Literal["2.9.3", "2.33", "2.42"],
139143
head_node_type: resources.Resources = resources.Resources(),
140-
python_version: str = "3.10",
141-
ray_version: str = "2.33",
142144
network: str | None = None,
143145
service_account: str | None = None,
144146
cluster_name: str | None = None,

providers/google/tests/system/google/cloud/vertex_ai/example_vertex_ai_ray.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
DAG_ID = "vertex_ai_ray_operations"
4444
LOCATION = "us-central1"
4545
WORKER_NODE_RESOURCES = resources.Resources(
46+
node_count=1,
47+
)
48+
WORKER_NODE_RESOURCES_NEW = resources.Resources(
4649
node_count=2,
4750
)
4851

@@ -58,6 +61,9 @@
5861
task_id="create_ray_cluster",
5962
project_id=PROJECT_ID,
6063
location=LOCATION,
64+
worker_node_types=[WORKER_NODE_RESOURCES],
65+
python_version="3.10",
66+
ray_version="2.33",
6167
)
6268
# [END how_to_cloud_vertex_ai_create_ray_cluster_operator]
6369

@@ -67,7 +73,7 @@
6773
project_id=PROJECT_ID,
6874
location=LOCATION,
6975
cluster_id="{{ task_instance.xcom_pull(task_ids='create_ray_cluster', key='cluster_id') }}",
70-
worker_node_types=[WORKER_NODE_RESOURCES],
76+
worker_node_types=[WORKER_NODE_RESOURCES_NEW],
7177
)
7278
# [END how_to_cloud_vertex_ai_update_ray_cluster_operator]
7379

0 commit comments

Comments
 (0)