Repository navigation
Expand file tree
/
Copy pathserver-setup.sh
More file actions
executable file
·102 lines (93 loc) · 4.59 KB
/
Copy pathserver-setup.sh
File metadata and controls
executable file
·102 lines (93 loc) · 4.59 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
# Bootstrap the harness on a fresh machine: venv, deps, unit tests. Re-runnable.
# Does NOT build the per-repo backend or run any evaluation -- the full path from
# zero to metrics.json is in SETUP.md.
#
# ./server-setup.sh
#
# Network: nothing here needs the internet except pip, which honours
# PIP_INDEX_URL automatically. Model gateway credentials belong in .env.local
# (gitignored), never inside the repository.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # repository root
say() { printf '\n### %s\n' "$*"; }
warn() { printf '### WARNING: %s\n' "$*" >&2; }
die() { printf '### ERROR: %s\n' "$*" >&2; exit 1; }
# ---- 1. interpreter: >= 3.10 if available (mini-swe-agent needs it), >= 3.9 minimum
PY=""
PY_FALLBACK=""
for c in python3.13 python3.12 python3.11 python3.10 python3; do
command -v "$c" >/dev/null 2>&1 || continue
if "$c" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)'; then
PY="$c"; break
fi
[[ -z "$PY_FALLBACK" ]] && PY_FALLBACK="$c"
done
[[ -n "$PY" ]] || PY="$PY_FALLBACK"
[[ -n "$PY" ]] || die "no python3 interpreter found (>= 3.9 required, >= 3.10 to install mini-swe-agent)"
"$PY" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)' \
|| die "$($PY --version 2>&1): evalkit needs >= 3.9"
# ---- 2. venv + requirements
# Debian and Ubuntu ship python3 without ensurepip, so `python -m venv` fails on
# a stock image. `apt install python3-venv` is the clean fix and is tried first
# in spirit -- but the machines this benchmark actually runs on are shared
# clusters and containers where there is no sudo, so fall back to a venv built
# without pip and bootstrap pip into it instead of stopping the install dead.
bootstrap_pip() { # into an existing pip-less venv
"$HERE/.venv/bin/python" -m ensurepip --upgrade >/dev/null 2>&1 && return 0
local getpip="$HERE/.venv/get-pip.py"
curl -fsSL -o "$getpip" https://bootstrap.pypa.io/get-pip.py \
|| { warn "could not download get-pip.py"; return 1; }
"$HERE/.venv/bin/python" "$getpip" -q
}
if [[ ! -x "$HERE/.venv/bin/python" ]]; then
say "creating .venv ($($PY --version 2>&1))"
if ! "$PY" -m venv "$HERE/.venv" 2>/dev/null; then
warn "python -m venv failed (no ensurepip?); retrying without pip"
rm -rf "$HERE/.venv"
"$PY" -m venv --without-pip "$HERE/.venv" \
|| die "venv creation failed (Debian/Ubuntu: apt install python3-venv)"
fi
fi
if [[ ! -x "$HERE/.venv/bin/pip" ]]; then
say "bootstrapping pip into .venv"
bootstrap_pip || die "the venv has no pip and it could not be bootstrapped \
(Debian/Ubuntu: apt install python3-venv, or make bootstrap.pypa.io reachable)"
fi
say "pip install -r requirements.txt"
"$HERE/.venv/bin/pip" install -q -U pip
if "$HERE/.venv/bin/python" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)'; then
"$HERE/.venv/bin/pip" install -q -r "$HERE/requirements.txt"
else
warn "python < 3.10: installing without mini-swe-agent (gold/null adapters still work)"
grep -vi 'mini-swe-agent' "$HERE/requirements.txt" > "$HERE/.venv/requirements.mini.txt"
"$HERE/.venv/bin/pip" install -q -r "$HERE/.venv/requirements.mini.txt"
fi
# ---- 3. host tooling for the local backend (docker is NOT required)
for b in conda git curl; do
command -v "$b" >/dev/null 2>&1 || warn "$b not found on PATH -- checkout + env builds need it"
done
avail_kb="$(df -k "$HERE" | awk 'NR==2 {print $4}')"
if [[ "$avail_kb" =~ ^[0-9]+$ && "$avail_kb" -lt 8388608 ]]; then
warn "only $((avail_kb / 1024 / 1024)) GiB free -- the local backend needs ~2 GiB per repository, ~25-30 GiB for all 15"
fi
# ---- 4. the task package: not in git, because gold/ and test.py are the oracle
BENCH_ROOT="$("$HERE/.venv/bin/python" -c 'from evalkit import BENCH_ROOT; print(BENCH_ROOT)')"
if [[ ! -d "$BENCH_ROOT" ]]; then
warn "no task package at $BENCH_ROOT"
printf ' python -m evalkit.hub download --repo-id risemds03/RepoReuse\n'
printf ' # or point EVALKIT_BENCH at a copy you already have\n'
fi
# ---- 5. smoke: the package imports and the parsers pass their unit tests
say "unit tests"
(cd "$HERE" && .venv/bin/python -m pytest evalkit/tests/ -q)
say "OK. next steps (full walkthrough: README.md, SETUP.md):"
cat <<EOF
cd "$HERE"
python -m evalkit.hub download --repo-id risemds03/RepoReuse # the task package
[[ -f .env.local ]] || cp .env.example .env.local
\${EDITOR:-vi} .env.local
./run_eval.sh --smoke
# Then: ./run_eval.sh # mini-swe, all tasks
# Or: ./run_eval.sh --agents mini-swe,opencode
EOF