Download docs/run-batch.md from OpenMOSS-Team/SWE-bench-Science: direct link, hf CLI and curl.
- Browser
- Download file 12.5 kB
-
https://huggingface.co/datasets/OpenMOSS-Team/SWE-bench-Science/resolve/main/docs/run-batch.md
- Command line
-
hf download hf://datasets/OpenMOSS-Team/SWE-bench-Science/docs/run-batch.md
-
curl -L -o run-batch.md https://huggingface.co/datasets/OpenMOSS-Team/SWE-bench-Science/resolve/main/docs/run-batch.md
Batch Evaluation Reference
scripts/run_batch.py is the convenience wrapper for running a materialized task
selection with Pier. It does not build task images. It reads the immutable
environment and verifier references from each task.toml, pulls those images
for linux/amd64, writes a redacted run record, and invokes Pier with
--no-force-build --no-delete --yes.
Prerequisites
From a downloaded release directory:
uv tool install --python 3.12 "datacurve-pier==0.3.0"
docker login
python3 scripts/materialize.py \
--task-id 002,005-007 \
--output tasks-selected-small --force
The pinned datacurve-pier==0.3.0 release requires Python 3.12 or newer.
Docker Engine 28 or newer is required for isolated bridge gateway mode.
The --path passed to run_batch.py must be a materialized directory containing
task_NNN/task.toml directories. The runner never selects tasks implicitly and
never reads task definitions from GitHub at runtime.
Provider Profiles
Use an env file outside the checkout. The parser accepts KEY=value, optional
export KEY=value, comments, and quoted values. It never prints credential
values or writes them to batch-run.json.
Codex and OpenAI-compatible gateways
run_batch.py translates the following fields into Pier's Codex provider
configuration when --agent codex is used:
| Variable | Required | Meaning |
|---|---|---|
MODEL |
No | Exact model route sent to the gateway; default gpt-5 |
OPENAI_API_KEY |
Yes for a real run | Gateway credential |
CODEX_BASE_URL |
No | OpenAI-compatible gateway URL; defaults to https://api.openai.com/v1 |
CODEX_WIRE_API |
No | responses or chat; defaults to responses |
CODEX_VERSION |
No | Codex runtime version passed to Pier |
CODEX_REASONING_EFFORT |
No | Reasoning effort passed to the Codex adapter |
Example:
MODEL=gpt-5
OPENAI_API_KEY=replace-with-your-key
CODEX_BASE_URL=https://gateway.example.edu/v1
CODEX_WIRE_API=responses
CODEX_VERSION=latest
CODEX_REASONING_EFFORT=high
CODEX_BASE_URL selects the model gateway. It is different from a network
proxy. A network proxy is configured with standard HTTP_PROXY, HTTPS_PROXY,
and NO_PROXY variables. For Docker Desktop, a proxy running on the host is
usually reached from a container as host.docker.internal, not 127.0.0.1.
Responses gateways use HTTP/SSE (supports_websockets=false). Include the API
path in CODEX_BASE_URL, for example http://gateway.example:4000/v1.
Nonstandard gateway ports are allowed only for their configured gateway host.
The benchmark's generated Codex configuration disables hosted web search.
Chat-only gateways through LiteLLM
Use an independent LiteLLM proxy when the upstream deployment exposes only Chat Completions. Codex continues to use its native Responses interface; the benchmark does not rewrite model requests or add model-specific adapters. LiteLLM provides the Responses-to-Chat bridge.
Install a separate gateway environment:
uv venv --python 3.12 .venv-gateway
uv pip install --python .venv-gateway/bin/python 'litellm[proxy]==1.103.2'
Create litellm.yaml, replacing the deployment name and upstream URL:
model_list:
- model_name: my-deployment
litellm_params:
model: openai/my-deployment
api_base: https://upstream.example/v1
api_key: os.environ/UPSTREAM_API_KEY
use_chat_completions_api: true
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
litellm_settings:
turn_off_message_logging: true
Set UPSTREAM_API_KEY and a separate LITELLM_MASTER_KEY in the gateway
process's environment, then start it:
.venv-gateway/bin/litellm --config litellm.yaml --host 127.0.0.1 --port 4001
For Docker Desktop, configure the evaluation profile as follows:
MODEL=my-deployment
OPENAI_API_KEY=replace-with-your-litellm-master-key
CODEX_BASE_URL=http://host.docker.internal:4001/v1
CODEX_WIRE_API=responses
CODEX_VERSION=latest
Only the LiteLLM proxy key enters the Agent container. The upstream key stays in the gateway process. The configured host and port are added to the inference allowlist; direct Agent internet access remains blocked. On Linux, use a gateway address reachable from the proxy's egress network rather than enabling host networking for the Agent. The gateway is a separate local service, not part of the task images or verifier.
Claude Code and mini-swe-agent
These harnesses receive their provider variables through Pier's --env-file:
# Claude Code
ANTHROPIC_AUTH_TOKEN=replace-with-your-gateway-key
ANTHROPIC_BASE_URL=https://api.anthropic.com
ANTHROPIC_CUSTOM_HEADERS=
# mini-swe-agent with an OpenAI-compatible provider
OPENAI_API_KEY=replace-with-your-gateway-key
OPENAI_BASE_URL=https://gateway.example.edu/v1
The model route is selected with the repeatable --model option. Provider
variables not listed here can be added to the env file and are passed through to
the selected harness by Pier.
Basic Commands
Run a no-model infrastructure smoke:
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent nop \
--n-concurrent 1 \
--n-attempts 1 \
--jobs-dir jobs \
--job-name smoke
Run Codex through a gateway:
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent codex \
--env-file ~/.config/swe-bench-science/codex.env \
--n-concurrent 2 \
--n-attempts 1 \
--max-retries 1 \
--jobs-dir jobs \
--job-name codex-small
Run Claude Code or mini-swe-agent:
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent claude-code \
--env-file ~/.config/swe-bench-science/claude.env \
--model anthropic/claude-opus-4-7 \
--n-concurrent 1 \
--jobs-dir jobs \
--job-name claude-small
For an approximately 120-second agent-stage smoke, add
--agent-timeout-multiplier 0.0223. For an approximately 30-second agent-stage
smoke, use --agent-timeout-multiplier 0.0055556. These options do not shorten
the verifier timeout or any native build timeout.
Offline Network Isolation
The batch runner selects the shared ScienceBenchDocker environment for every
harness, including Codex, Claude Code, and mini-swe-agent. Agent containers join
only an internal bridge with gateway_mode_ipv4=isolated and IPv6 disabled.
The inference proxy also joins a separate egress network, enforces the harness's
provider allowlist, and has IPv4/IPv6 forwarding disabled. Both containers drop
NET_ADMIN and NET_RAW. Verifiers and agents without inference egress use
network_mode=none.
Before the agent starts, the runner inspects the actual container and network
configuration. Unsupported engines, a host gateway, additional Agent networks,
or elevated network capabilities fail the trial. Clearing proxy variables,
NO_PROXY='*', curl --noproxy '*', and Git proxy overrides cannot create a
direct route to external source repositories.
Each trial records network-policy-<session>.json; batch-run.json records
the network policy and configured gateway authorities without credentials.
Task image digests are unchanged by this runtime policy. Pier installs the
selected harness during a separate image-build stage before the isolated agent
stage starts.
Run the opt-in Docker regression with an already pulled environment image:
SCI_BENCH_NETWORK_TEST_IMAGE='<environment image from task.toml>' \
python3.12 -m unittest tests.test_network_policy_e2e -v
This regression lives in the GitHub checkout. It uses a reachable local HTTP fixture to test permitted gateway traffic, denied source hosts, and direct proxy bypass attempts without a paid model call.
Use scripts/run_batch.py for this policy. A direct pier run command must
also supply --environment-import-path scripts.pier_network:ScienceBenchDocker
and any nonstandard gateway URLs through
--environment-kwarg 'inference_urls=["http://gateway.example:4000"]'.
The validated release backend is Docker.
Patch and Verifier Boundary
Each materialized task contains a Pier pre_artifacts.sh hook. Pier runs this
hook after the agent exits and before it collects artifacts. The hook computes
artifacts/model.patch against the task image's original baseline root commit,
so an agent-created commit is still included in the patch. A clean or timed-out
agent produces an explicit empty patch rather than a missing artifact.
For tasks with a separate verifier image, the verifier entrypoint applies that
patch to its clean task workspace before running public and private tests. The
verifier result therefore evaluates the agent workspace, not the untouched
baseline. A missing pre_artifacts.sh is rejected by run_batch.py; rerun
materialize.py with the current tools to regenerate the task selection.
Private-test collection is directory-based. The verifier runs pytest on
/tests/private_tests, so task authors may use names such as
test_res_export.py or test_scientific_invariants.py; no
test_task_NNN.py filename is required. The task's Compose override mounts the
bundle's dynamic grader into an existing prebuilt verifier image, so correcting
test discovery does not require rebuilding the image.
Option Reference
| Option | Default | Description |
|---|---|---|
--path |
required | Materialized task directory |
--agent |
nop |
Pier harness, such as codex, claude-code, mini-swe-agent, or nop |
--env |
docker |
Docker backend with the Science benchmark offline policy |
--env-file |
unset | Provider/harness env file |
--model |
unset | Model route; repeat for multiple Pier model arguments |
--agent-env KEY=VALUE |
repeatable | Extra environment value passed to the harness |
--agent-kwarg KEY=VALUE |
repeatable | Extra Pier agent keyword; useful for adapter-specific settings |
--n-concurrent |
1 |
Number of simultaneous tasks |
--n-attempts |
1 |
Attempts per task |
--max-retries |
0 |
Pier retries after an attempt-level failure |
--agent-timeout-multiplier |
Pier default | Multiplier for the agent stage timeout |
--verifier-timeout-multiplier |
Pier default | Multiplier for verifier/build timeout |
--jobs-dir |
jobs |
Directory for Pier jobs and summaries |
--job-name |
unset | Stable job name used in result paths |
--platform |
linux/amd64 |
Docker pull and derived Pier image platform |
--pier-bin |
pier |
Pier executable or absolute path |
--skip-pull |
off | Skip Docker pulls when immutable refs are already local |
--no-auto-provider |
off | Do not translate CODEX_* profile values into Codex kwargs |
--no-auto-agent-adapter |
off | Use Pier's built-in Codex agent instead of the Science Bench adapter |
--agent-import-path |
unset | Explicit Pier agent import path |
--dry-run |
off | Pull/validate images and write metadata, but do not invoke Pier |
The wrapper always records the selected task IDs, selection hash, image refs,
platform, Pier version, agent/model settings, and a redacted Pier command in
<path>/batch-run.json.
Results
Pier writes its job output under the selected jobs directory. The wrapper then generates:
jobs/<job-name>/result.json
jobs/<job-name>/summary.json
jobs/<job-name>/summary.csv
jobs/<job-name>/<task>__<trial>/verifier/reward.json
jobs/<job-name>/<task>__<trial>/verifier/ctrf.json
jobs/<job-name>/<task>__<trial>/verifier/test-stdout.txt
The summary CSV is the convenient per-task result table. Use pier view jobs
for trajectories and inspect result.json, reward.json, and
test-stdout.txt together when diagnosing a failure.
Common Variants
Pull nothing and inspect the fully rendered command:
python3 scripts/run_batch.py \
--path tasks-selected-small \
--agent codex \
--env-file ~/.config/swe-bench-science/codex.env \
--skip-pull \
--dry-run
Run the 91-task science-knowledge ablation selection after materialization:
python3 scripts/materialize.py \
--task-id 002-082,084,086,090,097-101,111,114 \
--allow-restricted-licenses \
--output tasks-science-knowledge-ablation --force
python3 scripts/run_batch.py \
--path tasks-science-knowledge-ablation \
--agent codex \
--env-file ~/.config/swe-bench-science/codex.env \
--n-concurrent 4 \
--jobs-dir jobs \
--job-name codex-science-ablation