diff --git a/tasks/task_027/tests/Dockerfile b/tasks/task_027/tests/Dockerfile index e820b7e788f477078ed4450a3dee220d3d07d77d..3996e4c52e703dbc0ed20aa2cd2b35206dd487a1 100644 --- a/tasks/task_027/tests/Dockerfile +++ b/tasks/task_027/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-027:v0.1.1@sha256:7553e8b9d60ddba9b86ee74d4f200929dfaed195b79a7e29efa3713f93e5a656 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_027/tests/docker-compose.yaml b/tasks/task_027/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_027/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_027/tests/grader.py b/tasks/task_027/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..c151ea9e186d51f93ccc0eb953180aa4240e106f --- /dev/null +++ b/tasks/task_027/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_027" +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_028/tests/Dockerfile b/tasks/task_028/tests/Dockerfile index b1d8b9c7e9174a44d18dfd810277b5df3ee55f94..9d579f5607484c7b8e2cc85453f26d0eec851efd 100644 --- a/tasks/task_028/tests/Dockerfile +++ b/tasks/task_028/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-028:v0.1.1@sha256:4c4ec965b94251ab9b163fe1294a4e863dc5a2b0a005dabb51dbaa5a5d6c95fe FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_028/tests/docker-compose.yaml b/tasks/task_028/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_028/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_028/tests/grader.py b/tasks/task_028/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..c467d04e037b7b469aaf7404bfae489380a9c2b1 --- /dev/null +++ b/tasks/task_028/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_028" +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_029/tests/Dockerfile b/tasks/task_029/tests/Dockerfile index 0aba4a2eb5ebe80ca7951e73070d9ba4e6e4adad..e39bccaec7d2002afac78fd20befdd46b162984d 100644 --- a/tasks/task_029/tests/Dockerfile +++ b/tasks/task_029/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-029:v0.1.1@sha256:bf60c02145e60447a42aa0e8205c11851bafae01fb38da1969c8ca9697ab119f FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_029/tests/docker-compose.yaml b/tasks/task_029/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_029/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_029/tests/grader.py b/tasks/task_029/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..97d1da2def1df836d5dab53ac9141e0b5109b304 --- /dev/null +++ b/tasks/task_029/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_029" +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_030/tests/Dockerfile b/tasks/task_030/tests/Dockerfile index bf046058e39e19c42df8e3a51e329624177ddaa8..68fabf69563fd0f64027be121eee5aa3fbfdc17d 100644 --- a/tasks/task_030/tests/Dockerfile +++ b/tasks/task_030/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-030:v0.1.1@sha256:a7a1ebc4f0d09c76072fd97d407d581348c92def2eb9cf4414cbca7a2d2175de FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_030/tests/docker-compose.yaml b/tasks/task_030/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_030/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_030/tests/grader.py b/tasks/task_030/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..091695b18edff5d9d5608e78253c1622a9e9c35e --- /dev/null +++ b/tasks/task_030/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_030" +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_031/tests/Dockerfile b/tasks/task_031/tests/Dockerfile index 49c6c0b3e1e3ba869303ffb6dcc69e1ed025448b..75df1ff409a02e07d7261c134a10f17a048f996d 100644 --- a/tasks/task_031/tests/Dockerfile +++ b/tasks/task_031/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-031:v0.1.1@sha256:76dd16524e2f8d46d8a4dc15f04b0c00d856be316fe9480271332ae20cac59f6 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_031/tests/docker-compose.yaml b/tasks/task_031/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_031/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_031/tests/grader.py b/tasks/task_031/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..fa7b0e22570f080c82347ca7081674a750c420dc --- /dev/null +++ b/tasks/task_031/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_031" +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_032/tests/Dockerfile b/tasks/task_032/tests/Dockerfile index c342403ad69efbce47bbc98c1185033b92e4ffd1..3682c75034e1a6ec8e3f62d3a34d2e2cedbed84a 100644 --- a/tasks/task_032/tests/Dockerfile +++ b/tasks/task_032/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-032:v0.1.1@sha256:c75faed022ffcf7321fcfc415227da35e38287acd1304c3cdf6fa487f6b8c2dd FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_032/tests/docker-compose.yaml b/tasks/task_032/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_032/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_032/tests/grader.py b/tasks/task_032/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..4bf1e97b2e442880654cbbb7cbe9b756a486f3a6 --- /dev/null +++ b/tasks/task_032/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_032" +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_033/tests/Dockerfile b/tasks/task_033/tests/Dockerfile index f06acc7bcdc12c9cbfde2b6ee486137745262acf..33b472b6580e39ea570b714d9472cc5b517f3428 100644 --- a/tasks/task_033/tests/Dockerfile +++ b/tasks/task_033/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-033:v0.1.1@sha256:6dc7b560ea513f6160f7c57f10d097acc966df297e37e71f466e132810369295 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_033/tests/docker-compose.yaml b/tasks/task_033/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_033/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_033/tests/grader.py b/tasks/task_033/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..34c08347dde4f34ce9f14fcfe77b02b53829395c --- /dev/null +++ b/tasks/task_033/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_033" +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_034/tests/Dockerfile b/tasks/task_034/tests/Dockerfile index 8503a2b35e7344a487c6ec19e1e48bf33311345c..a2bbe990e2835a7e3b26f9c70a6d6a89ce83c701 100644 --- a/tasks/task_034/tests/Dockerfile +++ b/tasks/task_034/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-034:v0.1.1@sha256:05bcfc247e7ddf648bb2c176a6a51e0044fe3e262fb1520291c13384074fdaa7 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_034/tests/docker-compose.yaml b/tasks/task_034/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_034/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_034/tests/grader.py b/tasks/task_034/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..1ccf015709cc554b75ce38debe0a17306731461e --- /dev/null +++ b/tasks/task_034/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_034" +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_035/tests/Dockerfile b/tasks/task_035/tests/Dockerfile index a7679c9be7f4334fd0844b33187b4ddaf5d2f340..389a3ed7ea9c2decf088c0d23eca0851b8903736 100644 --- a/tasks/task_035/tests/Dockerfile +++ b/tasks/task_035/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-035:v0.1.1@sha256:3f5829a8aac0f18cc8716f569d96154613a115e082be984153eedf0e81afdc8a FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_035/tests/docker-compose.yaml b/tasks/task_035/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_035/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_035/tests/grader.py b/tasks/task_035/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..6d8d40e474bd3b000c45b518ab63fb930196cd13 --- /dev/null +++ b/tasks/task_035/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_035" +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_036/tests/Dockerfile b/tasks/task_036/tests/Dockerfile index 7eab4b4542fa30c2531acc544cf569c06e869607..95d7b33454a9d54e838b5c9e1841ad69059163b4 100644 --- a/tasks/task_036/tests/Dockerfile +++ b/tasks/task_036/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-036:v0.1.1@sha256:97009f66b48e65e82d8e706d3e07eadded40d4918020554f7a9886708786dd69 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_036/tests/docker-compose.yaml b/tasks/task_036/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_036/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_036/tests/grader.py b/tasks/task_036/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..d67c6c47b8f69b805c59d4b12f1d207cb313b69c --- /dev/null +++ b/tasks/task_036/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_036" +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_037/tests/Dockerfile b/tasks/task_037/tests/Dockerfile index 8b1491e6ccb369bbfecde3a537c21f584936721a..a1c15587d006ca3733150df0d832c16f1ebf9898 100644 --- a/tasks/task_037/tests/Dockerfile +++ b/tasks/task_037/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-037:v0.1.1@sha256:c796741230bb4ab445d45895f095d69787bd4539b73918856d1ad79488bac7e3 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_037/tests/docker-compose.yaml b/tasks/task_037/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_037/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_037/tests/grader.py b/tasks/task_037/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..d5f62e3c1e4227eb17d597500f3f6bed5c2374aa --- /dev/null +++ b/tasks/task_037/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_037" +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_038/tests/Dockerfile b/tasks/task_038/tests/Dockerfile index 90e631b150679a97ab00ae331e50c627b3262bcf..21d2cde9d2eee512862afeb51fefec2253b13c74 100644 --- a/tasks/task_038/tests/Dockerfile +++ b/tasks/task_038/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-c-task-038:v0.1.1@sha256:4bb7c29ed433773c37de68bad0e425e75710b6709e0beec1b63f0f3691539643 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_038/tests/docker-compose.yaml b/tasks/task_038/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_038/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_038/tests/grader.py b/tasks/task_038/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..5ed970218751112d5657c2cce1580f0c72e68688 --- /dev/null +++ b/tasks/task_038/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_038" +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_039/tests/Dockerfile b/tasks/task_039/tests/Dockerfile index 9266e8df76e2cab3eb448fe75dc195b84be37425..a2c475e9446b68671e81767cf2284398d6ef20bc 100644 --- a/tasks/task_039/tests/Dockerfile +++ b/tasks/task_039/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-039:v0.1.1@sha256:1533cb3577d15acdc7fd3b1f755f8c4ec80fbb528b7bcb6bcf918c6559f20e4a FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_039/tests/docker-compose.yaml b/tasks/task_039/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_039/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_039/tests/grader.py b/tasks/task_039/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..7409b10c80ccd9689266c09e3675d8275b5cac3b --- /dev/null +++ b/tasks/task_039/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_039" +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_040/tests/Dockerfile b/tasks/task_040/tests/Dockerfile index d96bd626975bcefab652ba4c509b25debfc44d6d..3b4f14da271ef30d8c88a79b28e5b0825327a670 100644 --- a/tasks/task_040/tests/Dockerfile +++ b/tasks/task_040/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-040:v0.1.1@sha256:65832254b48e4b1777a7d1d07680a2a870de87c697b47ff8d0c27a516f95ad46 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_040/tests/docker-compose.yaml b/tasks/task_040/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_040/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_040/tests/grader.py b/tasks/task_040/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..bac54c9e6afbd6c56795586656a9b2c578e2a9b3 --- /dev/null +++ b/tasks/task_040/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_040" +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_041/tests/Dockerfile b/tasks/task_041/tests/Dockerfile index fee6a013cbe33177c2938dc9e637e1a85f205eb5..ee24000cbdb161c9b64daafe148b9645f831f800 100644 --- a/tasks/task_041/tests/Dockerfile +++ b/tasks/task_041/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-041:v0.1.1@sha256:89c3b061bcb5d19a2b28722e4c8a1a5c2435e8641d4cdc2f2ffbd565bc48ff10 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_041/tests/docker-compose.yaml b/tasks/task_041/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_041/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_041/tests/grader.py b/tasks/task_041/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..3fdfb45fbc3e0a0cefc98a00c7187ca8cf472076 --- /dev/null +++ b/tasks/task_041/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_041" +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_042/tests/Dockerfile b/tasks/task_042/tests/Dockerfile index c77cb1ef81b50f86f5b54cbf75944cc1e4eeaabe..1f54172030bbfd26aa29c76b341906856d371f47 100644 --- a/tasks/task_042/tests/Dockerfile +++ b/tasks/task_042/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-042:v0.1.1@sha256:2d3c7dba05b8ca04b80900872baa59a5f3bc42d765e80ed58aa917bf0126c512 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_042/tests/docker-compose.yaml b/tasks/task_042/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_042/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_042/tests/grader.py b/tasks/task_042/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..653a8ee49b3637d22358758af4a2c5b3c7adbacc --- /dev/null +++ b/tasks/task_042/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_042" +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_043/tests/Dockerfile b/tasks/task_043/tests/Dockerfile index 49e43ea373f989f6b504997ebe5a43f94b4722a0..878cc092c707e38b1188013faad017dfebfe54ad 100644 --- a/tasks/task_043/tests/Dockerfile +++ b/tasks/task_043/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-043:v0.1.1@sha256:84e2a692b8b83060583de8fca377a153136ba35bd01e40d4ff4e61fe116e2472 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_043/tests/docker-compose.yaml b/tasks/task_043/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_043/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_043/tests/grader.py b/tasks/task_043/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..05d2ef29c44cd58ffed40e44d4151e1eda0fc7e1 --- /dev/null +++ b/tasks/task_043/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_043" +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_044/tests/Dockerfile b/tasks/task_044/tests/Dockerfile index 61dad61a6690649c334994ff49ff498a6f76e6c9..a32e2e60ec1f31834fed1efcb8ae023e07ba710e 100644 --- a/tasks/task_044/tests/Dockerfile +++ b/tasks/task_044/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-044:v0.1.1@sha256:71ce7ba80a7fa8e30f073a714ed124130925d8fc6945760d3b28e176bdba2973 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_044/tests/docker-compose.yaml b/tasks/task_044/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_044/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_044/tests/grader.py b/tasks/task_044/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..49bec15ecf8a8a5fbc87e67113c9899bc7c2a453 --- /dev/null +++ b/tasks/task_044/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_044" +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_045/tests/Dockerfile b/tasks/task_045/tests/Dockerfile index 1718dbd380f7bbf98176c9daebc3a12945a0edf5..37cb6d534317f2b763df27e3c4459f8be6b6d9f7 100644 --- a/tasks/task_045/tests/Dockerfile +++ b/tasks/task_045/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-045:v0.1.1@sha256:8f1017124bd8c6ff303864a9f681042f38a68c6026620b1ddc187bfba8555525 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_045/tests/docker-compose.yaml b/tasks/task_045/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_045/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_045/tests/grader.py b/tasks/task_045/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..8067033dfc2ad347605443a4055288fd1d7bdab6 --- /dev/null +++ b/tasks/task_045/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_045" +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_046/tests/Dockerfile b/tasks/task_046/tests/Dockerfile index 7abb961292ec3a47141787877c59124ca10535a0..f2ad332c74b1f6835989c67eba641484c518c082 100644 --- a/tasks/task_046/tests/Dockerfile +++ b/tasks/task_046/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-046:v0.1.1@sha256:272c4cfe4cc4bc671ea369eeb6bf97bdc117cf5332c3f4b1468ab20364c9cb07 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_046/tests/docker-compose.yaml b/tasks/task_046/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_046/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_046/tests/grader.py b/tasks/task_046/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..e6c30a0340290919e32b9b215104a6f906f71aac --- /dev/null +++ b/tasks/task_046/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_046" +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_047/tests/Dockerfile b/tasks/task_047/tests/Dockerfile index 255252d651b9772e01ed4a9eb9b1ec18d8facad6..3fa968b4c6eeafe8da5285f1989094dfe7082aed 100644 --- a/tasks/task_047/tests/Dockerfile +++ b/tasks/task_047/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-047:v0.1.1@sha256:6255287669b4711882fdd9c817e94e31ba63f6cbc228a2469763f45b3019144b FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_047/tests/docker-compose.yaml b/tasks/task_047/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_047/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_047/tests/grader.py b/tasks/task_047/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..06c65127529906f9b14830071ef729b6f670c5fa --- /dev/null +++ b/tasks/task_047/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_047" +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_048/tests/Dockerfile b/tasks/task_048/tests/Dockerfile index a364cd97d7c97824d12a38bcd40e3101e2fa3f8e..c46a7a67423b49115d97e825332074d3d02d98d3 100644 --- a/tasks/task_048/tests/Dockerfile +++ b/tasks/task_048/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-048:v0.1.1@sha256:670f242d783782ed07312104f888007fdfa136952eb46941c065cfb4b5d9eb14 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_048/tests/docker-compose.yaml b/tasks/task_048/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_048/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_048/tests/grader.py b/tasks/task_048/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..c2016e276bafa5363fb2e5f904f78142ff7f35ba --- /dev/null +++ b/tasks/task_048/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_048" +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_049/tests/Dockerfile b/tasks/task_049/tests/Dockerfile index 6387a0bdea2c3fdce1e54dadf74cd736a0204152..e17e4c9a1ba4e8ed41ae69c57b9e84e0b80425be 100644 --- a/tasks/task_049/tests/Dockerfile +++ b/tasks/task_049/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-049:v0.1.1@sha256:ba7d3a2168c254fda002f5263c1e7d965577633f0473184e212743416a1d77fb FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_049/tests/docker-compose.yaml b/tasks/task_049/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_049/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_049/tests/grader.py b/tasks/task_049/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..691c0e5b699108bc8eac249725b451312c7b6c67 --- /dev/null +++ b/tasks/task_049/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_049" +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_050/tests/Dockerfile b/tasks/task_050/tests/Dockerfile index 07d7840b2205678da02539b4e576faf8476ffe52..36648eb20c379c2f7ebcc7be148a99bc43455d69 100644 --- a/tasks/task_050/tests/Dockerfile +++ b/tasks/task_050/tests/Dockerfile @@ -1,2 +1,5 @@ ARG VERIFIER_IMAGE=docker.io/kevinxulearning/swe-bench-science-verifier-python-task-050:v0.1.1@sha256:329b4cefbac68b9fff040c801b61c9edc46971f6378547731630f50d353d6a48 FROM ${VERIFIER_IMAGE} + +COPY grader.py /tests/grader.py +RUN chmod 755 /tests/grader.py diff --git a/tasks/task_050/tests/docker-compose.yaml b/tasks/task_050/tests/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2e97e5ab6736621a846c95722b74feff5663 --- /dev/null +++ b/tasks/task_050/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_050/tests/grader.py b/tasks/task_050/tests/grader.py new file mode 100644 index 0000000000000000000000000000000000000000..dcceb47e4c1027f96c5712ef7204a802176b5f26 --- /dev/null +++ b/tasks/task_050/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_050" +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))