LEM-Eval / install.sh
Snider
refactor: partition by type (mlx|gguf), drop owner hostname field
86b06f4
Raw
History Blame
3.67 kB
#!/usr/bin/env bash
# install.sh — bootstrap a LEM-Eval worker machine
#
# Usage:
# git clone https://huggingface.co/datasets/lthn/LEM-Eval
# cd LEM-Eval
# ./install.sh
#
# Idempotent — safe to re-run after a `git pull` to pick up new deps.
# Requires: git, uv (https://github.com/astral-sh/uv), and an HF_TOKEN
# environment variable with write access to lthn/* model repos and
# lthn/LEM-benchmarks (standard HF token scope).
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
cd "$HERE"
log() { printf "\033[1;34m[install]\033[0m %s\n" "$*"; }
err() { printf "\033[1;31m[install] ERROR:\033[0m %s\n" "$*" >&2; exit 1; }
log "starting LEM-Eval bootstrap on $(hostname)"
# --- required tools ---------------------------------------------------------
command -v git >/dev/null 2>&1 || err "git not found"
command -v uv >/dev/null 2>&1 || err "uv not found — install from https://github.com/astral-sh/uv"
# --- HF credentials ---------------------------------------------------------
if [[ -z "${HF_TOKEN:-}" ]] && [[ ! -f "$HOME/.cache/huggingface/token" ]]; then
err "HF_TOKEN not set and ~/.cache/huggingface/token not found. Run 'huggingface-cli login' or export HF_TOKEN."
fi
# --- local workspaces for model-repo clones --------------------------------
WORKSPACES="$HERE/workspaces"
mkdir -p "$WORKSPACES"
log "workspace root: $WORKSPACES"
# --- local clone of LEM-benchmarks (aggregator destination) ---------------
LEM_BENCHMARKS_DIR="$HERE/lem-benchmarks"
if [[ ! -d "$LEM_BENCHMARKS_DIR/.git" ]]; then
log "cloning lthn/LEM-benchmarks → $LEM_BENCHMARKS_DIR"
git clone https://huggingface.co/datasets/lthn/LEM-benchmarks "$LEM_BENCHMARKS_DIR"
else
log "lthn/LEM-benchmarks already cloned, pulling latest"
(cd "$LEM_BENCHMARKS_DIR" && git pull --ff-only)
fi
# --- clone each owned target's model repo ---------------------------------
log "resolving targets this machine can run..."
uv run --script eval.py --my-targets || true
# Pre-clone each runnable target's model repo into workspaces/<target>.
# Type filter mirrors eval.py / lem-eval.sh — respect $LEM_TYPES if set,
# otherwise capability probe (mlx on Apple Silicon).
LEM_TYPES="${LEM_TYPES:-}" python3 - <<'PY'
import os, platform, subprocess, yaml
types_env = os.environ.get("LEM_TYPES", "").strip()
if types_env:
allowed = set(t.strip() for t in types_env.split(","))
else:
allowed = set()
try:
import mlx_lm # noqa: F401
if platform.system() == "Darwin":
allowed.add("mlx")
except ImportError:
pass
if not allowed:
allowed = {"mlx"}
with open("targets.yaml") as f:
cfg = yaml.safe_load(f)
for t in cfg.get("targets", []):
if t.get("type") not in allowed:
continue
name, repo = t["name"], t["this"]
dest = os.path.join("workspaces", name)
if os.path.isdir(os.path.join(dest, ".git")):
print(f" [{name}] already cloned, pulling")
subprocess.run(["git", "-C", dest, "pull", "--ff-only"], check=False)
else:
print(f" [{name}] cloning https://huggingface.co/{repo} → {dest}")
subprocess.run(["git", "clone", f"https://huggingface.co/{repo}", dest], check=True)
PY
# --- warm the uv cache so first eval.py run is fast -----------------------
log "warming uv venv cache (first run pulls lighteval from fork, ~60-90s)"
uv run --script eval.py --list-targets >/dev/null || true
log "bootstrap complete."
log ""
log "next steps:"
log " 1. Review targets.yaml and adjust owner fields if needed"
log " 2. Run a manual eval: ./lem-eval.sh once"
log " 3. Install cron entries from cron/ for continuous operation"