Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion benchmark/edgebench/image_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions benchmark/tests/test_edgebench_image_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading