8000 docs: add deprecation notice to readme for Generative AI submodules: … · googleapis/python-aiplatform@c8a6e0d · GitHub
[go: up one dir, main page]

Skip to content

Commit c8a6e0d

Browse files
sararobcopybara-github
authored andcommitted
docs: add deprecation notice to readme for Generative AI submodules: vertexai.generative_models, vertexai.language_models, vertexai.vision_models, vertexai.tuning, vertexai.batch_prediction, vertexai.caching
PiperOrigin-RevId: 774778884
1 parent 1c60ee2 commit c8a6e0d

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Vertex AI SDK for Python
22
=================================================
33

4+
.. note::
5+
6+
The following Generative AI modules in the Vertex AI SDK are deprecated as of June 24, 2025 and will be removed on June 24, 2026:
7+
`vertexai.generative_models`, `vertexai.language_models`, `vertexai.vision_models`, `vertexai.tuning`, `vertexai.batch_prediction`, `vertexai.caching`. Please use the
8+
[Google Gen AI SDK](https://pypi.org/project/google-genai/) to access these features. See
9+
[the migration guide](https://cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk) for details.
10+
You can continue using all other Vertex AI SDK modules, as they are the recommended way to use the API.
11+
12+
413
|GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests|
514

615
`Vertex AI`_: Google Vertex AI is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import functools
16+
from typing import Any, Callable, Optional
17+
import warnings
18+
19+
BASE_WARNING_MESSAGE = (
20+
"This feature is deprecated as of June 24, 2025 and will be removed on June"
21+
" 24, 2026. For details, see"
22+
" https://cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk."
23+
)
24+
25+
26+
class DeprecationWarning(Warning):
27+
"""A warning that a feature is deprecated."""
28+
29+
30+
def genai_deprecation_warning(
31+
message: Optional[str] = BASE_WARNING_MESSAGE,
32+
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
33+
"""Deprecation warning, only warns once."""
34+
35+
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
36+
warning_done = False
37+
38+
@functools.wraps(func)
39+
def wrapper(*args: Any, **kwargs: Any) -> Any:
40+
nonlocal warning_done
41+
if not warning_done:
42+
warning_done = True
43+
warnings.warn(
44+
message=message,
45+
category=DeprecationWarning,
46+
stacklevel=2,
47+
)
48+
return func(*args, **kwargs)
49+
50+
return wrapper
51+
52+
return decorator

vertexai/batch_prediction/_batch_prediction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from google.cloud.aiplatform import utils as aiplatform_utils
2727
from google.cloud.aiplatform_v1 import types as gca_types
2828
from vertexai import generative_models
29+
from vertexai._utils import deprecation_warning
2930

3031
from google.rpc import status_pb2
3132

@@ -38,6 +39,7 @@
3839
_GEMINI_TUNED_MODEL_PATTERN = r"^projects/[0-9]+?/locations/[0-9a-z-]+?/models/[0-9]+?$"
3940

4041

42+
@deprecation_warning.genai_deprecation_warning()
4143
class BatchPredictionJob(aiplatform_base._VertexAiResourceNounPlus):
4244
"""Represents a BatchPredictionJob that runs with GenAI models."""
4345

vertexai/caching/_caching.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
)
5151
from google.protobuf import field_mask_pb2
5252

53+
from vertexai._utils import deprecation_warning
54+
5355

5456
def _prepare_create_request(
5557
model_name: str,
@@ -127,6 +129,7 @@ def _prepare_get_cached_content_request(name: str) -> GetCachedContentRequest:
127129
return types_v1.GetCachedContentRequest(name=name)
128130

129131

132+
@deprecation_warning.genai_deprecation_warning()
130133
class CachedContent(aiplatform_base._VertexAiResourceNounPlus):
131134
"""A cached content resource."""
132135

vertexai/generative_models/_generative_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
from google.protobuf import field_mask_pb2
6464
import warnings
6565

66+
from vertexai._utils import deprecation_warning
67+
6668
if TYPE_CHECKING:
6769
from vertexai.caching import CachedContent
6870

@@ -3406,6 +3408,7 @@ def respond_to_model_response(
34063408
return function_response_content
34073409

34083410

3411+
@deprecation_warning.genai_deprecation_warning()
34093412
class GenerativeModel(_GenerativeModel):
34103413
__module__ = "vertexai.generative_models"
34113414

vertexai/tuning/_tuning.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
from google.rpc import status_pb2 # type: ignore
4141

42+
from vertexai._utils import deprecation_warning
43+
4244

4345
_LOGGER = aiplatform_base.Logger(__name__)
4446

@@ -52,6 +54,7 @@ class TuningJobClientWithOverride(aiplatform_utils.ClientWithOverride):
5254
)
5355

5456

57+
@deprecation_warning.genai_deprecation_warning()
5558
class TuningJob(aiplatform_base._VertexAiResourceNounPlus):
5659
"""Represents a TuningJob that runs with Google owned models."""
5760

0 commit comments

Comments
 (0)
0