-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_batches.sh
More file actions
82 lines (69 loc) · 1.89 KB
/
run_batches.sh
File metadata and controls
82 lines (69 loc) · 1.89 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
START="${START:-1}"
END_TOTAL="${END_TOTAL:-69}"
BATCH_SIZE="${BATCH_SIZE:-3}"
BASE_URL="${OPENCLAW_BASE_URL:-http://127.0.0.1:18789}"
TOKEN="${OPENCLAW_GATEWAY_TOKEN:-}"
if [[ -z "${TOKEN}" ]]; then
echo "OPENCLAW_GATEWAY_TOKEN is required"
exit 1
fi
OUT_DIR="${OUT_DIR:-}"
if [[ -z "${OUT_DIR}" ]]; then
if [[ -d "output" ]]; then
OUT_DIR="output"
elif [[ -d "bench_output" ]]; then
OUT_DIR="bench_output"
else
OUT_DIR="output"
fi
fi
task_name_by_index() {
local idx="$1"
uv run python - "$idx" <<'PY'
import sys
from skill_bench_eval import get_available_tasks
idx = int(sys.argv[1])
tasks = get_available_tasks()
if idx < 1 or idx > len(tasks):
raise SystemExit(f"invalid task index: {idx} (available: 1..{len(tasks)})")
print(tasks[idx - 1].name)
PY
}
wait_for_result_json() {
local task_name="$1"
local timeout_s="${2:-60}"
local end_ts="$(( $(date +%s) + timeout_s ))"
local p="${OUT_DIR}/${task_name}/result.json"
while [[ "$(date +%s)" -lt "${end_ts}" ]]; do
if [[ -f "${p}" ]]; then
return 0
fi
sleep 2
done
return 1
}
s="${START}"
while [[ "${s}" -le "${END_TOTAL}" ]]; do
e="$(( s + BATCH_SIZE - 1 ))"
if [[ "${e}" -gt "${END_TOTAL}" ]]; then
e="${END_TOTAL}"
fi
end_task="$(task_name_by_index "${e}")"
echo "=== Running tasks ${s}-${e} (end task: ${end_task}) ==="
uv run skill_bench_eval.py run --start "${s}" --end "${e}" --token "${TOKEN}" --base-url "${BASE_URL}"
if [[ -d "${OUT_DIR}" ]]; then
du -sh "${OUT_DIR}" || true
fi
if wait_for_result_json "${end_task}" 60; then
echo "=== Completed batch ${s}-${e} ==="
else
echo "=== Batch ${s}-${e} finished but ${OUT_DIR}/${end_task}/result.json not found ==="
exit 2
fi
s="$(( e + 1 ))"
done
echo "=== Done: tasks ${START}-${END_TOTAL} ==="