Add do-nothing sanity check
Browse files#!/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())
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Do-nothing sanity check: an empty answer should score 0 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 grade_item, needs_judge # 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 main():
|
| 30 |
+
path = resolve_path()
|
| 31 |
+
rows = load_rows(path)
|
| 32 |
+
passed = failed = skipped = 0
|
| 33 |
+
fails = []
|
| 34 |
+
for row in rows:
|
| 35 |
+
fam = row.get("family", "")
|
| 36 |
+
ans = row.get("answer")
|
| 37 |
+
if needs_judge(fam, ans):
|
| 38 |
+
skipped += 1
|
| 39 |
+
continue
|
| 40 |
+
score = grade_item(fam, "", ans)
|
| 41 |
+
if score == 0.0:
|
| 42 |
+
passed += 1
|
| 43 |
+
else:
|
| 44 |
+
failed += 1
|
| 45 |
+
fails.append((row.get("id"), fam, score))
|
| 46 |
+
print(f"file={path}")
|
| 47 |
+
print(f"summary: do_nothing pass={passed}/{passed + failed} fail={failed} skipped_judge={skipped}")
|
| 48 |
+
for f in fails[:10]:
|
| 49 |
+
print("FAIL", *f)
|
| 50 |
+
return 0 if failed == 0 else 1
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
raise SystemExit(main())
|
| 55 |
+
Add do-nothing sanity check
|