Skip to content

Commit ac59173

Browse files
authored
refactor: introduce ai operator namespace and deprecated semantics (#1511)
* refactor: introduce ai operator namespace and deprecated semantics * duplicate semantic op options too * improve test coverage * relax test condition * clean up semantics and add public docs * addressing comments * use FutureWarning for deprecation * copy over recent top_k changes
1 parent 803c6dd commit ac59173

File tree

12 files changed

+2098
-11
lines changed

12 files changed

+2098
-11
lines changed

bigframes/_config/compute_options.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,31 @@ class ComputeOptions:
6060
bytes billed beyond this limit will fail (without incurring a
6161
charge). If unspecified, this will be set to your project default.
6262
See `maximum_bytes_billed`: https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJobConfig#google_cloud_bigquery_job_QueryJobConfig_maximum_bytes_billed.
63+
6364
enable_multi_query_execution (bool, Options):
6465
If enabled, large queries may be factored into multiple smaller queries
6566
in order to avoid generating queries that are too complex for the query
6667
engine to handle. However this comes at the cost of increase cost and latency.
68+
6769
extra_query_labels (Dict[str, Any], Options):
6870
Stores additional custom labels for query configuration.
69-
semmantic_ops_confirmation_threshold (int, optional):
70-
Guards against unexepcted processing of large amount of rows by semantic operators.
71+
72+
semantic_ops_confirmation_threshold (int, optional):
73+
.. deprecated:: 1.42.0
74+
Semantic operators are deprecated. Please use AI operators instead
75+
76+
semantic_ops_threshold_autofail (bool):
77+
.. deprecated:: 1.42.0
78+
Semantic operators are deprecated. Please use AI operators instead
79+
80+
ai_ops_confirmation_threshold (int, optional):
81+
Guards against unexpected processing of large amount of rows by semantic operators.
7182
If the number of rows exceeds the threshold, the user will be asked to confirm
7283
their operations to resume. The default value is 0. Set the value to None
7384
to turn off the guard.
74-
semantic_ops_threshold_autofail (bool):
75-
Guards against unexepcted processing of large amount of rows by semantic operators.
85+
86+
ai_ops_threshold_autofail (bool):
87+
Guards against unexpected processing of large amount of rows by semantic operators.
7688
When set to True, the operation automatically fails without asking for user inputs.
7789
"""
7890

@@ -84,6 +96,9 @@ class ComputeOptions:
8496
semantic_ops_confirmation_threshold: Optional[int] = 0
8597
semantic_ops_threshold_autofail = False
8698

99+
ai_ops_confirmation_threshold: Optional[int] = 0
100+
ai_ops_threshold_autofail = False
101+
87102
def assign_extra_query_labels(self, **kwargs: Any) -> None:
88103
"""
89104
Assigns additional custom labels for query configuration. The method updates the

bigframes/_config/experiment_options.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ExperimentOptions:
2424

2525
def __init__(self):
2626
self._semantic_operators: bool = False
27+
self._ai_operators: bool = False
2728
self._blob: bool = False
2829
self._udf: bool = False
2930

@@ -35,11 +36,24 @@ def semantic_operators(self) -> bool:
3536
def semantic_operators(self, value: bool):
3637
if value is True:
3738
msg = bfe.format_message(
38-
"Semantic operators are still under experiments, and are subject "
39+
"Semantic operators are deprecated, and will be removed in the future"
40+
)
41+
warnings.warn(msg, category=FutureWarning)
42+
self._semantic_operators = value
43+
44+
@property
45+
def ai_operators(self) -> bool:
46+
return self._ai_operators
47+
48+
@ai_operators.setter
49+
def ai_operators(self, value: bool):
50+
if value is True:
51+
msg = bfe.format_message(
52+
"AI operators are still under experiments, and are subject "
3953
"to change in the future."
4054
)
4155
warnings.warn(msg, category=bfe.PreviewWarning)
42-
self._semantic_operators = value
56+
self._ai_operators = value
4357

4458
@property
4559
def blob(self) -> bool:

bigframes/dataframe.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import bigframes.operations as ops
7575
import bigframes.operations.aggregations
7676
import bigframes.operations.aggregations as agg_ops
77+
import bigframes.operations.ai
7778
import bigframes.operations.plotting as plotting
7879
import bigframes.operations.semantics
7980
import bigframes.operations.structs
@@ -4574,4 +4575,13 @@ def _throw_if_null_index(self, opname: str):
45744575

45754576
@property
45764577
def semantics(self):
4578+
msg = bfe.format_message(
4579+
"The 'semantics' property will be removed. Please use 'ai' instead."
4580+
)
4581+
warnings.warn(msg, category=FutureWarning)
45774582
return bigframes.operations.semantics.Semantics(self)
4583+
4584+
@property
4585+
def ai(self):
4586+
"""Returns the accessor for AI operators."""
4587+
return bigframes.operations.ai.AIAccessor(self)

0 commit comments

Comments
 (0)