@@ -184,7 +184,12 @@ def read_jsonl_rows_for_commit(path: str, commit_id: str) -> pd.DataFrame:
184184
185185
186186def read_latest_baseline_rows (path : str , pr : pd .DataFrame ) -> pd .DataFrame :
187- """Read rows from the latest history commit matching the PR benchmark."""
187+ """Read rows from the latest history commit matching the PR benchmark.
188+
189+ A benchmark can be new to the PR workflow and therefore have no baseline
190+ yet. Return an empty frame with the PR schema in that case so the report
191+ can show the measurements without comparison.
192+ """
188193
189194 pr_identities = set (benchmark_identity_rows (pr )["benchmark_identity" ])
190195 if not pr_identities :
@@ -202,7 +207,7 @@ def read_latest_baseline_rows(path: str, pr: pd.DataFrame) -> pd.DataFrame:
202207 baseline_commit_id = commit_id
203208
204209 if baseline_commit_id is None :
205- raise ValueError ( "No baseline rows found for the benchmark under test" )
210+ return pr . iloc [ 0 : 0 ]. copy ( )
206211
207212 return read_jsonl_rows_for_commit (path , baseline_commit_id )
208213
@@ -230,7 +235,7 @@ def select_latest_baseline_rows(base: pd.DataFrame, pr: pd.DataFrame) -> pd.Data
230235 matches = base_identities [base_identities ["benchmark_identity" ].isin (pr_identities )]
231236 matches = matches [matches ["commit_id" ].notna ()]
232237 if matches .empty :
233- raise ValueError ( "No baseline rows found for the benchmark under test" )
238+ return base . iloc [ 0 : 0 ]. copy ( )
234239
235240 baseline_commit_id = matches ["commit_id" ].iloc [- 1 ]
236241 return base [base ["commit_id" ] == baseline_commit_id ].copy ()
@@ -256,6 +261,7 @@ def normalize_measurement_rows(df: pd.DataFrame) -> pd.DataFrame:
256261 columns = ["engine" , "file_format" , "query" ],
257262 index = df .index ,
258263 )
264+ df ["query" ] = pd .array (df ["query" ], dtype = "Int64" )
259265 return df
260266
261267
@@ -914,11 +920,11 @@ def main() -> None:
914920 title = format_title (benchmark_name , pr )
915921 base = read_latest_baseline_rows (sys .argv [1 ], pr )
916922
917- base_commit_id = set (base ["commit_id" ].unique ())
923+ base_commit_ids = set (base ["commit_id" ].unique ())
918924 pr_commit_id = set (pr ["commit_id" ].unique ())
919- assert len (base_commit_id ) == 1 , base_commit_id
925+ assert len (base_commit_ids ) <= 1 , base_commit_ids
920926 assert len (pr_commit_id ) == 1 , pr_commit_id
921- base_commit_id = next (iter (base_commit_id ) )
927+ base_commit_id = next (iter (base_commit_ids ), None )
922928 pr_commit_id = next (iter (pr_commit_id ))
923929
924930 base_file_sizes , base = split_file_size_rows (base )
@@ -990,13 +996,17 @@ def main() -> None:
990996 if summary_fields :
991997 print ("<br>" .join (summary_fields ))
992998 print ("" )
999+ if base_commit_id is None :
1000+ print ("_No baseline is available for this benchmark yet; PR measurements are shown without comparison._" )
1001+ print ("" )
9931002 if verdict is not None or engine_summary is not None :
9941003 print (format_report_help ())
9951004 print ("" )
9961005 print ("---" )
9971006 print ("" )
9981007
9991008 grouped_tables = df3 .groupby (["engine" , "file_format" , "unit" ], dropna = False , sort = False )
1009+ base_label = str (base_commit_id )[:8 ] if base_commit_id is not None else "none"
10001010 for engine , file_format , unit in sorted (grouped_tables .groups .keys (), key = group_sort_key ):
10011011 group_df = grouped_tables .get_group ((engine , file_format , unit )).sort_values ("name" )
10021012 group_performance = format_performance (
@@ -1014,7 +1024,7 @@ def main() -> None:
10141024 for name , ratio in zip (group_df ["name" ], group_df ["ratio" ])
10151025 ],
10161026 f"PR { pr_commit_id [:8 ]} ({ unit } )" : group_df ["value_pr" ].map (format_measurement_value ),
1017- f"base { base_commit_id [: 8 ] } ({ unit } )" : group_df ["value_base" ].map (format_measurement_value ),
1027+ f"base { base_label } ({ unit } )" : group_df ["value_base" ].map (format_measurement_value ),
10181028 "ratio (PR/base)" : group_df ["ratio" ].map (format_comparison_ratio ),
10191029 }
10201030 )
0 commit comments