Skip to content

Commit 952f759

Browse files
authored
Fix lookup of benchmark after rename/removal (#140)
1 parent d6a8ac1 commit 952f759

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

asv_runner/process_results.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ def build_new_rows(input_path: Path, skip_shas: set[str], added_date: str):
100100
columns = results["result_columns"]
101101
timestamp = dt.datetime.fromtimestamp(results["date"] / 1000)
102102
for name, benchmark in results["results"].items():
103+
if name not in benchmark_to_param_names:
104+
# benchmarks.json reflects only the latest benchmarked commit;
105+
# older or concurrently-pushed result files can reference names
106+
# that have since been renamed or removed in pandas.
107+
print(
108+
f"Skipping {name!r} for {commit_hash}: "
109+
"not in current benchmarks.json."
110+
)
111+
continue
103112
data = dict(zip(columns, benchmark))
104113
result = data["result"]
105114
param_names = benchmark_to_param_names[name]

tests/test_process_results.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,29 @@ def test_build_new_rows_respects_skip_shas(tmp_path: Path) -> None:
289289
assert set(df["sha"]) == {"keepme"}
290290

291291

292+
def test_build_new_rows_skips_benchmarks_missing_from_benchmarks_json(
293+
tmp_path: Path,
294+
) -> None:
295+
_write_benchmarks(
296+
tmp_path,
297+
{"version": "1.0", "bench.known": {"param_names": ["a"]}},
298+
)
299+
_write_result(
300+
tmp_path,
301+
"deadbeef",
302+
dt.datetime(2024, 1, 1),
303+
{
304+
"bench.known": [[1.0], [["1"]]],
305+
"bench.renamed_away": [[2.0], [["1"]]],
306+
},
307+
)
308+
309+
df = build_new_rows(tmp_path, skip_shas=set(), added_date="2024-01-02")
310+
311+
assert set(df["name"]) == {"bench.known"}
312+
assert len(df) == 1
313+
314+
292315
def test_build_new_rows_empty_when_no_result_files(tmp_path: Path) -> None:
293316
_write_benchmarks(
294317
tmp_path,

0 commit comments

Comments
 (0)