Upload 8 files
Browse files- eval/instance_report.py +49 -0
- eval/make_subset.py +36 -0
- eval/relay_model.py +35 -0
- eval/rescore.sh +44 -0
- eval/rescore_merge.py +56 -0
- eval/run_agent.sh +50 -0
- eval/score.sh +35 -0
- eval/subset.json +138 -0
eval/instance_report.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Build a run report from the harness's per-instance reports, for a run whose own final report was not written.
|
| 2 |
+
|
| 3 |
+
python eval/instance_report.py <folder the harness ran in> <run id> <preds.json> <out.json> [--ids id1 id2 ...]
|
| 4 |
+
|
| 5 |
+
The SWE-bench harness scores each instance into logs/run_evaluation/<run id>/<model>/<instance>/report.json and then,
|
| 6 |
+
as its last step, lists every container on the machine to write one summary file. On a machine where hundreds of
|
| 7 |
+
short-lived containers of other runs come and go, that listing can fail (a container disappears between being listed
|
| 8 |
+
and being read) and the summary is never written. The per-instance reports are complete by then; this adds them up
|
| 9 |
+
the same way. An instance with a patch and no report counts as an error, to be scored again (eval/rescore.sh).
|
| 10 |
+
"""
|
| 11 |
+
import glob
|
| 12 |
+
import json
|
| 13 |
+
import sys
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def main():
|
| 17 |
+
folder, run_id, preds_path, out = sys.argv[1:5]
|
| 18 |
+
only = set(sys.argv[sys.argv.index("--ids") + 1:]) if "--ids" in sys.argv else None
|
| 19 |
+
preds = json.load(open(preds_path))
|
| 20 |
+
resolved, completed, errors, empty = [], [], [], []
|
| 21 |
+
for iid, p in sorted(preds.items()):
|
| 22 |
+
if only is not None and iid not in only:
|
| 23 |
+
continue
|
| 24 |
+
if not (p.get("model_patch") or "").strip():
|
| 25 |
+
empty.append(iid)
|
| 26 |
+
continue
|
| 27 |
+
found = glob.glob(f"{folder}/logs/run_evaluation/{run_id}/*/{iid}/report.json")
|
| 28 |
+
if not found:
|
| 29 |
+
errors.append(iid)
|
| 30 |
+
continue
|
| 31 |
+
completed.append(iid)
|
| 32 |
+
try:
|
| 33 |
+
if json.load(open(found[0])).get(iid, {}).get("resolved"):
|
| 34 |
+
resolved.append(iid)
|
| 35 |
+
except ValueError:
|
| 36 |
+
completed.pop()
|
| 37 |
+
errors.append(iid)
|
| 38 |
+
n = len(resolved) + (len(completed) - len(resolved)) + len(errors) + len(empty)
|
| 39 |
+
report = {"built_from": "the per-instance reports (the harness's own run report was not written)",
|
| 40 |
+
"total_instances": n, "submitted_instances": n, "completed_instances": len(completed), "resolved_instances": len(resolved),
|
| 41 |
+
"unresolved_instances": len(completed) - len(resolved), "empty_patch_instances": len(empty), "error_instances": len(errors),
|
| 42 |
+
"completed_ids": completed, "resolved_ids": resolved, "unresolved_ids": sorted(set(completed) - set(resolved)),
|
| 43 |
+
"empty_patch_ids": empty, "error_ids": errors}
|
| 44 |
+
json.dump(report, open(out, "w"), indent=1)
|
| 45 |
+
print(f"built {out}: resolved {len(resolved)}, completed {len(completed)}, errors {len(errors)}, empty {len(empty)}")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
main()
|
eval/make_subset.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The evaluation subset: 100 instances of SWE-bench Verified, drawn once with a fixed seed.
|
| 2 |
+
|
| 3 |
+
python eval/make_subset.py # writes eval/subset.json
|
| 4 |
+
|
| 5 |
+
The file also lists every repository of SWE-bench Verified: training data must share none of them.
|
| 6 |
+
"""
|
| 7 |
+
import json
|
| 8 |
+
import random
|
| 9 |
+
import sys
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
from datasets import load_dataset
|
| 13 |
+
|
| 14 |
+
DATASET, SPLIT, SEED, N = "princeton-nlp/SWE-bench_Verified", "test", 20261201, 100
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def main():
|
| 18 |
+
out = Path(sys.argv[1] if len(sys.argv) > 1 else Path(__file__).parent / "subset.json")
|
| 19 |
+
ds = load_dataset(DATASET, split=SPLIT)
|
| 20 |
+
repo_of = dict(zip(ds["instance_id"], ds["repo"]))
|
| 21 |
+
ids = sorted(repo_of)
|
| 22 |
+
pick = sorted(random.Random(SEED).sample(ids, N))
|
| 23 |
+
per_repo = {}
|
| 24 |
+
for i in pick:
|
| 25 |
+
per_repo[repo_of[i]] = per_repo.get(repo_of[i], 0) + 1
|
| 26 |
+
out.write_text(json.dumps({
|
| 27 |
+
"dataset": DATASET, "split": SPLIT, "dataset_fingerprint": ds._fingerprint, "total_instances": len(ids),
|
| 28 |
+
"seed": SEED, "n": N, "method": "random.Random(seed).sample(sorted(instance_ids), n)",
|
| 29 |
+
"instance_ids": pick, "instances_per_repo": dict(sorted(per_repo.items())),
|
| 30 |
+
"all_repos_of_the_benchmark": sorted(set(repo_of.values())),
|
| 31 |
+
}, indent=1) + "\n", encoding="utf-8")
|
| 32 |
+
print(f"{out}: {len(pick)} of {len(ids)} instances, {len(per_repo)} repositories")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
main()
|
eval/relay_model.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The comparison model for the agent harness, reached through the laptop relay (tools/or_proxy.py).
|
| 2 |
+
|
| 3 |
+
Same request the harness's own OpenRouter class sends (one bash tool, cost reported per call); only the address
|
| 4 |
+
differs, and the key stays on the laptop.
|
| 5 |
+
"""
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
import requests
|
| 10 |
+
from minisweagent.models.openrouter_model import (BASH_TOOL, OpenRouterAPIError, OpenRouterAuthenticationError,
|
| 11 |
+
OpenRouterModel, OpenRouterRateLimitError)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class RelayOpenRouterModel(OpenRouterModel):
|
| 15 |
+
def __init__(self, **kwargs):
|
| 16 |
+
super().__init__(**kwargs)
|
| 17 |
+
self._api_url = os.environ.get("RELAY_URL", "http://127.0.0.1:18811/v1/chat/completions")
|
| 18 |
+
self._api_key = "relay"
|
| 19 |
+
|
| 20 |
+
def _query(self, messages, **kwargs):
|
| 21 |
+
payload = {"model": self.config.model_name, "messages": messages, "tools": [BASH_TOOL],
|
| 22 |
+
"usage": {"include": True}, **(self.config.model_kwargs | kwargs)}
|
| 23 |
+
try:
|
| 24 |
+
response = requests.post(self._api_url, headers={"Content-Type": "application/json"},
|
| 25 |
+
data=json.dumps(payload), timeout=600)
|
| 26 |
+
response.raise_for_status()
|
| 27 |
+
return response.json()
|
| 28 |
+
except requests.exceptions.HTTPError as e:
|
| 29 |
+
if response.status_code in (401, 402): # 402: the relay's spend cap
|
| 30 |
+
raise OpenRouterAuthenticationError(f"relay refused: HTTP {response.status_code} {response.text[:200]}") from e
|
| 31 |
+
if response.status_code == 429:
|
| 32 |
+
raise OpenRouterRateLimitError("Rate limit exceeded") from e
|
| 33 |
+
raise OpenRouterAPIError(f"HTTP {response.status_code}: {response.text[:300]}") from e
|
| 34 |
+
except requests.exceptions.RequestException as e:
|
| 35 |
+
raise OpenRouterAPIError(f"Request failed: {e}") from e
|
eval/rescore.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Score again, alone, every instance whose scoring errored, and add what resolves to the run's summary.
|
| 3 |
+
# Two things make an instance's scoring error on a busy machine: a docker call that times out while hundreds of other
|
| 4 |
+
# containers start and stop, and one scikit-learn test of the subset that collapses when its cores are shared. Here
|
| 5 |
+
# one instance runs at a time on 16 cores of its own, set before its tests start, with up to three tries.
|
| 6 |
+
# Every run is treated the same way, the comparison model's run included.
|
| 7 |
+
# LABEL=stock-1 [OUT=...] [LANE=0|1] bash eval/rescore.sh
|
| 8 |
+
set -u
|
| 9 |
+
R=/data/train/mini
|
| 10 |
+
P=$R/venv/bin/python
|
| 11 |
+
LABEL=${LABEL:?give LABEL}; OUT=${OUT:-$R/results/agent/$LABEL}; LANE=${LANE:-0}
|
| 12 |
+
CORES=$((LANE * 16))-$((LANE * 16 + 15))
|
| 13 |
+
cd "$OUT" || exit 1
|
| 14 |
+
IDS=$($P $R/src/eval/rescore_merge.py ids "$OUT" "$LABEL")
|
| 15 |
+
[ -z "$IDS" ] && exit 0
|
| 16 |
+
mkdir -p "$OUT/rescore"
|
| 17 |
+
cd "$OUT/rescore" || exit 1 # the harness writes its report and logs into the folder it runs in
|
| 18 |
+
if ! ls "$OUT"/rescore/*.json >/dev/null 2>&1; then
|
| 19 |
+
for try in 1 2 3; do
|
| 20 |
+
rm -f .pinned
|
| 21 |
+
( end=$((SECONDS + 1500))
|
| 22 |
+
while [ $SECONDS -lt $end ]; do
|
| 23 |
+
for c in $(/usr/bin/docker ps --format '{{.Names}}' | grep -F ".$LABEL-rescore"); do
|
| 24 |
+
grep -qxF "$c" .pinned 2>/dev/null && continue
|
| 25 |
+
/usr/bin/docker update --cpus 0 --cpuset-cpus "$CORES" "$c" >/dev/null 2>&1 && echo "$c" >> .pinned
|
| 26 |
+
done
|
| 27 |
+
sleep 0.3
|
| 28 |
+
done ) &
|
| 29 |
+
W=$!
|
| 30 |
+
rm -f ./*."$LABEL-rescore".json
|
| 31 |
+
# shellcheck disable=SC2086
|
| 32 |
+
sudo -n env PATH=$R/venv-smith/bin:/usr/bin:/bin HF_HOME=$R/hf $R/venv-smith/bin/python -m swebench.harness.run_evaluation \
|
| 33 |
+
--dataset_name princeton-nlp/SWE-bench_Verified --split test --predictions_path "$OUT/preds.json" --run_id "$LABEL-rescore" \
|
| 34 |
+
--max_workers 1 --timeout 900 --namespace swebench --instance_ids $IDS > score-$try.log 2>&1
|
| 35 |
+
kill $W 2>/dev/null
|
| 36 |
+
sudo -n chown -R "$USER":"$USER" "$OUT" 2>/dev/null
|
| 37 |
+
# shellcheck disable=SC2086
|
| 38 |
+
ls ./*."$LABEL-rescore".json >/dev/null 2>&1 || $P $R/src/eval/instance_report.py "$OUT/rescore" "$LABEL-rescore" "$OUT/preds.json" \
|
| 39 |
+
"instances.$LABEL-rescore.json" --ids $IDS >> score-$try.log 2>&1
|
| 40 |
+
[ -z "$($P $R/src/eval/rescore_merge.py errors "$OUT" "$LABEL")" ] && break
|
| 41 |
+
done
|
| 42 |
+
echo "tries: $try" > tries.txt
|
| 43 |
+
fi
|
| 44 |
+
$P $R/src/eval/rescore_merge.py merge "$OUT" "$LABEL"
|
eval/rescore_merge.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Helper of eval/rescore.sh.
|
| 2 |
+
|
| 3 |
+
python eval/rescore_merge.py ids <run folder> <label> the instance ids whose scoring errored (once per run)
|
| 4 |
+
python eval/rescore_merge.py errors <run folder> <label> the ids that errored again in the last rescoring
|
| 5 |
+
python eval/rescore_merge.py merge <run folder> <label> adds what resolved when scored alone to summary.json
|
| 6 |
+
python eval/rescore_merge.py reset <run folder> <label> forgets a rescoring that added nothing, so it is done again
|
| 7 |
+
"""
|
| 8 |
+
import glob
|
| 9 |
+
import json
|
| 10 |
+
import sys
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def main():
|
| 14 |
+
cmd, out, label = sys.argv[1:4]
|
| 15 |
+
s = json.load(open(out + "/summary.json"))
|
| 16 |
+
if cmd == "ids":
|
| 17 |
+
if s.get("rescored_alone") is not None:
|
| 18 |
+
return
|
| 19 |
+
r = json.load(open(out + "/" + s["report_file"]))
|
| 20 |
+
print(" ".join(r.get("error_ids") or []))
|
| 21 |
+
return
|
| 22 |
+
reports = glob.glob(out + "/rescore/*.json")
|
| 23 |
+
new, err = set(), []
|
| 24 |
+
for f in reports:
|
| 25 |
+
r = json.load(open(f))
|
| 26 |
+
new |= set(r.get("resolved_ids") or [])
|
| 27 |
+
err += r.get("error_ids") or []
|
| 28 |
+
if cmd == "errors":
|
| 29 |
+
print(" ".join(sorted(set(err))) if reports else "no report")
|
| 30 |
+
return
|
| 31 |
+
if cmd == "reset":
|
| 32 |
+
ra = s.get("rescored_alone")
|
| 33 |
+
if ra is not None and not ra.get("resolved"):
|
| 34 |
+
s.pop("rescored_alone", None)
|
| 35 |
+
s.pop("resolved_first_scoring", None)
|
| 36 |
+
json.dump(s, open(out + "/summary.json", "w"), indent=1)
|
| 37 |
+
print("reset", label)
|
| 38 |
+
return
|
| 39 |
+
if s.get("rescored_alone") is not None:
|
| 40 |
+
return
|
| 41 |
+
if not reports:
|
| 42 |
+
print(json.dumps({"label": label, "rescore": "no report was written; not merged"}))
|
| 43 |
+
return
|
| 44 |
+
added = sorted(new - set(s["resolved_ids"]))
|
| 45 |
+
s["resolved_first_scoring"] = s["resolved"]
|
| 46 |
+
s["resolved_ids"] = sorted(set(s["resolved_ids"]) | new)
|
| 47 |
+
s["resolved"] = len(s["resolved_ids"])
|
| 48 |
+
s["score_pct"] = round(100 * s["resolved"] / s["subset_n"], 1)
|
| 49 |
+
s["rescored_alone"] = {"resolved": added, "still_error": sorted(set(err))}
|
| 50 |
+
json.dump(s, open(out + "/summary.json", "w"), indent=1)
|
| 51 |
+
print(json.dumps({"label": label, "resolved": s["resolved"], "resolved_first_scoring": s["resolved_first_scoring"],
|
| 52 |
+
"rescored_alone": s["rescored_alone"]}))
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
main()
|
eval/run_agent.sh
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# One pass of the bash-only agent (mini-swe-agent, its own swebench.yaml) over the evaluation subset.
|
| 3 |
+
# LABEL=stock-1 URL=http://127.0.0.1:9006/v1 MODEL=hosted_vllm/inkling-2-mini bash eval/run_agent.sh
|
| 4 |
+
# LABEL=opus55-1 RELAY=1 WORKERS=8 bash eval/run_agent.sh # the comparison model, through the laptop relay
|
| 5 |
+
# Output: /data/train/mini/results/agent/$LABEL/{preds.json, <instance>/<instance>.traj.json, run.log}
|
| 6 |
+
set -u
|
| 7 |
+
R=/data/train/mini
|
| 8 |
+
LABEL=${LABEL:?give LABEL}; URL=${URL:-http://127.0.0.1:9006/v1}; MODEL=${MODEL:-hosted_vllm/inkling-2-mini}
|
| 9 |
+
WORKERS=${WORKERS:-32}; TEMP=${TEMP:-0}; MAXTOK=${MAXTOK:-16384}; STEPS=${STEPS:-250}; RELAY=${RELAY:-0}
|
| 10 |
+
SUBSET=${SUBSET:-$R/src/eval/subset.json}; DATA=${DATA:-verified}; SPLIT=${SPLIT:-test}
|
| 11 |
+
export PATH=$R/bin:$R/venv/bin:$PATH MSWEA_DOCKER_EXECUTABLE=$R/bin/docker HF_HOME=$R/hf PYTHONPATH=$R/src/eval
|
| 12 |
+
OUT=${OUT:-$R/results/agent/$LABEL}; mkdir -p "$OUT"
|
| 13 |
+
FILTER=$(python - "$SUBSET" <<'EOF'
|
| 14 |
+
import json, re, sys
|
| 15 |
+
print("^(" + "|".join(re.escape(i) for i in json.load(open(sys.argv[1]))["instance_ids"]) + ")$")
|
| 16 |
+
EOF
|
| 17 |
+
)
|
| 18 |
+
if [ "$RELAY" = 1 ]; then
|
| 19 |
+
MODEL_ARGS=(--model-class relay_model.RelayOpenRouterModel -m anthropic/claude-opus-5.5
|
| 20 |
+
-c model.set_cache_control=default_end -c model.model_kwargs.max_tokens="$MAXTOK"
|
| 21 |
+
-c agent.cost_limit="${COST_LIMIT:-2.5}")
|
| 22 |
+
else
|
| 23 |
+
export MSWEA_COST_TRACKING=ignore_errors
|
| 24 |
+
MODEL_ARGS=(-m "$MODEL" -c model.model_kwargs.api_base="$URL" -c model.model_kwargs.api_key=EMPTY
|
| 25 |
+
-c model.model_kwargs.temperature="$TEMP" -c model.model_kwargs.max_tokens="$MAXTOK" -c agent.cost_limit=0)
|
| 26 |
+
fi
|
| 27 |
+
echo "== $LABEL start $(date -u +%FT%TZ) workers=$WORKERS temp=$TEMP steps=$STEPS maxtok=$MAXTOK relay=$RELAY" | tee -a "$OUT/meta.txt"
|
| 28 |
+
# STARTUP: a command run in the task's container before the agent starts, with the instance's fields as {{ names }}.
|
| 29 |
+
# SWE-smith needs one: a task is a branch of the repository inside the image, so it must be checked out first.
|
| 30 |
+
STARTUP_ARGS=()
|
| 31 |
+
[ -n "${STARTUP:-}" ] && STARTUP_ARGS=(-c "run.env_startup_command=$STARTUP")
|
| 32 |
+
# shellcheck disable=SC2086
|
| 33 |
+
mini-extra swebench --subset "$DATA" --split "$SPLIT" --filter "$FILTER" -o "$OUT" -w "$WORKERS" \
|
| 34 |
+
-c swebench.yaml -c agent.step_limit="$STEPS" "${MODEL_ARGS[@]}" "${STARTUP_ARGS[@]}" ${EXTRA_ARGS:-} > "$OUT/run.log" 2>&1
|
| 35 |
+
echo "== $LABEL agent done $(date -u +%FT%TZ) exit=$?" | tee -a "$OUT/meta.txt"
|
| 36 |
+
python - "$OUT" <<'EOF'
|
| 37 |
+
import json, sys, glob, collections
|
| 38 |
+
out = sys.argv[1]
|
| 39 |
+
try:
|
| 40 |
+
p = json.load(open(out + "/preds.json"))
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print("no preds.json:", e); sys.exit()
|
| 43 |
+
st = collections.Counter()
|
| 44 |
+
for f in glob.glob(out + "/*/*.traj.json"):
|
| 45 |
+
try:
|
| 46 |
+
st[json.load(open(f)).get("info", {}).get("exit_status")] += 1
|
| 47 |
+
except Exception:
|
| 48 |
+
st["unreadable"] += 1
|
| 49 |
+
print("predictions:", len(p), "with a patch:", sum(1 for v in p.values() if (v.get("model_patch") or "").strip()), "exit statuses:", dict(st))
|
| 50 |
+
EOF
|
eval/score.sh
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Score one agent pass with the official SWE-bench harness, version 4.0.4 (the benchmark's own tests, in its own images).
|
| 3 |
+
# LABEL=stock-1 bash eval/score.sh
|
| 4 |
+
# An instance of the subset with no prediction or an empty patch counts as not resolved: the score is always out of N.
|
| 5 |
+
set -u
|
| 6 |
+
R=/data/train/mini
|
| 7 |
+
LABEL=${LABEL:?give LABEL}; OUT=${OUT:-$R/results/agent/$LABEL}; EW=${EW:-24}
|
| 8 |
+
SUBSET=${SUBSET:-$R/src/eval/subset.json}
|
| 9 |
+
cd "$OUT" || exit 1
|
| 10 |
+
echo "== $LABEL scoring start $(date -u +%FT%TZ)" | tee -a meta.txt
|
| 11 |
+
rm -f "instances.$LABEL.json"
|
| 12 |
+
sudo -n env PATH=$R/venv-smith/bin:/usr/bin:/bin HF_HOME=$R/hf $R/venv-smith/bin/python -m swebench.harness.run_evaluation \
|
| 13 |
+
--dataset_name princeton-nlp/SWE-bench_Verified --split test --predictions_path "$OUT/preds.json" --run_id "$LABEL" \
|
| 14 |
+
--max_workers "$EW" --namespace swebench --report_dir "$OUT" > score.log 2>&1
|
| 15 |
+
sudo -n chown -R "$USER":"$USER" "$OUT" $R/hf 2>/dev/null
|
| 16 |
+
# The harness's last step can fail on a busy machine and leave no run report (see eval/instance_report.py); the
|
| 17 |
+
# per-instance reports are complete by then and are added up instead.
|
| 18 |
+
ls ./*."$LABEL".json >/dev/null 2>&1 || $R/venv/bin/python $R/src/eval/instance_report.py "$OUT" "$LABEL" "$OUT/preds.json" "instances.$LABEL.json" >> score.log 2>&1
|
| 19 |
+
echo "== $LABEL scoring done $(date -u +%FT%TZ)" | tee -a meta.txt
|
| 20 |
+
$R/venv/bin/python - "$OUT" "$SUBSET" "$LABEL" <<'EOF'
|
| 21 |
+
import glob, json, sys
|
| 22 |
+
out, subset, label = sys.argv[1:4]
|
| 23 |
+
ids = json.load(open(subset))["instance_ids"]
|
| 24 |
+
reports = [f for f in glob.glob(out + f"/*.{label}.json")]
|
| 25 |
+
if not reports:
|
| 26 |
+
print("NO REPORT FILE; see score.log"); sys.exit(1)
|
| 27 |
+
r = json.load(open(reports[0]))
|
| 28 |
+
resolved = sorted(set(r.get("resolved_ids", [])) & set(ids))
|
| 29 |
+
summary = {"label": label, "subset_n": len(ids), "resolved": len(resolved), "score_pct": round(100 * len(resolved) / len(ids), 1),
|
| 30 |
+
"submitted": r.get("submitted_instances"), "completed": r.get("completed_instances"),
|
| 31 |
+
"empty_patch": r.get("empty_patch_instances"), "error": r.get("error_instances"),
|
| 32 |
+
"unresolved": r.get("unresolved_instances"), "resolved_ids": resolved, "report_file": reports[0].split("/")[-1]}
|
| 33 |
+
json.dump(summary, open(out + "/summary.json", "w"), indent=1)
|
| 34 |
+
print(json.dumps({k: v for k, v in summary.items() if k != "resolved_ids"}))
|
| 35 |
+
EOF
|
eval/subset.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"dataset": "princeton-nlp/SWE-bench_Verified",
|
| 3 |
+
"split": "test",
|
| 4 |
+
"dataset_fingerprint": "1fdfd21ba2621130",
|
| 5 |
+
"total_instances": 500,
|
| 6 |
+
"seed": 20261201,
|
| 7 |
+
"n": 100,
|
| 8 |
+
"method": "random.Random(seed).sample(sorted(instance_ids), n)",
|
| 9 |
+
"instance_ids": [
|
| 10 |
+
"astropy__astropy-14598",
|
| 11 |
+
"astropy__astropy-7336",
|
| 12 |
+
"astropy__astropy-7671",
|
| 13 |
+
"django__django-10554",
|
| 14 |
+
"django__django-11138",
|
| 15 |
+
"django__django-11211",
|
| 16 |
+
"django__django-11276",
|
| 17 |
+
"django__django-11451",
|
| 18 |
+
"django__django-11555",
|
| 19 |
+
"django__django-11749",
|
| 20 |
+
"django__django-11815",
|
| 21 |
+
"django__django-11885",
|
| 22 |
+
"django__django-12125",
|
| 23 |
+
"django__django-12143",
|
| 24 |
+
"django__django-12262",
|
| 25 |
+
"django__django-12304",
|
| 26 |
+
"django__django-12663",
|
| 27 |
+
"django__django-12754",
|
| 28 |
+
"django__django-12774",
|
| 29 |
+
"django__django-12965",
|
| 30 |
+
"django__django-13012",
|
| 31 |
+
"django__django-13023",
|
| 32 |
+
"django__django-13112",
|
| 33 |
+
"django__django-13343",
|
| 34 |
+
"django__django-13449",
|
| 35 |
+
"django__django-13513",
|
| 36 |
+
"django__django-13551",
|
| 37 |
+
"django__django-13794",
|
| 38 |
+
"django__django-13809",
|
| 39 |
+
"django__django-13964",
|
| 40 |
+
"django__django-14011",
|
| 41 |
+
"django__django-14155",
|
| 42 |
+
"django__django-14434",
|
| 43 |
+
"django__django-14493",
|
| 44 |
+
"django__django-14539",
|
| 45 |
+
"django__django-14559",
|
| 46 |
+
"django__django-14725",
|
| 47 |
+
"django__django-14771",
|
| 48 |
+
"django__django-15022",
|
| 49 |
+
"django__django-15280",
|
| 50 |
+
"django__django-15467",
|
| 51 |
+
"django__django-15695",
|
| 52 |
+
"django__django-15731",
|
| 53 |
+
"django__django-15732",
|
| 54 |
+
"django__django-15814",
|
| 55 |
+
"django__django-15957",
|
| 56 |
+
"django__django-16116",
|
| 57 |
+
"django__django-16333",
|
| 58 |
+
"django__django-16560",
|
| 59 |
+
"django__django-16642",
|
| 60 |
+
"django__django-16662",
|
| 61 |
+
"django__django-17087",
|
| 62 |
+
"matplotlib__matplotlib-20859",
|
| 63 |
+
"matplotlib__matplotlib-22865",
|
| 64 |
+
"matplotlib__matplotlib-24570",
|
| 65 |
+
"matplotlib__matplotlib-25122",
|
| 66 |
+
"matplotlib__matplotlib-25332",
|
| 67 |
+
"matplotlib__matplotlib-25960",
|
| 68 |
+
"matplotlib__matplotlib-26208",
|
| 69 |
+
"matplotlib__matplotlib-26342",
|
| 70 |
+
"mwaskom__seaborn-3187",
|
| 71 |
+
"psf__requests-5414",
|
| 72 |
+
"psf__requests-6028",
|
| 73 |
+
"pydata__xarray-3151",
|
| 74 |
+
"pydata__xarray-4356",
|
| 75 |
+
"pydata__xarray-4966",
|
| 76 |
+
"pydata__xarray-6721",
|
| 77 |
+
"pydata__xarray-7229",
|
| 78 |
+
"pydata__xarray-7233",
|
| 79 |
+
"pydata__xarray-7393",
|
| 80 |
+
"pylint-dev__pylint-4970",
|
| 81 |
+
"pytest-dev__pytest-10081",
|
| 82 |
+
"pytest-dev__pytest-5631",
|
| 83 |
+
"pytest-dev__pytest-5809",
|
| 84 |
+
"pytest-dev__pytest-6197",
|
| 85 |
+
"pytest-dev__pytest-7571",
|
| 86 |
+
"pytest-dev__pytest-8399",
|
| 87 |
+
"scikit-learn__scikit-learn-13779",
|
| 88 |
+
"scikit-learn__scikit-learn-14629",
|
| 89 |
+
"scikit-learn__scikit-learn-14710",
|
| 90 |
+
"scikit-learn__scikit-learn-25232",
|
| 91 |
+
"sphinx-doc__sphinx-10673",
|
| 92 |
+
"sphinx-doc__sphinx-8120",
|
| 93 |
+
"sphinx-doc__sphinx-9698",
|
| 94 |
+
"sympy__sympy-12481",
|
| 95 |
+
"sympy__sympy-13031",
|
| 96 |
+
"sympy__sympy-13091",
|
| 97 |
+
"sympy__sympy-13877",
|
| 98 |
+
"sympy__sympy-13974",
|
| 99 |
+
"sympy__sympy-15976",
|
| 100 |
+
"sympy__sympy-16450",
|
| 101 |
+
"sympy__sympy-16766",
|
| 102 |
+
"sympy__sympy-17655",
|
| 103 |
+
"sympy__sympy-19637",
|
| 104 |
+
"sympy__sympy-20428",
|
| 105 |
+
"sympy__sympy-21379",
|
| 106 |
+
"sympy__sympy-22080",
|
| 107 |
+
"sympy__sympy-23824",
|
| 108 |
+
"sympy__sympy-24066",
|
| 109 |
+
"sympy__sympy-24213"
|
| 110 |
+
],
|
| 111 |
+
"instances_per_repo": {
|
| 112 |
+
"astropy/astropy": 3,
|
| 113 |
+
"django/django": 49,
|
| 114 |
+
"matplotlib/matplotlib": 8,
|
| 115 |
+
"mwaskom/seaborn": 1,
|
| 116 |
+
"psf/requests": 2,
|
| 117 |
+
"pydata/xarray": 7,
|
| 118 |
+
"pylint-dev/pylint": 1,
|
| 119 |
+
"pytest-dev/pytest": 6,
|
| 120 |
+
"scikit-learn/scikit-learn": 4,
|
| 121 |
+
"sphinx-doc/sphinx": 3,
|
| 122 |
+
"sympy/sympy": 16
|
| 123 |
+
},
|
| 124 |
+
"all_repos_of_the_benchmark": [
|
| 125 |
+
"astropy/astropy",
|
| 126 |
+
"django/django",
|
| 127 |
+
"matplotlib/matplotlib",
|
| 128 |
+
"mwaskom/seaborn",
|
| 129 |
+
"pallets/flask",
|
| 130 |
+
"psf/requests",
|
| 131 |
+
"pydata/xarray",
|
| 132 |
+
"pylint-dev/pylint",
|
| 133 |
+
"pytest-dev/pytest",
|
| 134 |
+
"scikit-learn/scikit-learn",
|
| 135 |
+
"sphinx-doc/sphinx",
|
| 136 |
+
"sympy/sympy"
|
| 137 |
+
]
|
| 138 |
+
}
|