Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: add DeprecationWarning for PaLM2TextEmbeddingGenerator #1018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 4 bigframes/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ class AmbiguousWindowWarning(Warning):

class UnknownDataTypeWarning(Warning):
"""Data type is unknown."""


class ApiDeprecationWarning(FutureWarning):
"""The API has been deprecated."""
9 changes: 7 additions & 2 deletions 9 bigframes/ml/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

import bigframes_vendored.constants as constants
from google.cloud import bigquery
import typing_extensions

import bigframes
from bigframes import clients
from bigframes import clients, exceptions
from bigframes.core import blocks, log_adapter
from bigframes.ml import base, core, globals, utils
import bigframes.pandas as bpd
Expand Down Expand Up @@ -407,12 +408,16 @@ def to_gbq(self, model_name: str, replace: bool = False) -> PaLM2TextGenerator:
return new_model.session.read_gbq_model(model_name)


@typing_extensions.deprecated(
"PaLM2TextEmbeddingGenerator has been deprecated. Use TextEmbeddingGenerator(https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.TextEmbeddingGenerator) instead. ",
category=exceptions.ApiDeprecationWarning,
)
@log_adapter.class_logger
class PaLM2TextEmbeddingGenerator(base.BaseEstimator):
"""PaLM2 text embedding generator LLM model.

.. note::
Models in this class are outdated and going to be deprecated. To use the most updated text embedding models, go to the TextEmbeddingGenerator class.
PaLM2TextEmbeddingGenerator has been deprecated. Use TextEmbeddingGenerator(https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.TextEmbeddingGenerator) instead.


Args:
Expand Down
9 changes: 9 additions & 0 deletions 9 tests/system/small/ml/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import pytest

from bigframes import exceptions
from bigframes.ml import llm
from tests.system import utils

Expand Down Expand Up @@ -383,3 +384,11 @@ def test_llm_gemini_pro_score_params(llm_fine_tune_df_default_index):
],
index=6,
)


def test_palm2_text_embedding_deprecated():
with pytest.warns(exceptions.ApiDeprecationWarning):
try:
llm.PaLM2TextEmbeddingGenerator()
except (Exception):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like we are also ignoring all the exceptions? I wonder if we could just let it be raised and fail this test, if such a case occurs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend is already unavailable now. The exception is expected. We only want to check the warnings.

pass
Morty Proxy This is a proxified and sanitized view of the page, visit original site.