File size: 2,514 Bytes
8507a20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Score again, alone, every instance whose scoring errored, and add what resolves to the run's summary.
# Two things make an instance's scoring error on a busy machine: a docker call that times out while hundreds of other
# containers start and stop, and one scikit-learn test of the subset that collapses when its cores are shared. Here
# one instance runs at a time on 16 cores of its own, set before its tests start, with up to three tries.
# Every run is treated the same way, the comparison model's run included.
#   LABEL=stock-1 [OUT=...] [LANE=0|1] bash eval/rescore.sh
set -u
R=/data/train/mini
P=$R/venv/bin/python
LABEL=${LABEL:?give LABEL}; OUT=${OUT:-$R/results/agent/$LABEL}; LANE=${LANE:-0}
CORES=$((LANE * 16))-$((LANE * 16 + 15))
cd "$OUT" || exit 1
IDS=$($P $R/src/eval/rescore_merge.py ids "$OUT" "$LABEL")
[ -z "$IDS" ] && exit 0
mkdir -p "$OUT/rescore"
cd "$OUT/rescore" || exit 1            # the harness writes its report and logs into the folder it runs in
if ! ls "$OUT"/rescore/*.json >/dev/null 2>&1; then
    for try in 1 2 3; do
        rm -f .pinned
        ( end=$((SECONDS + 1500))
          while [ $SECONDS -lt $end ]; do
              for c in $(/usr/bin/docker ps --format '{{.Names}}' | grep -F ".$LABEL-rescore"); do
                  grep -qxF "$c" .pinned 2>/dev/null && continue
                  /usr/bin/docker update --cpus 0 --cpuset-cpus "$CORES" "$c" >/dev/null 2>&1 && echo "$c" >> .pinned
              done
              sleep 0.3
          done ) &
        W=$!
        rm -f ./*."$LABEL-rescore".json
        # shellcheck disable=SC2086
        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 \
            --dataset_name princeton-nlp/SWE-bench_Verified --split test --predictions_path "$OUT/preds.json" --run_id "$LABEL-rescore" \
            --max_workers 1 --timeout 900 --namespace swebench --instance_ids $IDS > score-$try.log 2>&1
        kill $W 2>/dev/null
        sudo -n chown -R "$USER":"$USER" "$OUT" 2>/dev/null
        # shellcheck disable=SC2086
        ls ./*."$LABEL-rescore".json >/dev/null 2>&1 || $P $R/src/eval/instance_report.py "$OUT/rescore" "$LABEL-rescore" "$OUT/preds.json" \
            "instances.$LABEL-rescore.json" --ids $IDS >> score-$try.log 2>&1
        [ -z "$($P $R/src/eval/rescore_merge.py errors "$OUT" "$LABEL")" ] && break
    done
    echo "tries: $try" > tries.txt
fi
$P $R/src/eval/rescore_merge.py merge "$OUT" "$LABEL"