File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33The input file is the output of the following command:
44pytest -vv --durations=0 --durations-min=0.001 > report.txt
55"""
6+ import re
67from pathlib import Path
78import pandas as pd
89import sys
2021start_index = all_lines .index (start_line ) + 1
2122
2223last_index = next (index for index , line in enumerate (all_lines [start_index :]) if "===" in line ) + start_index
23- #last_index = all_lines.index(last_line)
2424
25- timing_info = all_lines [start_index :last_index ]
25+ # Pytest 8.4+ appends a blank line and a "(N durations < Xs hidden.)" footer
26+ # inside the slowest-durations block. Keep only true duration rows shaped like
27+ # "0.123s call test_x.py::test_name".
28+ duration_line_re = re .compile (r"^\d+\.\d+s\s+(call|setup|teardown)\s" )
29+ timing_info = [line for line in all_lines [start_index :last_index ] if duration_line_re .match (line )]
2630timing_column = [float (line .split ("s" )[0 ].rstrip ()) for line in timing_info ]
2731type = [line .split ("s" )[1 ].rstrip () for line in timing_info ]
2832short_name = [line .rpartition ('::' )[2 ] for line in timing_info ]
Original file line number Diff line number Diff line change 4545 time_taken_list .append (time_taken )
4646
4747 for time in time_taken_list :
48- import_time_threshold = 3.0 # Most of the times is sub-second but there outliers
48+ # TODO: lower this back toward 3.0 s once the Windows runner outliers are diagnosed.
49+ import_time_threshold = 6.0
4950 if time >= import_time_threshold :
5051 exceptions .append (
5152 f"Importing { import_statement } took: { time :.2f} s. Should be <: { import_time_threshold } s."
5253 )
5354 break
5455
55-
5656 if time_taken_list :
5757 avg_time = sum (time_taken_list ) / len (time_taken_list )
5858 std_time = math .sqrt (sum ((x - avg_time ) ** 2 for x in time_taken_list ) / len (time_taken_list ))
6565 f"Importing { import_statement } took: { avg_time :.2f} s in average. Should be <: { import_time_threshold } s."
6666 )
6767
68+ # This is displayed to GITHUB_STEP_SUMMARY. Print it before raising so the
69+ # per-sample table is available even when the average threshold is exceeded.
70+ print (markdown_output )
71+
6872if exceptions :
6973 raise Exception ("\n " .join (exceptions ))
70-
71- # This is displayed to GITHUB_STEP_SUMMARY
72- print (markdown_output )
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ metrics = [
123123
124124test_core = [
125125 " pandas<3" ,
126- " pytest<8.4.0 " ,
126+ " pytest" ,
127127 " psutil" ,
128128
129129 # for github test : probeinterface and neo from master
@@ -154,7 +154,7 @@ test_preprocessing = [
154154
155155
156156test = [
157- " pytest<8.4.0 " ,
157+ " pytest" ,
158158 " pytest-cov" ,
159159 " psutil" ,
160160
You can’t perform that action at this time.
0 commit comments