Skip to content

Commit 456fb32

Browse files
authored
chore: add deferred exec code samples (#439)
* chore: add deferred exec code samples * fix tests * fix tests
1 parent 56de982 commit 456fb32

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

bigframes/_config/compute_options.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ class ComputeOptions:
2323
"""
2424
Encapsulates configuration for compute options.
2525
26+
**Examples:**
27+
28+
>>> import bigframes.pandas as bpd
29+
>>> df = bpd.read_gbq("bigquery-public-data.ml_datasets.penguins")
30+
31+
>>> bpd.options.compute.maximum_bytes_billed = 500
32+
>>> # df.to_pandas() # this should fail
33+
google.api_core.exceptions.InternalServerError: 500 Query exceeded limit for bytes billed: 500. 10485760 or higher required.
34+
35+
>>> bpd.options.compute.maximum_bytes_billed = None # reset option
36+
2637
Attributes:
2738
maximum_bytes_billed (int, Options):
2839
Limits the bytes billed for query jobs. Queries that will have

third_party/bigframes_vendored/pandas/core/config_init.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@
1515
display_options_doc = """
1616
Encapsulates configuration for displaying objects.
1717
18+
**Examples:**
19+
20+
Define Repr mode to "deferred" will prevent job execution in repr.
21+
>>> import bigframes.pandas as bpd
22+
>>> df = bpd.read_gbq("bigquery-public-data.ml_datasets.penguins")
23+
24+
>>> bpd.options.display.repr_mode = "deferred"
25+
>>> df.head(20) # will no longer run the job
26+
Computation deferred. Computation will process 28.9 kB
27+
28+
Users can also get a dry run of the job by accessing the query_job property before they've run the job. This will return a dry run instance of the job they can inspect.
29+
>>> df.query_job.total_bytes_processed
30+
28947
31+
32+
User can execute the job by calling .to_pandas()
33+
>>> # df.to_pandas()
34+
35+
Reset option
36+
>>> bpd.options.display.repr_mode = "head"
37+
1838
Attributes:
1939
max_columns (int, default 20):
2040
If `max_columns` is exceeded, switch to truncate view.

0 commit comments

Comments
 (0)