35
35
# https://github.com/str0zzapreti/pytest-retry/issues/32
36
36
PYTEST_VERSION = "pytest<8.0.0dev"
37
37
SPHINX_VERSION = "sphinx==4.5.0"
38
- LINT_PATHS = ["docs" , "bigframes" , "tests" , "third_party" , "noxfile.py" , "setup.py" ]
38
+ LINT_PATHS = [
39
+ "docs" ,
40
+ "bigframes" ,
41
+ "tests" ,
42
+ "third_party" ,
43
+ "noxfile.py" ,
44
+ "setup.py" ,
45
+ os .path .join ("scripts" , "benchmark" ),
46
+ ]
39
47
40
48
DEFAULT_PYTHON_VERSION = "3.10"
41
49
@@ -813,22 +821,17 @@ def notebook(session: nox.Session):
813
821
@nox .session (python = SYSTEM_TEST_PYTHON_VERSIONS )
814
822
def benchmark (session : nox .Session ):
815
823
session .install ("-e" , ".[all]" )
824
+ base_path = os .path .join ("scripts" , "benchmark" )
816
825
817
- benchmark_script_list = list (Path ("scripts/benchmark/" ).glob ("*.py" ))
818
-
826
+ benchmark_script_list = list (Path (base_path ).rglob ("*.py" ))
819
827
# Run benchmarks in parallel session.run's, since each benchmark
820
828
# takes an environment variable for performance logging
821
829
processes = []
822
830
for benchmark in benchmark_script_list :
823
831
process = Process (
824
832
target = session .run ,
825
833
args = ("python" , benchmark ),
826
- kwargs = {
827
- "env" : {
828
- LOGGING_NAME_ENV_VAR : "scripts/benchmark/"
829
- + os .path .basename (benchmark )
830
- }
831
- },
834
+ kwargs = {"env" : {LOGGING_NAME_ENV_VAR : benchmark .as_posix ()}},
832
835
)
833
836
process .start ()
834
837
processes .append (process )
@@ -839,7 +842,7 @@ def benchmark(session: nox.Session):
839
842
# when the environment variable is set as it is above,
840
843
# notebooks output a .bytesprocessed and .slotmillis report
841
844
# collect those reports and print a summary
842
- _print_performance_report ("scripts/" )
845
+ _print_performance_report (base_path )
843
846
844
847
845
848
def _print_performance_report (path : str ):
@@ -852,19 +855,24 @@ def _print_performance_report(path: str):
852
855
"""
853
856
print ("---BIGQUERY USAGE REPORT---" )
854
857
results_dict = {}
855
- for bytes_report in Path (path ).glob ("*/*.bytesprocessed" ):
858
+ bytes_reports = sorted (Path (path ).rglob ("*.bytesprocessed" ), key = lambda x : x .name )
859
+ for bytes_report in bytes_reports :
856
860
with open (bytes_report , "r" ) as bytes_file :
857
- filename = bytes_report .stem
861
+ filename = bytes_report .relative_to ( path ). with_suffix ( "" )
858
862
lines = bytes_file .read ().splitlines ()
859
863
query_count = len (lines )
860
864
total_bytes = sum ([int (line ) for line in lines ])
861
865
results_dict [filename ] = [query_count , total_bytes ]
862
- for millis_report in Path (path ).glob ("*/*.slotmillis" ):
866
+ os .remove (bytes_report )
867
+
868
+ millis_reports = sorted (Path (path ).rglob ("*.slotmillis" ), key = lambda x : x .name )
869
+ for millis_report in millis_reports :
863
870
with open (millis_report , "r" ) as millis_file :
864
- filename = millis_report .stem
871
+ filename = millis_report .relative_to ( path ). with_suffix ( "" )
865
872
lines = millis_file .read ().splitlines ()
866
873
total_slot_millis = sum ([int (line ) for line in lines ])
867
874
results_dict [filename ] += [total_slot_millis ]
875
+ os .remove (millis_report )
868
876
869
877
cumulative_queries = 0
870
878
cumulative_bytes = 0
0 commit comments