Load definition, solution, and workloads from an example directory.
(
language: str, problem: str, solution_file: str
)
| 151 | |
| 152 | |
| 153 | def _load_example( |
| 154 | language: str, problem: str, solution_file: str |
| 155 | ) -> tuple[Definition, Solution, list[Workload]]: |
| 156 | """Load definition, solution, and workloads from an example directory.""" |
| 157 | example_dir = _EXAMPLES_DIR / language / problem |
| 158 | definition = Definition(**json.loads((example_dir / "definition.json").read_text())) |
| 159 | sol_dict = json.loads((example_dir / solution_file).read_text()) |
| 160 | solution = Solution(**sol_dict) |
| 161 | workloads = [ |
| 162 | Workload(**json.loads(line)) |
| 163 | for line in (example_dir / "workload.jsonl").read_text().splitlines() |
| 164 | if line.strip() |
| 165 | ] |
| 166 | return definition, solution, workloads |
| 167 | |
| 168 | |
| 169 | def _run_subprocess(cmd: list[str], cwd: Path) -> subprocess.CompletedProcess: |
no test coverage detected