Skip to content

Commit 76ebabe

Browse files
google-labs-jules[bot]tswast
authored andcommitted
chore: use bigframes.pandas._read_gbq_colab() in benchmarks
I have refactored the `read_gbq_colab` benchmarks to call `bigframes.pandas`. I updated the benchmarks in `tests/benchmark/read_gbq_colab` to call `bigframes.pandas._read_gbq_colab(...)` instead of `session._read_gbq_colab(...)`. Since the `session` object is no longer needed in these benchmarks, I also removed that dependency.
1 parent e5ff8f7 commit 76ebabe

File tree

6 files changed

+24
-42
lines changed

6 files changed

+24
-42
lines changed

tests/benchmark/read_gbq_colab/aggregate_output.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515

1616
import benchmark.utils as utils
1717

18-
import bigframes.session
18+
import bigframes.pandas
1919

2020
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2121

2222

23-
def aggregate_output(
24-
*, project_id, dataset_id, table_id, session: bigframes.session.Session
25-
):
23+
def aggregate_output(*, project_id, dataset_id, table_id):
2624
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2725
# e.g. "{local_inline}" or "{local_large}"
28-
df = session._read_gbq_colab(
26+
df = bigframes.pandas._read_gbq_colab(
2927
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
3028
)
3129

@@ -56,9 +54,8 @@ def aggregate_output(
5654
project_id,
5755
dataset_id,
5856
table_id,
59-
session,
6057
suffix,
61-
) = utils.get_configuration(include_table_id=True)
58+
) = utils.get_configuration(include_table_id=True, include_session=False)
6259
current_path = pathlib.Path(__file__).absolute()
6360

6461
utils.get_execution_time(
@@ -68,5 +65,4 @@ def aggregate_output(
6865
project_id=project_id,
6966
dataset_id=dataset_id,
7067
table_id=table_id,
71-
session=session,
7268
)

tests/benchmark/read_gbq_colab/dry_run.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
import benchmark.utils as utils
1717

18-
import bigframes.session
18+
import bigframes.pandas
1919

2020

21-
def dry_run(*, project_id, dataset_id, table_id, session: bigframes.session.Session):
21+
def dry_run(*, project_id, dataset_id, table_id):
2222
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2323
# e.g. "{local_inline}" or "{local_large}"
24-
session._read_gbq_colab(
24+
bigframes.pandas._read_gbq_colab(
2525
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}",
2626
dry_run=True,
2727
)
@@ -32,9 +32,8 @@ def dry_run(*, project_id, dataset_id, table_id, session: bigframes.session.Sess
3232
project_id,
3333
dataset_id,
3434
table_id,
35-
session,
3635
suffix,
37-
) = utils.get_configuration(include_table_id=True)
36+
) = utils.get_configuration(include_table_id=True, include_session=False)
3837
current_path = pathlib.Path(__file__).absolute()
3938

