S3RL4 commited on
Commit
81c3cc6
·
verified ·
1 Parent(s): a089e9d

Remove bad folder (ndjson test)

Browse files
verification_kit/gold.py/verification_kit/gold.py DELETED
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Gold-answer sanity check: built-in gold replies should score 1 on deterministic tasks."""
3
- import json
4
- import sys
5
- from pathlib import Path
6
-
7
- ROOT = Path(__file__).resolve().parents[1]
8
- sys.path.insert(0, str(ROOT / "environment" / "src"))
9
- from binary_reasoning_v1.grading import _answer_symbol, grade_item, needs_judge, norm_symbol # noqa: E402
10
-
11
-
12
- def resolve_path():
13
- if len(sys.argv) > 1:
14
- return Path(sys.argv[1])
15
- for p in (ROOT / "sample_free.jsonl", ROOT / "environment/src/binary_reasoning_v1/items.jsonl"):
16
- if p.exists():
17
- return p
18
- raise SystemExit("no sample JSONL found; pass one as argv[1]")
19
-
20
-
21
- def load_rows(path):
22
- rows = []
23
- for line in path.read_text(encoding="utf-8").splitlines():
24
- if line.strip():
25
- rows.append(json.loads(line))
26
- return rows
27
-
28
-
29
- def parse_json_answer(ans):
30
- if isinstance(ans, dict):
31
- return ans
32
- if isinstance(ans, str):
33
- try:
34
- obj = json.loads(ans)
35
- if isinstance(obj, dict):
36
- return obj
37
- except Exception:
38
- pass
39
- return {}
40
-
41
-
42
- def gold_reply(row):
43
- fam = row.get("family", "")
44
- ans = row.get("answer")
45
- if fam == "func_id_mc" and isinstance(ans, dict):
46
- opts = ans.get("options", [])
47
- correct = norm_symbol(ans.get("correct", ""))
48
- for i, opt in enumerate(opts[:4]):
49
- if norm_symbol(opt) == correct:
50
- return "ABCD"[i]
51
- return str(ans.get("correct", ""))
52
- if fam == "toolchain_fp" and isinstance(ans, dict):
53
- return "\n".join(str(s) for s in ans.get("toolchain_strings", []))
54
- if fam == "crossarch_equivalence":
55
- obj = parse_json_answer(ans)
56
- if bool(obj.get("same")):
57
- return f"Same function: {obj.get('symbol', '')}"
58
- return "Not the same."
59
- sym = _answer_symbol(ans)
60
- return str(sym or ans or "")
61
-
62
-
63
- def main():
64
- path = resolve_path()
65
- rows = load_rows(path)
66
- passed = failed = skipped = 0
67
- fails = []
68
- for row in rows:
69
- fam = row.get("family", "")
70
- ans = row.get("answer")
71
- if needs_judge(fam, ans):
72
- skipped += 1
73
- continue
74
- score = grade_item(fam, gold_reply(row), ans)
75
- if score == 1.0:
76
- passed += 1
77
- else:
78
- failed += 1
79
- fails.append((row.get("id"), fam, score))
80
- print(f"file={path}")
81
- print(f"summary: gold pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
82
- for f in fails[:10]:
83
- print("FAIL", *f)
84
- return 0 if failed == 0 else 1
85
-
86
-
87
- if __name__ == "__main__":
88
- raise SystemExit(main())
89
- Add gold-answer sanity check