#!/usr/bin/env python """Free local checks for the Handicate framework (no GPU, no model download). Verifies: config imports, every module parses, the rubric + feedback load and compose, the GRPO reward func has the right shape, and the eval gate logic is correct. Run: python test_run.py """ import ast import os import sys from pathlib import Path HERE = Path(__file__).resolve().parent sys.path.insert(0, str(HERE)) def ok(m): print(" [PASS]", m) def fail(m): print(" [FAIL]", m); sys.exit(1) def main(): print("LOCAL checks (free):") # every .py parses for p in HERE.rglob("*.py"): if p.name == "test_run.py": continue try: ast.parse(p.read_text(encoding="utf-8")) except SyntaxError as e: fail(f"{p.name} syntax error: {e}") ok("all .py modules parse") import config as C for k in ["BASE_MODEL", "JUDGE_MODEL", "ROUNDS", "ACCEPT_THRESHOLD", "EVAL_SET"]: if not hasattr(C, k): fail(f"config missing {k}") ok(f"config OK (base={C.BASE_MODEL})") # rubric + feedback compose (this is the 'requirements + examples + criticisms') from core.judge import load_rubric r = load_rubric() if "Requirements" not in r or "criticisms" not in r.lower(): fail("rubric/feedback did not compose") ok("rubric + accumulated criticisms compose") # eval-gate logic from core.evalgate import keep_round assert keep_round(0.8, 0.7) and not keep_round(0.6, 0.7), "keep_round wrong" assert keep_round(0.69, 0.7, tolerance=0.02), "tolerance wrong" ok("eval gate keep/revert logic correct") print("LOCAL checks passed.\n") print("Next: add data/eval_heldout.jsonl + data/seed_prompts.jsonl, then") print(" hf upload AmongTheCouch23/handicate-code . . --repo-type dataset") print(" hf jobs uv run -d --flavor a100-large --timeout 12h --python 3.11 -s HF_TOKEN ./jobs/run_handicate.py") if __name__ == "__main__": main()