MCPcopy Create free account
hub / github.com/NVIDIA/SOL-ExecBench / _load_example

Function _load_example

tests/examples/test_examples.py:153–166  ·  view source on GitHub ↗

Load definition, solution, and workloads from an example directory.

(
    language: str, problem: str, solution_file: str
)

Source from the content-addressed store, hash-verified

151
152
153def _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
169def _run_subprocess(cmd: list[str], cwd: Path) -> subprocess.CompletedProcess:

Callers 1

test_exampleFunction · 0.85

Calls 3

DefinitionClass · 0.90
SolutionClass · 0.90
WorkloadClass · 0.90

Tested by

no test coverage detected