ECG-EdgeBench / scripts /finalize_evidence.py
LianeMarilin's picture
Publish ECG-EdgeBench validated task sample
b99b565 verified
Raw History Blame Contribute Delete
2.25 kB
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import json
from pathlib import Path
import shutil
ROOT = Path(__file__).resolve().parents[1]
START = ">>>>> Start Structured Result"
END = ">>>>> End Structured Result"
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--run-dir", type=Path, required=True)
args = parser.parse_args()
data = args.run_dir / "data" if (args.run_dir / "data").is_dir() else args.run_dir
provenance = json.loads((data / "provenance.json").read_text(encoding="utf-8"))
raw = (args.run_dir / "baseline-output.txt").read_text(encoding="utf-8")
baseline = json.loads(raw.split(START, 1)[1].split(END, 1)[0].strip())
evidence = ROOT / "provenance"
evidence.mkdir(parents=True, exist_ok=True)
shutil.copyfile(data / "provenance.json", evidence / "data_build_provenance.json")
report = {
"status": "PASS" if baseline.get("valid") and baseline.get("pass_rate") == 1.0 else "FAIL",
"experiment": "starter baseline trained on all DS1 beats and evaluated once on hidden DS2 labels",
"environment": {
"numpy": "1.26.4",
"scipy": "1.12.0",
"scikit_learn": "1.4.2",
"pandas": "2.2.3",
"wfdb": "4.1.2"
},
"data": {
"train_beats": provenance["splits"]["train"]["beats"],
"test_beats": provenance["splits"]["test"]["beats"],
"train_class_counts": provenance["splits"]["train"]["class_counts"],
"test_class_counts": provenance["splits"]["test"]["class_counts"],
"source_files": len(provenance["files"]),
"array_sha256": {
**provenance["splits"]["train"]["array_sha256"],
**provenance["splits"]["test"]["array_sha256"]
}
},
"result": baseline,
"qualification_boundary": "One real baseline run proves executability and score headroom, not 12-hour frontier-agent difficulty or official EdgeBench acceptance."
}
(ROOT / "baseline_report.json").write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
return 0
if __name__ == "__main__":
raise SystemExit(main())