docs: Add code examples to configuration docstrings (#2352) · googleapis/python-bigquery-dataframes@3c21993 · GitHub
Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 3c21993

Browse files
docs: Add code examples to configuration docstrings (#2352)
Added code examples to the docstrings of global configuration properties to demonstrate how to set them using `bigframes.pandas.options`. This covers BigQuery options, compute options, sampling options, experiment options, and display options. --- *PR created automatically by Jules for task [15986639753712030034](https://jules.google.com/task/15986639753712030034) started by @tswast* --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Tim Sweña (Swast) <swast@google.com> Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
1 parent 5c91fb6 commit 3c21993

5 files changed

Lines changed: 193 additions & 16 deletions

File tree

bigframes/_config/bigquery_options.py

Lines changed: 56 additions & 1 deletion

bigframes/_config/compute_options.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,30 @@ class ComputeOptions:
2828
>>> import bigframes.pandas as bpd
2929
>>> df = bpd.read_gbq("bigquery-public-data.ml_datasets.penguins")
3030
31-
>>> bpd.options.compute.maximum_bytes_billed = 500
31+
>>> bpd.options.compute.maximum_bytes_billed = 500 # doctest: +SKIP
3232
>>> df.to_pandas() # this should fail # doctest: +SKIP
3333
google.api_core.exceptions.InternalServerError: 500 Query exceeded limit for bytes billed: 500. 10485760 or higher required.
3434
35-
>>> bpd.options.compute.maximum_bytes_billed = None # reset option
35+
>>> bpd.options.compute.maximum_bytes_billed = None # reset option # doctest: +SKIP
3636
3737
To add multiple extra labels to a query configuration, use the `assign_extra_query_labels`
3838
method with keyword arguments:
3939
40-
>>> bpd.options.compute.assign_extra_query_labels(test1=1, test2="abc")
41-
>>> bpd.options.compute.extra_query_labels
40+
>>> bpd.options.compute.assign_extra_query_labels(test1=1, test2="abc") # doctest: +SKIP
41+
>>> bpd.options.compute.extra_query_labels # doctest: +SKIP
4242
{'test1': 1, 'test2': 'abc'}
4343
4444
Alternatively, you can add labels individually by directly accessing the `extra_query_labels`
4545
dictionary:
4646
47-
>>> bpd.options.compute.extra_query_labels["test3"] = False
48-
>>> bpd.options.compute.extra_query_labels
47+
>>> bpd.options.compute.extra_query_labels["test3"] = False # doctest: +SKIP
48+
>>> bpd.options.compute.extra_query_labels # doctest: +SKIP
4949
{'test1': 1, 'test2': 'abc', 'test3': False}
5050
5151
To remove a label from the configuration, use the `del` keyword on the desired label key:
5252
53-
>>> del bpd.options.compute.extra_query_labels["test1"]
54-
>>> bpd.options.compute.extra_query_labels
53+
>>> del bpd.options.compute.extra_query_labels["test1"] # doctest: +SKIP
54+
>>> bpd.options.compute.extra_query_labels # doctest: +SKIP
5555
{'test2': 'abc', 'test3': False}
5656
"""
5757

@@ -63,6 +63,11 @@ class ComputeOptions:
6363
their operations to resume. The default value is 0. Set the value to None
6464
to turn off the guard.
6565
66+
**Examples:**
67+
68+
>>> import bigframes.pandas as bpd
69+
>>> bpd.options.compute.ai_ops_confirmation_threshold = 100 # doctest: +SKIP
70+
6671
Returns:
6772
Optional[int]: Number of rows.
6873
"""
@@ -73,6 +78,11 @@ class ComputeOptions:
7378
7479
When set to True, the operation automatically fails without asking for user inputs.
7580
81+
**Examples:**
82+
83+
>>> import bigframes.pandas as bpd
84+
>>> bpd.options.compute.ai_ops_threshold_autofail = True # doctest: +SKIP
85+
7686
Returns:
7787
bool: True if the guard is enabled.
7888
"""
@@ -85,6 +95,10 @@ class ComputeOptions:
8595
10 GB for potentially faster execution; BigQuery will raise an error if this
8696
limit is exceeded. Setting to True removes this result size limit.
8797
98+
**Examples:**
99+
100+
>>> import bigframes.pandas as bpd
101+
>>> bpd.options.compute.allow_large_results = True # doctest: +SKIP
88102
89103
Returns:
90104
bool | None: True if results > 10 GB are enabled.
@@ -97,6 +111,10 @@ class ComputeOptions:
97111
query engine to handle. However this comes at the cost of increase cost and
98112
latency.
99113
114+
**Examples:**
115+
116+
>>> import bigframes.pandas as bpd
117+
>>> bpd.options.compute.enable_multi_query_execution = True # doctest: +SKIP
100118
101119
Returns:
102120
bool | None: True if enabled.
@@ -121,6 +139,11 @@ class ComputeOptions:
121139
default. See `maximum_bytes_billed`:
122140
https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJobConfig#google_cloud_bigquery_job_QueryJobConfig_maximum_bytes_billed.
123141
142+
**Examples:**
143+
144+
>>> import bigframes.pandas as bpd
145+
>>> bpd.options.compute.maximum_bytes_billed = 1000 # doctest: +SKIP
146+
124147
Returns:
125148
int | None: Number of bytes, if set.
126149
"""
@@ -136,6 +159,11 @@ class ComputeOptions:
136159
of rows to be downloaded exceeds this limit, a
137160
``bigframes.exceptions.MaximumResultRowsExceeded`` exception is raised.
138161
162+
**Examples:**
163+
164+
>>> import bigframes.pandas as bpd
165+
>>> bpd.options.compute.maximum_result_rows = 1000 # doctest: +SKIP
166+
139167
Returns:
140168
int | None: Number of rows, if set.
141169
"""

bigframes/_config/experiment_options.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ def __init__(self):
3131

3232
@property
3333
def semantic_operators(self) -> bool:
34+
"""Deprecated.
35+
36+
**Examples:**
37+
38+
>>> import bigframes.pandas as bpd
39+
>>> bpd.options.experiments.semantic_operators = True # doctest: +SKIP
40+
"""
3441
return self._semantic_operators
3542

3643
@semantic_operators.setter
@@ -44,6 +51,13 @@ def semantic_operators(self, value: bool):
4451

4552
@property
4653
def ai_operators(self) -> bool:
54+
"""If True, allow using the AI operators.
55+
56+
**Examples:**
57+
58+
>>> import bigframes.pandas as bpd
59+
>>> bpd.options.experiments.ai_operators = True # doctest: +SKIP
60+
"""
4761
return self._ai_operators
4862

4963
@ai_operators.setter

bigframes/_config/sampling_options.py

Lines changed: 20 additions & 0 deletions

0 commit comments

Comments
 (0)