Skip to content

Commit ceca490

Browse files
chore: refactor get_configuration to use a dataclass (#1940)
* Refactor get_configuration to use a dataclass I've introduced a new `BenchmarkConfig` frozen dataclass to provide a more structured way of handling benchmark configurations. I updated the `get_configuration` function in `tests/benchmark/utils.py` to return an instance of this dataclass. I have partially updated the call sites for `get_configuration` to use the new dataclass object. The following directories have been updated: - tests/benchmark/db_benchmark/groupby/ - tests/benchmark/db_benchmark/join/ - tests/benchmark/db_benchmark/sort/ - tests/benchmark/read_gbq_colab/ (except for sort_output.py) The remaining call sites in `tests/benchmark/read_gbq_colab/sort_output.py` and `tests/benchmark/tpch/` still need to be updated. * I will refactor `get_configuration` to use a dataclass. This change introduces a new `BenchmarkConfig` frozen dataclass to provide a more structured way of handling benchmark configurations. The `get_configuration` function in `tests/benchmark/utils.py` will be updated to return an instance of this dataclass. All call sites for `get_configuration` will be updated to use the new dataclass object. * I will refactor `get_configuration` to use a dataclass. This change introduces a new `BenchmarkConfig` frozen dataclass to provide a more structured way of handling benchmark configurations. The `get_configuration` function in `tests/benchmark/utils.py` will be updated to return an instance of this dataclass. All call sites for `get_configuration` will be updated to use the new dataclass object. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent ab01b0a commit ceca490

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+298
-312
lines changed

tests/benchmark/db_benchmark/groupby/q1.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q1,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q10.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q10,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q2.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q2,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q3.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q3,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q4.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q4,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q5.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q5,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q6.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q6,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q7.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q7,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/groupby/q8.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import bigframes_vendored.db_benchmark.groupby_queries as vendored_dbbenchmark_groupby_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822
current_path = pathlib.Path(__file__).absolute()
2923

3024
utils.get_execution_time(
3125
vendored_dbbenchmark_groupby_queries.q8,
3226
current_path,
33-
suffix,
34-
project_id,
35-
dataset_id,
36-
table_id,
37-
session,
27+
config.benchmark_suffix,
28+
config.project_id,
29+
config.dataset_id,
30+
config.table_id,
31+
config.session,
3832
)

tests/benchmark/db_benchmark/join/q1.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,16 @@
1818
import bigframes_vendored.db_benchmark.join_queries as vendored_dbbenchmark_join_queries
1919

2020
if __name__ == "__main__":
21-
(
22-
project_id,
23-
dataset_id,
24-
table_id,
25-
session,
26-
suffix,
27-
) = utils.get_configuration(include_table_id=True)
21+
config = utils.get_configuration(include_table_id=True)
2822

2923
current_path = pathlib.Path(__file__).absolute()
3024

3125
utils.get_execution_time(
3226
vendored_dbbenchmark_join_queries.q1,
3327
current_path,
34-
suffix,
35-
project_id,
36-
dataset_id,
37-
table_id,
38-
session,
28+
config.benchmark_suffix,
29+
config.project_id,
30+
config.dataset_id,
31+
config.table_id,
32+
config.session,
3933
)

0 commit comments

Comments
 (0)