4039
utils.get_execution_time(
@@ -44,5 +43,4 @@ def dry_run(*, project_id, dataset_id, table_id, session: bigframes.session.Sess
4443
project_id=project_id,
4544
dataset_id=dataset_id,
4645
table_id=table_id,
47-
session=session,
4846
)

tests/benchmark/read_gbq_colab/filter_output.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515

1616
import benchmark.utils as utils
1717

18-
import bigframes.session
18+
import bigframes.pandas
1919

2020
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2121

2222

23-
def filter_output(
24-
*, project_id, dataset_id, table_id, session: bigframes.session.Session
25-
):
23+
def filter_output(*, project_id, dataset_id, table_id):
2624
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2725
# e.g. "{local_inline}" or "{local_large}"
28-
df = session._read_gbq_colab(
26+
df = bigframes.pandas._read_gbq_colab(
2927
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
3028
)
3129

@@ -48,9 +46,8 @@ def filter_output(
4846
project_id,
4947
dataset_id,
5048
table_id,
51-
session,
5249
suffix,
53-
) = utils.get_configuration(include_table_id=True)
50+
) = utils.get_configuration(include_table_id=True, include_session=False)
5451
current_path = pathlib.Path(__file__).absolute()
5552

5653
utils.get_execution_time(
@@ -60,5 +57,4 @@ def filter_output(
6057
project_id=project_id,
6158
dataset_id=dataset_id,
6259
table_id=table_id,
63-
session=session,
6460
)

tests/benchmark/read_gbq_colab/first_page.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
import benchmark.utils as utils
1717

18-
import bigframes.session
18+
import bigframes.pandas
1919

2020
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2121

2222

23-
def first_page(*, project_id, dataset_id, table_id, session: bigframes.session.Session):
23+
def first_page(*, project_id, dataset_id, table_id):
2424
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2525
# e.g. "{local_inline}" or "{local_large}"
26-
df = session._read_gbq_colab(
26+
df = bigframes.pandas._read_gbq_colab(
2727
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
2828
)
2929

@@ -37,9 +37,8 @@ def first_page(*, project_id, dataset_id, table_id, session: bigframes.session.S
3737
project_id,
3838
dataset_id,
3939
table_id,
40-
session,
4140
suffix,
42-
) = utils.get_configuration(include_table_id=True)
41+
) = utils.get_configuration(include_table_id=True, include_session=False)
4342
current_path = pathlib.Path(__file__).absolute()
4443

4544
utils.get_execution_time(
@@ -49,5 +48,4 @@ def first_page(*, project_id, dataset_id, table_id, session: bigframes.session.S
4948
project_id=project_id,
5049
dataset_id=dataset_id,
5150
table_id=table_id,
52-
session=session,
5351
)

tests/benchmark/read_gbq_colab/last_page.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
import benchmark.utils as utils
1717

18-
import bigframes.session
18+
import bigframes.pandas
1919

2020
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2121

2222

23-
def last_page(*, project_id, dataset_id, table_id, session: bigframes.session.Session):
23+
def last_page(*, project_id, dataset_id, table_id):
2424
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2525
# e.g. "{local_inline}" or "{local_large}"
26-
df = session._read_gbq_colab(
26+
df = bigframes.pandas._read_gbq_colab(
2727
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
2828
)
2929

@@ -38,9 +38,8 @@ def last_page(*, project_id, dataset_id, table_id, session: bigframes.session.Se
3838
project_id,
3939
dataset_id,
4040
table_id,
41-
session,
4241
suffix,
43-
) = utils.get_configuration(include_table_id=True)
42+
) = utils.get_configuration(include_table_id=True, include_session=False)
4443
current_path = pathlib.Path(__file__).absolute()
4544

4645
utils.get_execution_time(
@@ -50,5 +49,4 @@ def last_page(*, project_id, dataset_id, table_id, session: bigframes.session.Se
5049
project_id=project_id,
5150
dataset_id=dataset_id,
5251
table_id=table_id,
53-
session=session,
5452
)

tests/benchmark/read_gbq_colab/sort_output.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515

1616
import benchmark.utils as utils
1717

18-
import bigframes.session
18+
import bigframes.pandas
1919

2020
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2121

2222

23-
def sort_output(
24-
*, project_id, dataset_id, table_id, session: bigframes.session.Session
25-
):
23+
def sort_output(*, project_id, dataset_id, table_id):
2624
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2725
# e.g. "{local_inline}" or "{local_large}"
28-
df = session._read_gbq_colab(
26+
df = bigframes.pandas._read_gbq_colab(
2927
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
3028
)
3129

@@ -48,9 +46,8 @@ def sort_output(
4846
project_id,
4947
dataset_id,
5048
table_id,
51-
session,
5249
suffix,
53-
) = utils.get_configuration(include_table_id=True)
50+
) = utils.get_configuration(include_table_id=True, include_session=False)
5451
current_path = pathlib.Path(__file__).absolute()
5552

5653
utils.get_execution_time(
@@ -60,5 +57,4 @@ def sort_output(
6057
project_id=project_id,
6158
dataset_id=dataset_id,
6259
table_id=table_id,
63-
session=session,
6460
)

0 commit comments

Comments
 (0)