MCPcopy
hub / github.com/IBM/AssetOpsBench / load_scenarios

Function load_scenarios

src/evaluation/loader.py:45–75  ·  view source on GitHub ↗

Load scenarios from one or more files or directories. Supported inputs: 1. Existing JSON / JSONL scenario files. 2. A directory containing scenario subdirectories, each with ``groundtruth.txt``. For example: scenarios_data/ scenario_11/ groundtruth.txt scenario_1

(paths: Iterable[Path] | Path)

Source from the content-addressed store, hash-verified

43
44
45def load_scenarios(paths: Iterable[Path] | Path) -> list[Scenario]:
46 """Load scenarios from one or more files or directories.
47
48 Supported inputs:
49
50 1. Existing JSON / JSONL scenario files.
51 2. A directory containing scenario subdirectories, each with
52 ``groundtruth.txt``. For example:
53
54 scenarios_data/
55 scenario_11/
56 groundtruth.txt
57 scenario_12/
58 groundtruth.txt
59
60 For folder-based scenarios, the folder name becomes the scenario id and
61 ``groundtruth.txt`` becomes ``expected_answer``.
62 """
63 if isinstance(paths, (str, Path)):
64 paths = [Path(paths)]
65
66 out: list[Scenario] = []
67 for p in paths:
68 p = Path(p)
69
70 if p.is_dir():
71 out.extend(_load_scenario_dir(p))
72 else:
73 out.extend(_load_scenario_file(p))
74
75 return out
76
77
78def _load_scenario_dir(path: Path) -> list[Scenario]:

Calls 2

_load_scenario_dirFunction · 0.85
_load_scenario_fileFunction · 0.85