power-cap-sweep: make CONTAINER optional for host engine builds (#85, #87)

Same engine-coupling fix as a8606e3 applied to power-cap-sweep.sh.
Previously line 129 hard-required CONTAINER to be non-empty, which
blocked host-build llama.cpp users (no docker container) from running
the sweep even with explicit URL + MODEL.

Now: CONTAINER is optional. URL + MODEL are the only hard requirements.
If CONTAINER is unset, defaults to "none" — bench.sh's docker-log
scrape gracefully no-ops on that value (already validated in earlier
work).

Also tightens the error message — explicitly notes "CONTAINER is
optional — set CONTAINER=none for host builds" so a host-build user
hitting a real misconfig (missing URL or MODEL) sees the right hint.

Smoke-tested both branches:

1. CONTAINER=none URL=http://localhost:8030 MODEL=... → runs end-to-end,
   bench actually executes, real measurement captured at 250W cap.

2. PREFLIGHT_NO_AUTODETECT=1 (no URL/MODEL/CONTAINER) → fails fast with
   "could not auto-detect a running URL + MODEL" + the optional-CONTAINER
   hint.

Closes the third script in the harness-engine-decoupling triplet
(verify-full + soak-test landed in a8606e3; verify-stress.sh remaining,
deferred since its docker refs are diagnostic hints not blockers).
This commit is contained in:
noonghunna
2026-05-06 22:24:28 +00:00
parent a8606e3439
commit 2bb3cf7217
+13 -4
View File
@@ -107,7 +107,7 @@ if [ ! -x "$BENCH" ]; then
echo "[error] expected $BENCH" >&2; exit 1
fi
# Auto-detect URL/CONTAINER/MODEL from the running vllm container.
# Auto-detect URL/CONTAINER/MODEL from the running engine.
# This must happen BEFORE we exec bench.sh under our sudo context — bench.sh's
# own autodetect doesn't reliably fire when re-invoked under sudo (env vars
# get stripped, defaults kick in, wrong MODEL → HTTP 404 against the server).
@@ -126,10 +126,19 @@ if [ -z "${MODEL:-}" ] && [ -n "${URL:-}" ]; then
| python3 -c "import sys, json; print(json.load(sys.stdin)['data'][0]['id'])" 2>/dev/null || echo "")
fi
if [ -z "${URL:-}" ] || [ -z "${MODEL:-}" ] || [ -z "${CONTAINER:-}" ]; then
echo "[error] could not auto-detect a running container + URL + MODEL." >&2
# CONTAINER is OPTIONAL — host engine builds (e.g. llama.cpp host server, see
# club-3090#85, #87) have no container. URL + MODEL are the only hard
# requirements. If CONTAINER is unset we mark it "none" for display, which is
# also the value bench.sh expects to skip its docker-log scrape cleanly.
if [ -z "${CONTAINER:-}" ]; then
CONTAINER="none"
fi
if [ -z "${URL:-}" ] || [ -z "${MODEL:-}" ]; then
echo "[error] could not auto-detect a running URL + MODEL." >&2
echo "[hint] start a model server first (bash scripts/switch.sh <variant>)" >&2
echo "[hint] or pass URL=http://... CONTAINER=name MODEL=name as env vars" >&2
echo "[hint] or pass URL=http://... MODEL=name as env vars" >&2
echo "[hint] CONTAINER is optional — set CONTAINER=none for host builds" >&2
echo "[got] URL='${URL:-}' CONTAINER='${CONTAINER:-}' MODEL='${MODEL:-}'" >&2
exit 1
fi