Skip to content
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

feat: add DeprecationWarning for PaLM2TextEmbeddingGenerator #1018

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

GarrettWu
Copy link
Contributor

@GarrettWu GarrettWu commented Sep 24, 2024

No description provided.

@GarrettWu GarrettWu requested a review from tswast September 24, 2024 23:54
@GarrettWu GarrettWu self-assigned this Sep 24, 2024
@GarrettWu GarrettWu requested review from a team as code owners September 24, 2024 23:54
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Sep 24, 2024

@functools.wraps(func1)
def new_func1(*args, **kwargs):
warnings.simplefilter("always", DeprecationWarning)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't override people's default filters. Just use FutureWarning as recommended here: https://docs.python.org/3/library/warnings.html

See this note:

Changed in version 3.7: Previously DeprecationWarning and FutureWarning were distinguished based on whether a feature was being removed entirely or changing its behaviour. They are now distinguished based on their intended audience and the way they’re handled by the default warnings filters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@tswast tswast Sep 26, 2024

Choose a reason for hiding this comment

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

Can we put this in bigframes._core.deprecation? I know we haven't been the best at not polluting the bigframes.* namespace with private stuff, but since this isn't an API intended to be used by end users, I'd like to keep it clear that it's "private" to our package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the file, using typing_extension instead.

@tswast
Copy link
Collaborator

tswast commented Sep 26, 2024

Consider using https://typing-extensions.readthedocs.io/en/latest/#typing_extensions.deprecated instead, as that also works well with type checkers such as mypy.

@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: m Pull request size is medium. labels Sep 27, 2024
@GarrettWu
Copy link
Contributor Author

Consider using https://typing-extensions.readthedocs.io/en/latest/#typing_extensions.deprecated instead, as that also works well with type checkers such as mypy.

Done

@GarrettWu GarrettWu requested a review from sycai September 27, 2024 18:28
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.

@GarrettWu GarrettWu merged commit 4af5bbb into main Sep 27, 2024
22 of 23 checks passed
@GarrettWu GarrettWu deleted the garrettwu-deprecate branch September 27, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants