MCPcopy Index your code
hub / github.com/IBM/AssetOpsBench / write_reports_dir

Function write_reports_dir

src/evaluation/report.py:148–170  ·  view source on GitHub ↗

Write one JSON file per result (`` .json``) plus an aggregate. Results without a ``run_id`` fall back to `` .json`` so nothing is dropped. Returns the directory path.

(report: EvalReport, reports_dir: Path)

Source from the content-addressed store, hash-verified

146
147
148def write_reports_dir(report: EvalReport, reports_dir: Path) -> Path:
149 """Write one JSON file per result (``<run_id>.json``) plus an aggregate.
150
151 Results without a ``run_id`` fall back to ``<scenario_id>.json`` so
152 nothing is dropped. Returns the directory path.
153 """
154 reports_dir = Path(reports_dir)
155 reports_dir.mkdir(parents=True, exist_ok=True)
156
157 used: dict[str, int] = {}
158 for r in report.results:
159 stem = r.run_id or f"scenario-{r.scenario_id}"
160 suffix = used.get(stem, 0)
161 used[stem] = suffix + 1
162 name = stem if suffix == 0 else f"{stem}-{suffix}"
163 (reports_dir / f"{name}.json").write_text(
164 r.model_dump_json(indent=2), encoding="utf-8"
165 )
166
167 (reports_dir / _AGGREGATE_FILENAME).write_text(
168 report.model_dump_json(indent=2), encoding="utf-8"
169 )
170 return reports_dir
171
172
173def render_summary(report: EvalReport) -> str:

Calls 1

getMethod · 0.45