Skip to content

Commit 3a36784

Browse files
yinghsienwucopybara-github
authored andcommitted
fix: Add deprecation warnings when using Ray v2.4
PiperOrigin-RevId: 629468075
1 parent 3f037a1 commit 3a36784

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import logging
2020
import time
2121
from typing import Dict, List, Optional
22+
import warnings
2223

2324
from google.cloud.aiplatform import initializer
2425
from google.cloud.aiplatform import utils
@@ -127,7 +128,10 @@ def create_ray_cluster(
127128
logging.info(
128129
"[Ray on Vertex]: No VPC network configured. It is required for client connection."
129130
)
130-
131+
if ray_version == "2.4":
132+
warnings.warn(
133+
_gapic_utils._V2_4_WARNING_MESSAGE, DeprecationWarning, stacklevel=2
134+
)
131135
local_ray_verion = _validation_utils.get_local_ray_version()
132136
if ray_version != local_ray_verion:
133137
if custom_images is None and head_node_type.custom_image is None:

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

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import ray.data
1919
from ray.data.dataset import Dataset
2020
from typing import Any, Dict, Optional
21+
import warnings
2122

2223
from google.cloud.aiplatform.preview.vertex_ray.bigquery_datasource import (
2324
BigQueryDatasource,
@@ -30,6 +31,10 @@
3031
except ImportError:
3132
_BigQueryDatasink = None
3233

34+
from google.cloud.aiplatform.preview.vertex_ray.util._validation_utils import (
35+
_V2_4_WARNING_MESSAGE,
36+
)
37+
3338

3439
def read_bigquery(
3540
project_id: Optional[str] = None,
@@ -56,6 +61,7 @@ def write_bigquery(
5661
ray_remote_args: Dict[str, Any] = None,
5762
) -> Any:
5863
if ray.__version__ == "2.4.0":
64+
warnings.warn(_V2_4_WARNING_MESSAGE, DeprecationWarning, stacklevel=2)
5965
return ds.write_datasource(
6066
BigQueryDatasource(),
6167
project_id=project_id,

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

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import ray.cloudpickle as cpickle
2525
import tempfile
2626
from typing import Optional, TYPE_CHECKING
27+
import warnings
2728

2829
from google.cloud import aiplatform
2930
from google.cloud.aiplatform import initializer
@@ -33,6 +34,9 @@
3334
from google.cloud.aiplatform.preview.vertex_ray.predict.util import (
3435
predict_utils,
3536
)
37+
from google.cloud.aiplatform.preview.vertex_ray.util._validation_utils import (
38+
_V2_4_WARNING_MESSAGE,
39+
)
3640

3741

3842
try:
@@ -123,6 +127,7 @@ def _get_estimator_from(
123127

124128
ray_version = ray.__version__
125129
if ray_version == "2.4.0":
130+
warnings.warn(_V2_4_WARNING_MESSAGE, DeprecationWarning, stacklevel=2)
126131
if not isinstance(checkpoint, ray_sklearn.SklearnCheckpoint):
127132
raise ValueError(
128133
"[Ray on Vertex AI]: arg checkpoint should be a"

google/cloud/aiplatform/preview/vertex_ray/predict/tensorflow/register.py

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import logging
2121
import ray
2222
from typing import Callable, Optional, Union, TYPE_CHECKING
23+
import warnings
2324

2425
from google.cloud import aiplatform
2526
from google.cloud.aiplatform import initializer
@@ -28,6 +29,9 @@
2829
from google.cloud.aiplatform.preview.vertex_ray.predict.util import (
2930
predict_utils,
3031
)
32+
from google.cloud.aiplatform.preview.vertex_ray.util._validation_utils import (
33+
_V2_4_WARNING_MESSAGE,
34+
)
3135

3236

3337
try:
@@ -141,6 +145,7 @@ def _get_tensorflow_model_from(
141145
"""
142146
ray_version = ray.__version__
143147
if ray_version == "2.4.0":
148+
warnings.warn(_V2_4_WARNING_MESSAGE, DeprecationWarning, stacklevel=2)
144149
if not isinstance(checkpoint, ray_tensorflow.TensorflowCheckpoint):
145150
raise ValueError(
146151
"[Ray on Vertex AI]: arg checkpoint should be a"

google/cloud/aiplatform/preview/vertex_ray/predict/torch/register.py

+5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
import ray
2121
from ray.air._internal.torch_utils import load_torch_model
2222
import tempfile
23+
from google.cloud.aiplatform.preview.vertex_ray.util._validation_utils import (
24+
_V2_4_WARNING_MESSAGE,
25+
)
2326
from google.cloud.aiplatform.utils import gcs_utils
2427
from typing import Optional
28+
import warnings
2529

2630

2731
try:
@@ -61,6 +65,7 @@ def get_pytorch_model_from(
6165
"""
6266
ray_version = ray.__version__
6367
if ray_version == "2.4.0":
68+
warnings.warn(_V2_4_WARNING_MESSAGE, DeprecationWarning, stacklevel=2)
6469
if not isinstance(checkpoint, ray_torch.TorchCheckpoint):
6570
raise ValueError(
6671
"[Ray on Vertex AI]: arg checkpoint should be a"

google/cloud/aiplatform/preview/vertex_ray/predict/xgboost/register.py

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import ray
2424
import tempfile
2525
from typing import Optional, TYPE_CHECKING
26+
import warnings
2627

2728
from google.cloud import aiplatform
2829
from google.cloud.aiplatform import initializer
@@ -32,6 +33,9 @@
3233
from google.cloud.aiplatform.preview.vertex_ray.predict.util import (
3334
predict_utils,
3435
)
36+
from google.cloud.aiplatform.preview.vertex_ray.util._validation_utils import (
37+
_V2_4_WARNING_MESSAGE,
38+
)
3539

3640

3741
try:
@@ -133,6 +137,7 @@ def _get_xgboost_model_from(
133137
"""
134138
ray_version = ray.__version__
135139
if ray_version == "2.4.0":
140+
warnings.warn(_V2_4_WARNING_MESSAGE, DeprecationWarning, stacklevel=2)
136141
if not isinstance(checkpoint, ray_xgboost.XGBoostCheckpoint):
137142
raise ValueError(
138143
"[Ray on Vertex AI]: arg checkpoint should be a"

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

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727

2828
SUPPORTED_RAY_VERSIONS = immutabledict({"2.4": "2.4.0", "2.9": "2.9.3"})
2929
SUPPORTED_PY_VERSION = ["3.10"]
30+
_V2_4_WARNING_MESSAGE = (
31+
"After May 30, 2024, using Ray version = 2.4 will result in an error. "
32+
"Please use Ray version = 2.9.3 (default) instead."
33+
)
3034

3135
# Artifact Repository available regions.
3236
_AVAILABLE_REGIONS = ["us", "europe", "asia"]

0 commit comments

Comments
 (0)