diff --git a/tasks/task_098/tests/grader.py b/tasks/task_098/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..8e9f99d4d7da6fb95c51af7c0aab669f41e9f1a2 --- /dev/null +++ b/tasks/task_098/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_098" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_099/tests/Dockerfile b/tasks/task_099/tests/Dockerfile index 419f7f0da9a127c9249c7ec72998e248bd77f089..ea7cd87403640ce04a7ec470e11ee754d9774db7 100644 --- a/tasks/task_099/tests/Dockerfile +++ b/tasks/task_099/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-099:v0.1.1@sha256:bbdc0225f7b4fd0b619b748d21fa7fd6086680e450f009335605b4227ce23ab0 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_099/tests/docker-compose.yaml b/tasks/task_099/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_099/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_099/tests/grader.py b/tasks/task_099/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..aa7547f02437f97023a57a8f078fa4c2f1ae3897 --- /dev/null +++ b/tasks/task_099/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_099" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_100/tests/Dockerfile b/tasks/task_100/tests/Dockerfile index a848c5a0eee7be1385cee5c2360e991d86d8c452..2427e306160ba9abd738f7a03200de43a2bd1d7b 100644 --- a/tasks/task_100/tests/Dockerfile +++ b/tasks/task_100/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-100:v0.1.1@sha256:f31d5844bc55cf997b84e2518c2a71c0daf1c09292fca7285fb42348787489b6 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_100/tests/docker-compose.yaml b/tasks/task_100/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_100/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_100/tests/grader.py b/tasks/task_100/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..710492da52486b8158f2157e79f1cb811948efc9 --- /dev/null +++ b/tasks/task_100/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_100" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_101/tests/Dockerfile b/tasks/task_101/tests/Dockerfile index 34fc1776935611b2db80b2916490fa542b0503b2..b6f41f1f69292d82c466398680745dcffec1569c 100644 --- a/tasks/task_101/tests/Dockerfile +++ b/tasks/task_101/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-101:v0.1.1@sha256:351e46f543c558cf41d5ac880353cee71632002cae6f9fabe07c543b9ae9e63e FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_101/tests/docker-compose.yaml b/tasks/task_101/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_101/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_101/tests/grader.py b/tasks/task_101/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..5601f09c1aacd3560c7b31093302ae24606ffb44 --- /dev/null +++ b/tasks/task_101/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_101" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_102/tests/Dockerfile b/tasks/task_102/tests/Dockerfile index f6980a7b1def66b99303e21fda1dea7f2f29b377..322de893560ea6d07bc8e5d78537d67c597b62c5 100644 --- a/tasks/task_102/tests/Dockerfile +++ b/tasks/task_102/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-102:v0.1.1@sha256:adaf1de19b5892112a68f14183079fe298592287c6744d336bcc08997b95b336 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_102/tests/docker-compose.yaml b/tasks/task_102/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_102/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_102/tests/grader.py b/tasks/task_102/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..ee2c90a3f3968bee4f2d7217c8a4dc4a38947f66 --- /dev/null +++ b/tasks/task_102/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_102" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_103/tests/Dockerfile b/tasks/task_103/tests/Dockerfile index 941136b543d55bafe0fac69b8119d16f099ff19c..922a8a87dc2ac047dbe97f663786bcecf419beae 100644 --- a/tasks/task_103/tests/Dockerfile +++ b/tasks/task_103/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-103:v0.1.1@sha256:f5aee22839b572d8edf7c7884c1473cca47f07ee681bd11309ad3fd71d26c6dc FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_103/tests/docker-compose.yaml b/tasks/task_103/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_103/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_103/tests/grader.py b/tasks/task_103/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..740c001ec8b65cd8e0a93f6d255da2989cb19d66 --- /dev/null +++ b/tasks/task_103/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_103" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_104/tests/Dockerfile b/tasks/task_104/tests/Dockerfile index 5f5ec833c5640785a15655440847b3494c17e092..0a3b68e89eb6143a223b198e331538543540dbdf 100644 --- a/tasks/task_104/tests/Dockerfile +++ b/tasks/task_104/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-104:v0.1.1@sha256:4e3e0fbde6106146ebadaecb511695588c4e06dec6a71b0bfac4c8de994bd2bc FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_104/tests/docker-compose.yaml b/tasks/task_104/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_104/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_104/tests/grader.py b/tasks/task_104/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..a029d93cc60981470a44b9053ceb545d5b8a1d01 --- /dev/null +++ b/tasks/task_104/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_104" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_105/tests/Dockerfile b/tasks/task_105/tests/Dockerfile index 89ce876d44e90e2cd701c6288cdf9e8ebb3f48c9..19bbc8395d914bf733ef27af0c8de7f7ab072083 100644 --- a/tasks/task_105/tests/Dockerfile +++ b/tasks/task_105/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-cpp-task-105:v0.1.1@sha256:4e96032a9972da65b1146cc41f8332bda8b16276b7ebf50db8287d5d7a434a96 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_105/tests/docker-compose.yaml b/tasks/task_105/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_105/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_105/tests/grader.py b/tasks/task_105/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..5f9dbe43d32a0b9c2650639d703239a65ebe20bf --- /dev/null +++ b/tasks/task_105/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_105" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_106/tests/Dockerfile b/tasks/task_106/tests/Dockerfile index 0f2648449cd4b15b2cd1e24f4329b6faa9e3cb7b..fe903887f3360ff59888e40495f534160f43599d 100644 --- a/tasks/task_106/tests/Dockerfile +++ b/tasks/task_106/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-106:v0.1.1@sha256:2c7ddddb4e5595efd5421461fffab8a15fd94618104523a27a6f3bbba6e71a26 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_106/tests/docker-compose.yaml b/tasks/task_106/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_106/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_106/tests/grader.py b/tasks/task_106/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..52e39659209b2b121b6c4c10a05ecf46b4b50a9e --- /dev/null +++ b/tasks/task_106/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_106" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_107/tests/Dockerfile b/tasks/task_107/tests/Dockerfile index 0cb43ef17c11f543a0cbd6fc00bef86cc8950827..2af83a47e9393008ce33935c082d9979b929a229 100644 --- a/tasks/task_107/tests/Dockerfile +++ b/tasks/task_107/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-107:v0.1.1@sha256:1a5c67f1817c05b93066b554f6b83f498f73f1b610ee8ea13507c0b475e96bfd FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_107/tests/docker-compose.yaml b/tasks/task_107/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_107/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_107/tests/grader.py b/tasks/task_107/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..18d85e22d047d47e429e4f7cb71fd582fd142faa --- /dev/null +++ b/tasks/task_107/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_107" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_108/tests/Dockerfile b/tasks/task_108/tests/Dockerfile index 99937e72fbd8c26f59d564fd69b402feb0c07a9a..8ac8341609c154cc9fa6a0109a070146ea2d68dd 100644 --- a/tasks/task_108/tests/Dockerfile +++ b/tasks/task_108/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-108:v0.1.1@sha256:8db765c589aa1c821ac3e5cde3dc2f13dadf41c35132bda6e7ee121254e8f73a FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_108/tests/docker-compose.yaml b/tasks/task_108/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_108/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_108/tests/grader.py b/tasks/task_108/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..9d0d2720bd0f3de85359b4c49267b4aa1d67f0e4 --- /dev/null +++ b/tasks/task_108/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_108" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_109/tests/Dockerfile b/tasks/task_109/tests/Dockerfile index 6a8b86f3e057dbd0ecc9159eb7dafc84aa7fc1e0..c6714b5be8e2310da064a617cf58c74814fdef7b 100644 --- a/tasks/task_109/tests/Dockerfile +++ b/tasks/task_109/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-109:v0.1.1@sha256:b8c2d6a3e9d319f7cb3294afe63976c1bad693e90e7d01980eb7c0c4720cb545 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_109/tests/docker-compose.yaml b/tasks/task_109/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_109/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_109/tests/grader.py b/tasks/task_109/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..5ee2d655ff18e23e9ba618e6c7d49f461d8f71dd --- /dev/null +++ b/tasks/task_109/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_109" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_110/tests/Dockerfile b/tasks/task_110/tests/Dockerfile index bab04984c1361058abf1410725cb7356374f7a61..cecb5da296d5e936bde6a40072ed78080e400518 100644 --- a/tasks/task_110/tests/Dockerfile +++ b/tasks/task_110/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-110:v0.1.1@sha256:c0a222690f44ab8ca6aebb45094ece6132c681a7e907f912ab730803fb3f2f34 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_110/tests/docker-compose.yaml b/tasks/task_110/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_110/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_110/tests/grader.py b/tasks/task_110/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..1f689f9d3ca0d390061d0e7cd31418c00701669d --- /dev/null +++ b/tasks/task_110/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_110" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_111/tests/Dockerfile b/tasks/task_111/tests/Dockerfile index f791e9f0c3871199056b79c87721585ad1bad1e8..847aff9f29080ae06058461a614070a1735fb456 100644 --- a/tasks/task_111/tests/Dockerfile +++ b/tasks/task_111/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-111:v0.1.1@sha256:d1f89ef44d00ba6a6d86fbd9c38160846d3925cfd06982d4d11f745c2e43d4e6 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_111/tests/docker-compose.yaml b/tasks/task_111/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_111/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_111/tests/grader.py b/tasks/task_111/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..42b7e21f55aaa4860e0964298667995b9096feec --- /dev/null +++ b/tasks/task_111/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_111" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_112/tests/Dockerfile b/tasks/task_112/tests/Dockerfile index ee200e3b3833d760d3a696faccce63a24efd22a0..492f9b173e1878c8aa64ed09118d98736196a609 100644 --- a/tasks/task_112/tests/Dockerfile +++ b/tasks/task_112/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-112:v0.1.1@sha256:ef1e5aac750fc5146793f1e1410b13fb6219a12acac82405f51cbb34194c4cee FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_112/tests/docker-compose.yaml b/tasks/task_112/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_112/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_112/tests/grader.py b/tasks/task_112/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..76c811ecf3c6c4fa4d09dc50214a47e99c616f33 --- /dev/null +++ b/tasks/task_112/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_112" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_113/tests/Dockerfile b/tasks/task_113/tests/Dockerfile index 8912d9c016a30d37c0cc4d02f7e3f35af9710969..f33bb81f1801f1b9856df7f6ce7536d2e7993715 100644 --- a/tasks/task_113/tests/Dockerfile +++ b/tasks/task_113/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-113:v0.1.1@sha256:5ace611a3ae59ae06d6bb2a4b4de17b1c38f57bf50a1f5096e8c6947dce5d758 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_113/tests/docker-compose.yaml b/tasks/task_113/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_113/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_113/tests/grader.py b/tasks/task_113/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..55781e7f51daec393b7e2fc28f04ee095479cb4c --- /dev/null +++ b/tasks/task_113/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_113" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_114/tests/Dockerfile b/tasks/task_114/tests/Dockerfile index 6ecc6bb3e6e4776f0f78c8d6cf5f2f913c155943..1dbe3baa4cb2801335a85852a3ba8c595c0a17a7 100644 --- a/tasks/task_114/tests/Dockerfile +++ b/tasks/task_114/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-114:v0.1.1@sha256:61dde7a057773f55e54e42b3806cbfa9f958e12bd722fd4b267e630c84e7e6fa FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_114/tests/docker-compose.yaml b/tasks/task_114/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_114/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_114/tests/grader.py b/tasks/task_114/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..e453b521f8160262dd1c68b3bd77e63a6ad21cf3 --- /dev/null +++ b/tasks/task_114/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_114" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_115/tests/Dockerfile b/tasks/task_115/tests/Dockerfile index be28ca4e6ea9d840dc56cb6bdf6697acab649937..b7b49a16f25d00e8238bf646cd7e7015919e358b 100644 --- a/tasks/task_115/tests/Dockerfile +++ b/tasks/task_115/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-115:v0.1.1@sha256:1b16ce929f12ec92e01fef2775b3ab0d9d96346c3b1a8362ab9559fecc4871f0 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_115/tests/docker-compose.yaml b/tasks/task_115/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_115/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_115/tests/grader.py b/tasks/task_115/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..7a15d763793b9a33c742bdd9894735a566bfb900 --- /dev/null +++ b/tasks/task_115/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_115" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_116/tests/Dockerfile b/tasks/task_116/tests/Dockerfile index b7a2ff772b27f21d196f7b2f03557b98d2e53dcb..a5aa4b170d5e03d74a18ea151dbadeaa30e44463 100644 --- a/tasks/task_116/tests/Dockerfile +++ b/tasks/task_116/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-116:v0.1.1@sha256:18362993ba38c4a6981c386934b43733bdf13d5d3792b5952b3762ff420be98e FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_116/tests/docker-compose.yaml b/tasks/task_116/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_116/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_116/tests/grader.py b/tasks/task_116/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..d3b2dc855ab636db0e36d11499716d7dd8e27b9e --- /dev/null +++ b/tasks/task_116/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_116" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_117/tests/Dockerfile b/tasks/task_117/tests/Dockerfile index f208d3534b0540b240c6a5c476560e6bf0ff88db..75da46bbfab434a1e0dbeca729865f68b99e54e3 100644 --- a/tasks/task_117/tests/Dockerfile +++ b/tasks/task_117/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-117:v0.1.1@sha256:5c9d6aac4d7a4480cb2591fea878ea1d6c323bdd0571f2a0b9d88bbe3d0474b9 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_117/tests/docker-compose.yaml b/tasks/task_117/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_117/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_117/tests/grader.py b/tasks/task_117/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..b282729155c245b960f078bd7783e5788b8bba75 --- /dev/null +++ b/tasks/task_117/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_117" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_118/tests/Dockerfile b/tasks/task_118/tests/Dockerfile index 806c384b043d2e80838ec34b4aca049d3b0055e2..955e992526afd14602fc78060d85b6f78e47cb4d 100644 --- a/tasks/task_118/tests/Dockerfile +++ b/tasks/task_118/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-118:v0.1.1@sha256:d9d994d83ed59efa74d512e9306ed84d990a37a00d7ce444e2b6738b124914fd FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_118/tests/docker-compose.yaml b/tasks/task_118/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_118/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_118/tests/grader.py b/tasks/task_118/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..d6fa80323d7488597a6882b7d03678fec0ff9b3b --- /dev/null +++ b/tasks/task_118/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_118" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tasks/task_119/tests/Dockerfile b/tasks/task_119/tests/Dockerfile index 5d579025d51db34263913253ed1b8915d866855f..48591108a2420b20f7105d88a16e1a3f9412b3b3 100644 --- a/tasks/task_119/tests/Dockerfile +++ b/tasks/task_119/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-119:v0.1.1@sha256:2e5b8b443c3eb07bc0d543ee9d65e2565b3d6e0cd9e3193043e0f9c221ca4d2f FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_119/tests/docker-compose.yaml b/tasks/task_119/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_119/tests/docker-compose.yaml @@ -0,0 +1,7 @@ +services: + main: + volumes: + - type: bind + source: ./grader.py + target: /tests/grader.py + read_only: true diff --git a/tasks/task_119/tests/grader.py b/tasks/task_119/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..f85710a159d6e72dbb17afd983deaad0b7655488 --- /dev/null +++ b/tasks/task_119/tests/grader.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +from __future__ import annotations + +import json +import os +import subprocess +import sys +import xml.etree.ElementTree as ET +from pathlib import Path + + +TASK_ID = "task_119" +TASK_ROOT = Path("/app") / TASK_ID +LOG_ROOT = Path("/logs/verifier") +LOG_ROOT.mkdir(parents=True, exist_ok=True) +env = os.environ.copy() +env.update( + { + "SCI_BENCH_TASK_ID": TASK_ID, + "SCI_BENCH_TASK_DIR": str(TASK_ROOT), + "PYTHONPATH": f"{TASK_ROOT}:{TASK_ROOT / 'source'}", + } +) + + +def execute(command: list[str], cwd: Path) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + cwd=cwd, + env=env, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + check=False, + ) + + +public = execute([sys.executable, "reproduce.py"], TASK_ROOT) +junit = LOG_ROOT / "junit.xml" +# Private tests are a task-owned directory. Their filenames are intentionally +# unconstrained; pytest discovers every supported test module recursively. +private = execute( + [ + sys.executable, + "-m", + "pytest", + "-q", + f"--junitxml={junit}", + "/tests/private_tests", + ], + TASK_ROOT, +) + +private_total = private_passed = private_failed = 0 +if junit.is_file(): + root = ET.parse(junit).getroot() + suites = [root] if root.tag == "testsuite" else root.findall(".//testsuite") + private_total = sum(int(suite.attrib.get("tests", "0")) for suite in suites) + private_failed = sum( + int(suite.attrib.get("failures", "0")) + + int(suite.attrib.get("errors", "0")) + for suite in suites + ) + private_passed = max(private_total - private_failed, 0) + +reward = int(public.returncode == 0 and private.returncode == 0) +summary = { + "reward": reward, + "task_id": TASK_ID, + "public": { + "passed": int(public.returncode == 0), + "collected": 1, + "return_code": public.returncode, + }, + "private": { + "passed": private_passed, + "collected": private_total, + "failed": private_failed, + "return_code": private.returncode, + }, +} +(LOG_ROOT / "reward.json").write_text(json.dumps(summary, indent=2) + "\n") +(LOG_ROOT / "reward.txt").write_text(f"{reward:.1f}\n") +(LOG_ROOT / "ctrf.json").write_text( + json.dumps( + { + "reportFormat": "CTRF", + "specVersion": "0.0.0", + "results": { + "summary": { + "tests": private_total, + "passed": private_passed, + "failed": private_failed, + }, + "tests": [], + }, + }, + indent=2, + ) + + "\n" +) +combined = ( + "== public ==\n" + + (public.stdout or "") + + "\n== private ==\n" + + (private.stdout or "") +) +(LOG_ROOT / "test-stdout.txt").write_text(combined) +(LOG_ROOT / "run.log").write_text(combined) +print(json.dumps(summary, sort_keys=True)) diff --git a/tools/materialize.py b/tools/materialize.py index 0925c2ed1e99e32b74dc1bd7edbc909ba9f6dc52..3df6b3e92d34d1454a267958fccb5678ec350363 100644 --- a/tools/materialize.py +++ b/tools/materialize.py @@ -142,6 +142,8 @@ def main() -> int: "environment/Dockerfile", "tests/Dockerfile", "tests/test.sh", + "tests/grader.py", + "tests/docker-compose.yaml", ): path = source / relative if path.is_file():