-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcases.py
More file actions
30 lines (21 loc) · 789 Bytes
/
Copy pathcases.py
File metadata and controls
30 lines (21 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import annotations
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parent
CASE_DIR = ROOT / "cases"
def list_case_names() -> list[str]:
return sorted(path.stem for path in CASE_DIR.glob("*.json"))
def load_case(name: str) -> dict:
path = CASE_DIR / f"{name}.json"
if not path.exists():
raise FileNotFoundError(f"benchmark case not found: {path}")
with path.open("r", encoding="utf-8") as fh:
return json.load(fh)
def backend_case_names(backend_name: str) -> list[str]:
names: list[str] = []
for name in list_case_names():
case = load_case(name)
backend = case.get("backends", {}).get(backend_name, {})
if backend.get("supported"):
names.append(name)
return names