From 2806ec2608d1c8ffacfb17e05d5cda9d6e08be6c Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Tue, 10 Nov 2026 04:56:26 +0800 Subject: [PATCH] fix(benchmark): count cyclic receipts without changing literal matching Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- benchmark/edgebench/image_inventory.py | 10 +++++++++- benchmark/tests/test_edgebench_image_inventory.py | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/benchmark/edgebench/image_inventory.py b/benchmark/edgebench/image_inventory.py index e7000c741f..d442fefb15 100644 --- a/benchmark/edgebench/image_inventory.py +++ b/benchmark/edgebench/image_inventory.py @@ -4,7 +4,9 @@ import argparse from collections import Counter, defaultdict +from itertools import chain import json +import os from pathlib import Path import re @@ -25,7 +27,13 @@ def inventory(log_dirs, *, task=None): root = log_dir.resolve(strict=True) if not root.is_dir(): raise ValueError(f"Expected an EdgeBench log directory: {root}") - for path in root.glob("runs/*/*/runtime-receipt.json"): + # Preserve literal matching, adding links omitted by older pathlib. + literal_paths = root.glob("runs/*/*/runtime-receipt.json") + linked_paths = ( + path for path in root.glob("runs/*/*/*") + if path.name == "runtime-receipt.json" and os.path.islink(path) + ) + for path in chain(literal_paths, linked_paths): case_id = path.parent.name if task is not None and case_id != task: continue diff --git a/benchmark/tests/test_edgebench_image_inventory.py b/benchmark/tests/test_edgebench_image_inventory.py index 6d734b3d32..ca4b9f9a6e 100644 --- a/benchmark/tests/test_edgebench_image_inventory.py +++ b/benchmark/tests/test_edgebench_image_inventory.py @@ -83,6 +83,19 @@ def write(relative, task): assert result["unreadable_receipts"] == 0 +def test_inventory_retains_literal_receipt_lookup_on_the_filesystem(tmp_path, capsys): + receipt = tmp_path / "runs" / "run" / "case" / "RUNTIME-RECEIPT.JSON" + receipt.parent.mkdir(parents=True) + receipt.write_text(json.dumps({"task": "case"})) + # Retain each runtime's existing literal-glob matching for readable files. + literal_matches = list(tmp_path.glob("runs/*/*/runtime-receipt.json")) + + main(["--log-dir", str(tmp_path)]) + result = json.loads(capsys.readouterr().out) + assert [row["task"] for row in result["cases"]] == (["case"] if literal_matches else []) + assert result["unreadable_receipts"] == 0 + + def test_preflight_looks_up_each_required_image_once_and_keeps_missing_image_gate(tmp_path): pytest.importorskip("sforge") pytest.importorskip("harbor")