Add validated Krea2 eval recorder
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) in sys.path:
|
||||
sys.path.remove(str(ROOT))
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
import krea2_eval_log # noqa: E402
|
||||
|
||||
|
||||
def _load_entry(path: Path) -> dict:
|
||||
with path.open("r", encoding="utf-8") as handle:
|
||||
data = json.load(handle)
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError("entry JSON must contain one object")
|
||||
return data
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Validate and append one durable Krea2 fixed-seed eval entry.")
|
||||
parser.add_argument("--entry-json", required=True, help="Path to a JSON object containing one eval entry.")
|
||||
parser.add_argument("--log-path", default=str(krea2_eval_log.DEFAULT_EVAL_LOG_PATH), help="Eval log path to update.")
|
||||
parser.add_argument("--dry-run", action="store_true", help="Validate without writing the log.")
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
entry = _load_entry(Path(args.entry_json))
|
||||
log = krea2_eval_log.append_entry(entry, path=args.log_path, dry_run=args.dry_run)
|
||||
except Exception as exc:
|
||||
print(f"error: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
action = "validated" if args.dry_run else "recorded"
|
||||
print(f"{action}: {entry.get('id')} ({len(log.get('entries') or [])} entries)")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user