Skip to content

Commit ce9d123

Browse files
I've updated the benchmarks to use bigframes.pandas._read_gbq_colab().
1 parent f63ce9b commit ce9d123

File tree

5 files changed

+23
-29
lines changed

5 files changed

+23
-29
lines changed

tests/benchmark/read_gbq_colab/dry_run.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,20 @@
1414
import pathlib
1515

1616
import benchmark.utils as utils
17+
import bigframes.pandas
1718

18-
import bigframes.session
1919

20-
21-
def dry_run(*, project_id, dataset_id, table_id, session: bigframes.session.Session):
20+
def dry_run(*, project_id, dataset_id, table_id):
2221
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2322
# e.g. "{local_inline}" or "{local_large}"
24-
session._read_gbq_colab(
23+
bigframes.pandas._read_gbq_colab(
2524
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}",
2625
dry_run=True,
2726
)
2827

2928

3029
if __name__ == "__main__":
31-
config = utils.get_configuration(include_table_id=True)
30+
config = utils.get_configuration(include_table_id=True, start_session=False)
3231
current_path = pathlib.Path(__file__).absolute()
3332

3433
utils.get_execution_time(
@@ -38,5 +37,4 @@ def dry_run(*, project_id, dataset_id, table_id, session: bigframes.session.Sess
3837
project_id=config.project_id,
3938
dataset_id=config.dataset_id,
4039
table_id=config.table_id,
41-
session=config.session,
4240
)

tests/benchmark/read_gbq_colab/first_page.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
import pathlib
1515

1616
import benchmark.utils as utils
17-
18-
import bigframes.session
17+
import bigframes.pandas
1918

2019
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2120

2221

23-
def first_page(*, project_id, dataset_id, table_id, session: bigframes.session.Session):
22+
def first_page(*, project_id, dataset_id, table_id):
2423
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2524
# e.g. "{local_inline}" or "{local_large}"
26-
df = session._read_gbq_colab(
25+
df = bigframes.pandas._read_gbq_colab(
2726
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
2827
)
2928

@@ -33,7 +32,7 @@ def first_page(*, project_id, dataset_id, table_id, session: bigframes.session.S
3332

3433

3534
if __name__ == "__main__":
36-
config = utils.get_configuration(include_table_id=True)
35+
config = utils.get_configuration(include_table_id=True, start_session=False)
3736
current_path = pathlib.Path(__file__).absolute()
3837

3938
utils.get_execution_time(
@@ -43,5 +42,4 @@ def first_page(*, project_id, dataset_id, table_id, session: bigframes.session.S
4342
project_id=config.project_id,
4443
dataset_id=config.dataset_id,
4544
table_id=config.table_id,
46-
session=config.session,
4745
)

tests/benchmark/read_gbq_colab/last_page.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
import pathlib
1515

1616
import benchmark.utils as utils
17-
18-
import bigframes.session
17+
import bigframes.pandas
1918

2019
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2120

2221

23-
def last_page(*, project_id, dataset_id, table_id, session: bigframes.session.Session):
22+
def last_page(*, project_id, dataset_id, table_id):
2423
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2524
# e.g. "{local_inline}" or "{local_large}"
26-
df = session._read_gbq_colab(
25+
df = bigframes.pandas._read_gbq_colab(
2726
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
2827
)
2928

@@ -34,7 +33,7 @@ def last_page(*, project_id, dataset_id, table_id, session: bigframes.session.Se
3433

3534

3635
if __name__ == "__main__":
37-
config = utils.get_configuration(include_table_id=True)
36+
config = utils.get_configuration(include_table_id=True, start_session=False)
3837
current_path = pathlib.Path(__file__).absolute()
3938

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

tests/benchmark/read_gbq_colab/sort_output.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414
import pathlib
1515

1616
import benchmark.utils as utils
17-
18-
import bigframes.session
17+
import bigframes.pandas
1918

2019
PAGE_SIZE = utils.READ_GBQ_COLAB_PAGE_SIZE
2120

2221

23-
def sort_output(
24-
*, project_id, dataset_id, table_id, session: bigframes.session.Session
25-
):
22+
def sort_output(*, project_id, dataset_id, table_id):
2623
# TODO(tswast): Support alternative query if table_id is a local DataFrame,
2724
# e.g. "{local_inline}" or "{local_large}"
28-
df = session._read_gbq_colab(
25+
df = bigframes.pandas._read_gbq_colab(
2926
f"SELECT * FROM `{project_id}`.{dataset_id}.{table_id}"
3027
)
3128

@@ -44,7 +41,7 @@ def sort_output(
4441

4542

4643
if __name__ == "__main__":
47-
config = utils.get_configuration(include_table_id=True)
44+
config = utils.get_configuration(include_table_id=True, start_session=False)
4845
current_path = pathlib.Path(__file__).absolute()
4946

5047
utils.get_execution_time(
@@ -54,5 +51,4 @@ def sort_output(
5451
project_id=config.project_id,
5552
dataset_id=config.dataset_id,
5653
table_id=config.table_id,
57-
session=config.session,
5854
)

tests/benchmark/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
class BenchmarkConfig:
2626
project_id: str
2727
dataset_id: str
28-
session: bigframes.Session
28+
session: bigframes.Session | None
2929
benchmark_suffix: str | None
3030
table_id: str | None = None
3131

3232

33-
def get_configuration(include_table_id=False) -> BenchmarkConfig:
33+
def get_configuration(
34+
include_table_id=False, start_session=True
35+
) -> BenchmarkConfig:
3436
parser = argparse.ArgumentParser()
3537
parser.add_argument(
3638
"--project_id",
@@ -65,7 +67,9 @@ def get_configuration(include_table_id=False) -> BenchmarkConfig:
6567
)
6668

6769
args = parser.parse_args()
68-
session = _initialize_session(_str_to_bool(args.ordered))
70+
session = (
71+
_initialize_session(_str_to_bool(args.ordered)) if start_session else None
72+
)
6973

7074
return BenchmarkConfig(
7175
project_id=args.project_id,

0 commit comments

Comments
 (0)