Run evaluation on each case and return the list of results.
(
case_ids: list[str],
gt_dir: Path,
agent_dir: Path,
tolerance: float,
llm_model: Any | None,
master: MasterData | None,
)
| 1315 | |
| 1316 | |
| 1317 | def _run_evaluation_loop( |
| 1318 | case_ids: list[str], |
| 1319 | gt_dir: Path, |
| 1320 | agent_dir: Path, |
| 1321 | tolerance: float, |
| 1322 | llm_model: Any | None, |
| 1323 | master: MasterData | None, |
| 1324 | ) -> list[dict]: |
| 1325 | """Run evaluation on each case and return the list of results.""" |
| 1326 | results = [] |
| 1327 | for idx, case_id in enumerate(case_ids, 1): |
| 1328 | gt_file = gt_dir / case_id / "Postprocessing_Data.json" |
| 1329 | agent_file = agent_dir / case_id / "Postprocessing_Data.json" |
| 1330 | |
| 1331 | if not gt_file.exists(): |
| 1332 | results.append( |
| 1333 | { |
| 1334 | "case_id": case_id, |
| 1335 | "status": "ERROR", |
| 1336 | "error": "Ground truth file not found", |
| 1337 | } |
| 1338 | ) |
| 1339 | print( |
| 1340 | f" [{idx}/{len(case_ids)}] {case_id}: ERROR (no ground truth)" |
| 1341 | ) |
| 1342 | continue |
| 1343 | if not agent_file.exists(): |
| 1344 | results.append( |
| 1345 | { |
| 1346 | "case_id": case_id, |
| 1347 | "status": "ERROR", |
| 1348 | "error": "Agent output file not found", |
| 1349 | } |
| 1350 | ) |
| 1351 | print( |
| 1352 | f" [{idx}/{len(case_ids)}] {case_id}: ERROR (no agent output)" |
| 1353 | ) |
| 1354 | continue |
| 1355 | |
| 1356 | result = evaluate_case( |
| 1357 | case_id, gt_file, agent_file, tolerance, llm_model, master |
| 1358 | ) |
| 1359 | results.append(result) |
| 1360 | |
| 1361 | status_icon = "PASS" if result["all_correct"] else "FAIL" |
| 1362 | llm_tag = "" |
| 1363 | if result.get("llm_verdict"): |
| 1364 | llm_tag = f" [{result['llm_verdict']['verdict']}]" |
| 1365 | detail = "" |
| 1366 | if not result["all_correct"]: |
| 1367 | detail = f" ({', '.join(result['mismatches'][:2])})" |
| 1368 | print( |
| 1369 | f" [{idx}/{len(case_ids)}] {case_id}: {status_icon}{llm_tag}{detail}" |
| 1370 | ) |
| 1371 | |
| 1372 | return results |
| 1373 | |
| 1374 |
no test coverage detected