dannylev123's picture
SWE-Race v0.1 public split (95 tasks)
4e3f22a verified
Raw History Blame Contribute Delete
2.06 kB
#!/bin/bash
# SWE-Race Harbor verifier: pytest -> JUnit XML -> grader.py -> reward.json
set -uo pipefail
trap 'if [ ! -f /logs/verifier/reward.json ] && [ ! -f /logs/verifier/reward.txt ]; then mkdir -p /logs/verifier; echo -1 > /logs/verifier/reward.txt; fi' EXIT
log() { echo "[verifier] $*"; }
cd /app || { mkdir -p /logs/verifier; exit 6; }
# Applies model.patch (the agent's work) then test.patch (the held-out tests).
python3 /tests/grader.py prepare || exit $?
[ -f /logs/verifier/reward.json ] && exit 0 # patch didn't apply -> already graded 0
export RUN_LOG=/logs/verifier/run.log
: > "$RUN_LOG" 2>/dev/null || true
require_cmd() { command -v "$1" >/dev/null 2>&1 || { log "ERROR: missing $1; PATH=$PATH"; exit 127; }; }
require_cmd python3
# Restart the daemons the tests need (Postgres, Redis); see environment/Dockerfile.
[ -x /usr/local/bin/benchgen-services ] && /usr/local/bin/benchgen-services >/dev/null 2>&1
# One pytest run covers both whitelists: after prepare, the f2p tests exist
# (test.patch applied) alongside the pre-existing p2p tests.
# The cache goes to /tmp rather than being disabled: `-p no:cacheprovider` makes
# pytest reject a repo's own `--cache-clear` addopts (async-lru#697 ran nothing).
# Hangs fail by name instead of stalling: a per-test timeout where pytest-timeout
# is installed and collection errors do not stop the run, both as verified
# it; and an overall cap below the 1800 s verifier budget, since the bug a task
# fixes can itself be a hang (pgqueuer#553 hung its empty submission for 30 min).
_TO=$(python3 -c 'import pytest_timeout' 2>/dev/null && echo --timeout=600)
set +e
timeout -k 30 1500 python3 -m pytest tests/unit/test_sql_alchemy_pooled_connection_provider.py $_TO --continue-on-collection-errors \
-o cache_dir=/tmp/.pytest_cache -rfE \
--junitxml=/logs/verifier/new.xml 2>&1 | tee -a "$RUN_LOG"
set -e
echo "===== raw suite output ====="
cat "$RUN_LOG" 2>/dev/null
echo "===== grade ====="
python3 /tests/grader.py grade
log "reward.json=$(cat /logs/verifier/reward.json 2>/dev/null)"