File size: 1,550 Bytes
4882451
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""Do-nothing sanity check: an empty answer should score 0 on deterministic tasks."""
import json
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "environment" / "src"))
from binary_reasoning_v1.grading import grade_item, needs_judge  # noqa: E402


def resolve_path():
    if len(sys.argv) > 1:
        return Path(sys.argv[1])
    for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
        if p.exists():
            return p
    raise SystemExit("no sample JSONL found; pass one as argv[1]")


def load_rows(path):
    rows = []
    for line in path.read_text(encoding="utf-8").splitlines():
        if line.strip():
            rows.append(json.loads(line))
    return rows


def main():
    path = resolve_path()
    rows = load_rows(path)
    passed = failed = skipped = 0
    fails = []
    for row in rows:
        fam = row.get("family", "")
        ans = row.get("answer")
        if needs_judge(fam, ans):
            skipped += 1
            continue
        score = grade_item(fam, "", ans)
        if score == 0.0:
            passed += 1
        else:
            failed += 1
            fails.append((row.get("id"), fam, score))
    print(f"file={path}")
    print(f"summary: do_nothing pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
    for f in fails[:10]:
        print("FAIL", *f)
    return 0 if failed == 0 else 1


if __name__ == "__main__":
    raise SystemExit(main())