Download evaluation/src/helixbench/cli.py from NoizAI/Helixbench: direct link, hf CLI and curl.
- Browser
- Download file 3.09 kB
-
https://huggingface.co/datasets/NoizAI/Helixbench/resolve/main/evaluation/src/helixbench/cli.py
- Command line
-
hf download hf://datasets/NoizAI/Helixbench/evaluation/src/helixbench/cli.py
-
curl -L -o cli.py https://huggingface.co/datasets/NoizAI/Helixbench/resolve/main/evaluation/src/helixbench/cli.py
3.09 kB
| """Command line interface for one-model Helixbench runs.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from . import __version__ | |
| from .inputs import COHORT_SHA256, frozen_rows, prepare, sha256, validate_prepared | |
| from .pipeline import METRICS, run | |
| from .report import aggregate, calculate | |
| def parser() -> argparse.ArgumentParser: | |
| command = argparse.ArgumentParser(prog="helixbench", description="Six fixed Helixbench metrics") | |
| command.add_argument("--version", action="version", version=__version__) | |
| sub = command.add_subparsers(dest="command", required=True) | |
| p = sub.add_parser("prepare", help="Validate the 1015 generated/GT media and freeze manifests") | |
| p.add_argument("--generated", type=Path, required=True) | |
| p.add_argument("--gt", type=Path, help="Optional if using packaged GT features") | |
| p.add_argument("--model-id", required=True) | |
| p.add_argument("--run-dir", type=Path, required=True) | |
| p = sub.add_parser("run", help="Run one or all six metric stages") | |
| p.add_argument("--run-dir", type=Path, required=True) | |
| p.add_argument("--metric", choices=("all", *METRICS), default="all") | |
| p.add_argument("--deps-root", type=Path, required=True) | |
| p.add_argument("--weights-root", type=Path, required=True) | |
| p.add_argument("--torch-home", type=Path, required=True) | |
| p.add_argument("--frame-workers", type=int, default=8) | |
| p = sub.add_parser("aggregate", help="Check coverage and emit exactly six scores") | |
| p.add_argument("--run-dir", type=Path, required=True) | |
| p = sub.add_parser("verify", help="Recalculate an existing six-score report") | |
| p.add_argument("--run-dir", type=Path, required=True) | |
| sub.add_parser("verify-package", help="Verify the frozen cohort and packaged engine hashes") | |
| return command | |
| def main() -> None: | |
| args = parser().parse_args() | |
| if args.command == "prepare": | |
| print(json.dumps(prepare(args.generated, args.gt, args.run_dir, args.model_id), ensure_ascii=False)) | |
| elif args.command == "run": | |
| run(args.run_dir, args.metric, args.deps_root, args.weights_root, args.torch_home, args.frame_workers) | |
| elif args.command == "aggregate": | |
| report = aggregate(args.run_dir) | |
| print(json.dumps({key: value["value"] for key, value in report["metrics"].items()}, ensure_ascii=False)) | |
| elif args.command == "verify": | |
| expected = json.loads((args.run_dir / "REPORT.json").read_text()) | |
| actual = calculate(args.run_dir) | |
| if expected != actual: | |
| raise ValueError("Stored report differs from recalculated six-metric result") | |
| complete = json.loads((args.run_dir / "COMPLETE.json").read_text()) | |
| if complete["report_sha256"] != sha256(args.run_dir / "REPORT.json"): | |
| raise ValueError("REPORT.json SHA256 differs from COMPLETE.json") | |
| print("Helixbench report verified") | |
| elif args.command == "verify-package": | |
| from .provenance import verify_package | |
| print(json.dumps(verify_package(), ensure_ascii=False)) | |
| if __name__ == "__main__": | |
| main() | |