File size: 1,077 Bytes
504d922
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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())