Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def score(unit, dir, transcript, answer, verified=None):
if not verified:
return {"reward": 0.0, "passed": False, "detail": {"why": "the instance's tests did not run"}}
log = os.path.join(verified["dir"], "test-stdout.txt")
with open(os.path.join(verified["dir"], "model.patch")) as f:
with open(os.path.join(verified["dir"], "model.patch"), encoding="utf-8", errors="replace") as f:
patch = f.read()
report = get_eval_report(make_test_spec(row(unit)), {"instance_id": unit, "model_patch": patch or None}, log, True)
with open(os.path.join(verified["dir"], "report.json"), "w") as f:
Expand Down
4 changes: 3 additions & 1 deletion app/nullius/catalogue/benchmarks/terminal-bench/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ def setup(unit, dir):
**({"internet": True} if unit in INTERNET else {}),
**({"agent_seconds": agent} if agent else {}), # the task's own agent timeout, not the run's
"prepare": PREPARE,
"verify": {"copy": {f"{unit}/tests": "/tests"}, "run": ["bash", "/tests/test.sh"], "collect": LOGS,
"verify": {"copy": {f"{unit}/tests": "/tests"},
"run": ["bash", "-c", f"rm -f {LOGS}/reward.txt {LOGS}/reward.json && exec bash /tests/test.sh"],
"collect": LOGS,
"seconds": (t.get("verifier") or {}).get("timeout_sec") or 900, "network": True,
**({"keep_processes": True} if unit in KEEP_PROCESSES else {})}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{"entry": "task.toml", "setting": "environment.gpus", "values": "0 for every task", "default": "0",
"nullius": "fixed:0 - no task asks for one"},
{"entry": "task.toml", "setting": "environment.allow_internet", "values": "true for every task", "default": "true",
"nullius": "fixed:false for the agent - its only way out is its model, through the relay; the tests get a network after it ends; said in the limitations"},
"nullius": "fixed:per-task - public internet for the 38 tasks in the driver's INTERNET list during the agent or reference solution; the other 51 keep only their model route; the tests get a network after it ends"},
{"entry": "harbor run", "setting": "--override-cpus/-memory/-storage/-gpus, -e (docker, daytona, modal ...)", "values": "", "default": "none, docker",
"nullius": "not offered - where and on what the container runs, not what is measured; the standard's backends are local and docker"}
]
23 changes: 23 additions & 0 deletions app/tests/test_standard_check_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,29 @@ def test_a_service_task_keeps_its_processes_and_the_rest_do_not(self):
self.assertIs(self.setup_of("hf-model-inference")["verify"]["keep_processes"], True)
self.assertIs(self.setup_of("install-windows-3.11")["verify"]["keep_processes"], True)

def test_a_reward_left_by_the_agent_does_not_count(self):
logs = os.path.join(self.tmp, "verifier")
os.makedirs(logs)
script = os.path.join(self.tmp, "test.sh")
step = self.setup_of("regex-log")["verify"]
command = step["run"][-1].replace(step["collect"], logs).replace("/tests/test.sh", script)
for tests, expected in (("exit 1\n", 0.0), (f"echo 1 > {logs}/reward.txt\n", 1.0)):
with self.subTest(tests=tests):
for name in ("reward.txt", "reward.json"):
with open(os.path.join(logs, name), "w") as f:
f.write("1\n")
with open(script, "w") as f:
f.write(tests)
checked = subprocess.run([*step["run"][:-1], command], capture_output=True, timeout=30)
self.assertEqual(checked.returncode, 1 if expected == 0 else 0)
self.assertFalse(os.path.exists(os.path.join(logs, "reward.json")))
request = {"op": "score", "unit": "regex-log", "dir": self.tmp,
"transcript": [], "answer": "", "verified": {"dir": logs}}
scored = subprocess.run(["python3", os.path.join(TB, "driver.py")],
input=json.dumps(request) + "\n", capture_output=True, text=True, check=True)
result = json.loads(scored.stdout)
self.assertEqual((result["reward"], result["passed"]), (expected, bool(expected)))

def test_all_tasks_have_image_pins_and_only_downloading_tasks_get_internet(self):
data = runpy.run_path(os.path.join(TB, "driver.py"), run_name="metadata")
self.assertEqual((len(data["ALL"]), len(data["INTERNET"]), len(data["OFFLINE"])), (89, 38, 51))
Expand Down
14 changes: 7 additions & 7 deletions app/tests/test_swebench_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ def test_missing_patch_is_not_treated_as_a_submission(self):
self.driver.score("unit", str(self.root), [], "", verified={"dir": self.driver.RESULTS})
self.grade.assert_not_called()

def test_change_in_another_encoding_is_still_scored(self):
(self.repo / "edit").write_bytes(b"caf\xe9\n")
patch = self.capture()
self.assertIn(b"caf\xe9", patch.read_bytes())
self.driver.score("unit", str(self.root), [], "", verified={"dir": self.driver.RESULTS})
self.assertTrue(self.grade.call_args.args[1]["model_patch"])


class ProCheck(unittest.TestCase):
"""SWE-bench Pro's check on a made-up task folder: its upstream's capture first, the patch in the collected
Expand Down Expand Up @@ -209,10 +216,3 @@ def test_check_tells_the_jvm_of_the_proxy_it_is_given(self):
self.assertEqual((self.repo / "jvm").read_text(),
f"-Xmx1g -Dhttp.proxyHost={host} -Dhttp.proxyPort={port} -Dhttps.proxyHost={host} -Dhttps.proxyPort={port} "
"-Daether.connector.http.useSystemProperties=true")

def test_change_in_another_encoding_is_still_scored(self):
(self.repo / "edit").write_bytes(b"caf\xe9\n")
patch = self.capture()
self.assertIn(b"caf\xe9", patch.read_bytes())
self.driver.score("unit", str(self.root), [], "", verified={"dir": self.driver.RESULTS})
self.assertTrue(self.grade.call_args.args[1]["model_patch"])