| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| import sys | |
| ROOT_DIR = Path(__file__).resolve().parents[1] | |
| if str(ROOT_DIR) not in sys.path: | |
| sys.path.insert(0, str(ROOT_DIR)) | |
| import pandas as pd | |
| def main() -> int: | |
| parser = argparse.ArgumentParser(description="Export compact run report from output files") | |
| parser.add_argument("--results-dir", required=True) | |
| args = parser.parse_args() | |
| root = Path(args.results_dir) | |
| ranking = pd.read_csv(root / "final_ranking.csv") if (root / "final_ranking.csv").exists() else pd.DataFrame() | |
| summary = json.loads((root / "summary.json").read_text(encoding="utf-8")) if (root / "summary.json").exists() else {} | |
| report = { | |
| "results_dir": str(root), | |
| "top5": ranking.head(5).to_dict(orient="records"), | |
| "summary": summary, | |
| } | |
| out = root / "report_compact.json" | |
| out.write_text(json.dumps(report, indent=2), encoding="utf-8") | |
| print(json.dumps(report, indent=2)) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |