Return a sorted list of problem directories under *benchmark_dir*. Each problem directory must contain definition.json and workload.jsonl. If *categories* is given (e.g. ["L1", "L2"]), only those sub-directories are searched.
(
benchmark_dir: Path, categories: list[str] | None = None
)
| 51 | |
| 52 | |
| 53 | def discover_problems( |
| 54 | benchmark_dir: Path, categories: list[str] | None = None |
| 55 | ) -> list[Path]: |
| 56 | """Return a sorted list of problem directories under *benchmark_dir*. |
| 57 | |
| 58 | Each problem directory must contain definition.json and workload.jsonl. |
| 59 | If *categories* is given (e.g. ["L1", "L2"]), only those sub-directories are searched. |
| 60 | """ |
| 61 | if categories: |
| 62 | roots = [benchmark_dir / c for c in categories] |
| 63 | else: |
| 64 | roots = sorted( |
| 65 | p for p in benchmark_dir.iterdir() if p.is_dir() and p.name in CATEGORIES |
| 66 | ) |
| 67 | |
| 68 | problems = [] |
| 69 | for root in roots: |
| 70 | if not root.is_dir(): |
| 71 | continue |
| 72 | for problem_dir in sorted(root.iterdir()): |
| 73 | defn = problem_dir / "definition.json" |
| 74 | wkl = problem_dir / "workload.jsonl" |
| 75 | if defn.exists() and wkl.exists(): |
| 76 | problems.append(problem_dir) |
| 77 | return problems |
| 78 | |
| 79 | |
| 80 | # --------------------------------------------------------------------------- |