v0.2.7 documentation and local-preview scorer: participant steps with a manifest template; organiser procedure split out; publish_consent wording says a merge publishes the row, the manifest and the predictions file; score_entry.py v4 accepts publish_consent=false as a local preview; SHA256SUMS regenerated. Data, scorer, rows and splits unchanged.
1d525c8 Download score_entry.py from AxisMeru/nyayasiddhi: direct link, hf CLI and curl.
- Browser
- Download file 6.85 kB
-
https://huggingface.co/datasets/AxisMeru/nyayasiddhi/resolve/main/score_entry.py
- Command line
-
hf download hf://datasets/AxisMeru/nyayasiddhi/score_entry.py
-
curl -L -o score_entry.py https://huggingface.co/datasets/AxisMeru/nyayasiddhi/resolve/main/score_entry.py
6.85 kB
| #!/usr/bin/env python3 | |
| """NyayaSiddhi self-serve scorer (Track A, 17 Oct 2026; #687). Run it from the PUBLIC release bundle (the Hugging Face dataset AxisMeru/nyayasiddhi: data/, schema674/, scorer/, submission680/): CPU only, standard library plus jsonschema, no model call, no network, no secret, no organiser access. | |
| python score_entry.py --bundle BUNDLE_DIR --dir SUBMISSION_DIR [--out-dir NEW_OR_EMPTY_DIR] [--expect-sha256 HEX] | |
| SUBMISSION_DIR holds exactly manifest.json and predictions.jsonl (see submission680/SUBMISSION_PATH_680.md). Steps, each printed: (1) the organisers' submission check (layout, schema, every item of the split exactly once, split pinned by sha256, prediction file sha256, n_error, consent); (2) the organisers' scorer re-run on your predictions with your manifest's error mapping; (3) a preview of the numbers: false_proof and coverage for ALL and each family, each with k, n and the exact 95% Clopper-Pearson interval. | |
| The preview is YOUR number from the public scorer. It is NOT a published row: a published row also needs the organisers' re-score by a second person, the contamination flag and two readers of the status word. It carries no rank and no composite score.""" | |
| import argparse, hashlib, json, re, sys, tempfile | |
| from pathlib import Path | |
| ap = argparse.ArgumentParser(); ap.add_argument("--bundle", required=True); ap.add_argument("--dir", required=True); ap.add_argument("--out-dir"); ap.add_argument("--expect-sha256"); a = ap.parse_args() | |
| B = Path(a.bundle).resolve(); D = Path(a.dir).resolve() | |
| sys.path[:0] = [str(B / "schema674"), str(B / "scorer"), str(B / "submission680")] | |
| import validate_674 as V # noqa: E402 | |
| import s6_scorer # noqa: E402 | |
| import check_submission as C # noqa: E402 | |
| def main(): | |
| items_dir = B / "data" | |
| # publish_consent=false: the organisers' check refuses it because consent gates a MERGE, not a score. Nothing is uploaded by this script, so a | |
| # private self-score runs: the check sees a throw-away copy of the manifest with consent true; the score, the receipt and the printed lines use | |
| # the real manifest, and the preview says plainly that this entry could not be submitted as it stands. | |
| try: man0 = json.loads((D / "manifest.json").read_text()) | |
| except Exception: man0 = None | |
| # the throw-away layout is built from the manifest's own names, so they are checked FIRST (R2 21 Oct: "../x" or "a/b" would have written outside the temp dir before the schema ran): both must be plain names, else the REAL directory is checked and fails normally | |
| safe = lambda s: isinstance(s, str) and re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._+-]{0,63}", s) is not None and ".." not in s | |
| local_only = isinstance(man0, dict) and man0.get("publish_consent") is False and safe(man0.get("system_name")) and safe(man0.get("system_version")) | |
| with tempfile.TemporaryDirectory() as ct: | |
| chk_dir = D | |
| if local_only: | |
| chk_dir = Path(ct) / str(man0.get("system_name")) / str(man0.get("system_version")); chk_dir.mkdir(parents=True); (chk_dir / "manifest.json").write_text(json.dumps({**man0, "publish_consent": True})); (chk_dir / "predictions.jsonl").write_bytes((D / "predictions.jsonl").read_bytes()) | |
| print("NOTE publish_consent is false: scoring as a LOCAL PREVIEW only. Nothing is uploaded; this entry cannot be submitted as a pull request until publish_consent is true.") | |
| errs, rec = C.check(chk_dir, items_dir) | |
| for e in errs: print("FAIL", e) | |
| print("SUBMISSION CHECK:", "FAIL" if errs else "OK"); | |
| if errs: return 1 | |
| man = json.loads((D / "manifest.json").read_text()); pfile = D / "predictions.jsonl" | |
| items, e = V.load_split(items_dir, man["benchmark_version"], man["split"], V.RELEASED_SHA256) | |
| if items is None: print("FAIL", "; ".join(e)); return 1 | |
| with tempfile.TemporaryDirectory() as t: | |
| ip, ap_ = Path(t) / "items.jsonl", Path(t) / "arm.jsonl" | |
| ip.write_text("".join(json.dumps(x) + "\n" for x in items)) | |
| ap_.write_text("".join(json.dumps({"item_id": r["item_id"], "outcome": "ERROR" if r.get("error") is True else r["verdict"]}) + "\n" for r in V.lines(pfile))) | |
| tab = s6_scorer.score(ip, {"A": ap_})["arms"]["A"] | |
| as_proof = man["error_mapping"] == "error_counted_as_proof"; rows = [] | |
| for g, b in [("ALL", tab["pooled"])] + sorted(tab["by_family"].items()): | |
| fp, cv = b["false_proof"], b["coverage"] | |
| k_fp, k_cv = (fp["worst_case_k"], cv["worst_case_k"]) if as_proof else (fp["k"], cv["k"]) | |
| for name, k, n in (("false_proof", k_fp, fp["n"]), ("coverage", k_cv, cv["n"])): | |
| lo, hi = V.cp_interval(k, n) if n else (None, None) | |
| rows.append({"group": g, "name": name, "k": k, "n": n, "ci_low": lo, "ci_high": hi, "interval_method": "clopper-pearson-exact", "interval_level": 0.95}) | |
| prev = {"status": "self-scored preview (NOT a published row)" + ("; LOCAL PREVIEW: publish_consent is false, so this entry cannot be submitted as it stands" if local_only else ""), "benchmark_version": man["benchmark_version"], "split": man["split"], "error_mapping": man["error_mapping"], "system_name": man.get("system_name"), "system_version": man.get("system_version"), "metrics": rows} | |
| for r in rows: print(f"{r['group']:8} {r['name']:12} k={r['k']} n={r['n']} 95% CI [{r['ci_low']}, {r['ci_high']}]") | |
| print("This is a self-scored preview from the public scorer. Not a published row; no rank, no composite score.") | |
| print("These items are public, so this is a development figure.") | |
| text = json.dumps(prev, indent=1, sort_keys=True) + "\n"; psha = hashlib.sha256(text.encode()).hexdigest() | |
| print("preview sha256:", psha) | |
| if a.out_dir: | |
| od = Path(a.out_dir); od.mkdir(parents=True, exist_ok=True) | |
| if any(od.iterdir()): print("FAIL out-dir is not empty"); return 1 | |
| sh = lambda p: hashlib.sha256(Path(p).read_bytes()).hexdigest() | |
| (od / "score_preview.json").write_text(text) | |
| receipt = {"scorer_sha256": sh(B / "scorer" / "s6_scorer.py"), "validator_sha256": sh(B / "schema674" / "validate_674.py"), "item_file_sha256": sh(items_dir / (man["split"] + ".jsonl")), "predictions_sha256": sh(pfile), "manifest_sha256": sh(D / "manifest.json"), "preview_sha256": psha, "command": "python score_entry.py --bundle BUNDLE --dir SUBMISSION_DIR --out-dir OUT_DIR"} # no timestamp, no host name: the same inputs give the same bytes anywhere | |
| (od / "score_receipt.json").write_text(json.dumps(receipt, indent=1, sort_keys=True) + "\n") | |
| if a.expect_sha256: | |
| same = a.expect_sha256.strip().lower() == psha; print("REPRODUCES: your preview equals the sha256 an organiser published." if same else "DIFFERS: your preview does not equal the published sha256 (a dispute worth raising)."); return 0 if same else 2 | |
| return 0 | |
| sys.exit(main()) | |