Download scripts/validate_u2_schema.py from u2bench-anon/u2-bench-code-review: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/u2bench-anon/u2-bench-code-review/resolve/main/scripts/validate_u2_schema.py
- Command line
-
hf download hf://u2bench-anon/u2-bench-code-review/scripts/validate_u2_schema.py
-
curl -L -o validate_u2_schema.py https://huggingface.co/u2bench-anon/u2-bench-code-review/resolve/main/scripts/validate_u2_schema.py
1.1 kB
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| REQUIRED = ("qhash", "question", "gold_answer") | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--input", required=True, help="Path to non-STEM QA JSONL file") | |
| args = ap.parse_args() | |
| path = Path(args.input) | |
| if not path.exists(): | |
| raise SystemExit(f"Input file does not exist: {path}") | |
| n = 0 | |
| with path.open("r", encoding="utf-8", errors="ignore") as f: | |
| for i, line in enumerate(f, 1): | |
| s = line.strip() | |
| if not s: | |
| continue | |
| n += 1 | |
| try: | |
| obj = json.loads(s) | |
| except Exception as exc: # noqa: BLE001 | |
| raise SystemExit(f"Line {i} is not valid JSON: {exc}") from exc | |
| missing = [k for k in REQUIRED if k not in obj] | |
| if missing: | |
| raise SystemExit(f"Line {i} missing fields: {missing}") | |
| print(f"OK: {n} rows validated with fields {REQUIRED}") | |
| if __name__ == "__main__": | |
| main() | |