Skip to content

refactor: introduce ai operator namespace and deprecated semantics #1511

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 16 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from 10 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
3 changes: 3 additions & 0 deletions bigframes/_config/compute_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class ComputeOptions:
semantic_ops_confirmation_threshold: Optional[int] = 0
semantic_ops_threshold_autofail = False

ai_ops_confirmation_threshold: Optional[int] = 0
ai_ops_threshold_autofail = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Also update the docstring as the semantic ops here. Also, mark semantic_ops as deprecated in the docstring too?

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


def assign_extra_query_labels(self, **kwargs: Any) -> None:
"""
Assigns additional custom labels for query configuration. The method updates the
Expand Down
15 changes: 15 additions & 0 deletions bigframes/_config/experiment_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ExperimentOptions:

def __init__(self):
self._semantic_operators: bool = False
self._ai_operators: bool = False
self._blob: bool = False
self._udf: bool = False

Expand All @@ -41,6 +42,20 @@ def semantic_operators(self, value: bool):
warnings.warn(msg, category=bfe.PreviewWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the experiment_options for semantic_operators be marked as deprecated as well?

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

self._semantic_operators = value

@property
def ai_operators(self) -> bool:
return self._ai_operators

@ai_operators.setter
def ai_operators(self, value: bool):
if value is True:
msg = bfe.format_message(
"AI operators are still under experiments, and are subject "
"to change in the future."
)
warnings.warn(msg, category=bfe.PreviewWarning)
self._ai_operators = value

@property
def blob(self) -> bool:
return self._blob
Expand Down
9 changes: 9 additions & 0 deletions bigframes/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import bigframes.operations as ops
import bigframes.operations.aggregations
import bigframes.operations.aggregations as agg_ops
import bigframes.operations.ai
import bigframes.operations.plotting as plotting
import bigframes.operations.semantics
import bigframes.operations.structs
Expand Down Expand Up @@ -4574,4 +4575,12 @@ def _throw_if_null_index(self, opname: str):

@property
def semantics(self):
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please format the warning message as below:

msg = bfe.format_message("The 'semantics' property will be removed. Please use 'ai' instead.")
warnings.warn(msg,  category=bfe.PreviewWarning)

Copy link
Contributor

Choose a reason for hiding this comment

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

@tswast for suggestions too.
Should we use @typing_extensions.deprecated as other LLM methods does?

@typing_extensions.deprecated
(
    "PaLM2TextGenerator is going to be deprecated. Use GeminiTextGenerator instead. ",
    category=exceptions.ApiDeprecationWarning,
)

"The 'semantic' property will be removed. Please use 'ai' instead.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo.

Suggested change
"The 'semantic' property will be removed. Please use 'ai' instead.",
"The 'semantics' property will be removed. Please use 'ai' instead.",

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

FutureWarning,
)
return bigframes.operations.semantics.Semantics(self)

@property
def ai(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need a docstring? Also, please add the AI class to the accessors section in the docs:

https://github.com/googleapis/python-bigquery-dataframes/blob/main/docs/reference/bigframes.pandas/frame.rst#accessors

as well as thhe table of contents

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return bigframes.operations.ai.Ai(self)
Loading