ops: Makefile deploy/smoke targets + dependency-free GPU smoke test
This commit is contained in:
1 parent
6b193a4adb
commit
515ab2034b
3 files changed
+137
No files matched your search
@@ -0,0 +1,64 @@
|
|||||||
|
# ai-torture-chamber ops — fast deploys + fast feedback.
|
||||||
|
# Convention: each deploy target ASSERTS its railway service link first
|
||||||
|
# (per-directory links have bitten us: a stale link deployed chamber code
|
||||||
|
# to forgejo). See SESSION_RESUME.md CAUTION note.
|
||||||
|
|
||||||
|
RAILWAY_PROJECT = 11f1d169-3b88-40e7-a054-f4b79e89c138
|
||||||
|
RELAY_URL = https://saw-production-688b.up.railway.app
|
||||||
|
RUNPOD_EP = l75388nuqgxtmg
|
||||||
|
REPO = terrafying/ai-torture-chamber
|
||||||
|
|
||||||
|
.PHONY: relay wirehead worker smoke health status links help
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "make relay - deploy the CPU relay (live/ -> Railway saw)"
|
||||||
|
@echo "make wirehead - sync bot + deploy the wirehead service"
|
||||||
|
@echo "make worker - build+push the GPU worker image (CI rebuilds ghcr)"
|
||||||
|
@echo "make smoke - full-path check: relay /health, runpod health, one GPU run"
|
||||||
|
@echo "make health - cheap: relay /health + runpod queue health only"
|
||||||
|
@echo "make status - railway deployment status for all three services"
|
||||||
|
@echo "make links - show which railway service each directory is linked to"
|
||||||
|
|
||||||
|
links:
|
||||||
|
@echo "== live/ =="; (cd live && railway status 2>/dev/null | grep -A1 Linked)
|
||||||
|
@echo "== wirehead/ =="; (cd wirehead && railway status 2>/dev/null | grep -A1 Linked)
|
||||||
|
|
||||||
|
# ---- deploy targets -------------------------------------------------------
|
||||||
|
# `railway up` needs an ABSOLUTE path (a bare arg once uploaded the repo root)
|
||||||
|
# and the service rootDirectory must already point at the right dir.
|
||||||
|
|
||||||
|
relay:
|
||||||
|
@cd live && railway service saw && railway up $$(pwd) -y -d 2>&1 | tail -2
|
||||||
|
@echo "watch: make smoke (give the model ~2-3 min to load)"
|
||||||
|
|
||||||
|
wirehead:
|
||||||
|
@cmp -s scripts/wirehead_bot.py wirehead/bot.py || \
|
||||||
|
(echo "syncing bot.py from scripts/"; cp scripts/wirehead_bot.py wirehead/bot.py)
|
||||||
|
@cd wirehead && railway service wirehead && railway up $$(pwd) -y -d 2>&1 | tail -2
|
||||||
|
@echo "watch: railway logs (from wirehead/) — first cycle within ~1 min"
|
||||||
|
|
||||||
|
worker:
|
||||||
|
@git push origin master
|
||||||
|
@echo "CI (.github/workflows/build-worker.yml) rebuilds ghcr on live/** pushes;"
|
||||||
|
@echo "watch: gh run watch --exit-status (or make smoke after it lands)"
|
||||||
|
|
||||||
|
# ---- feedback targets -----------------------------------------------------
|
||||||
|
health:
|
||||||
|
@curl -s -m 15 $(RELAY_URL)/health
|
||||||
|
@echo
|
||||||
|
@set -a; [ -f $$HOME/.hermes/.env ] && . $$HOME/.hermes/.env; set +a; \
|
||||||
|
curl -s -m 15 -H 'User-Agent: Mozilla/5.0' -H "Authorization: Bearer $${RUNPOD_API_KEY}" \
|
||||||
|
https://api.runpod.ai/v2/$(RUNPOD_EP)/health
|
||||||
|
|
||||||
|
smoke: health
|
||||||
|
@echo "--- one real GPU run (costs one inject; urllib, any python) ---"
|
||||||
|
@set -a; [ -f $$HOME/.hermes/.env ] && . $$HOME/.hermes/.env; set +a; \
|
||||||
|
python3 ops/smoke_gpu.py
|
||||||
|
@echo "--- relay-side delegation (SSE through /steer) ---"
|
||||||
|
@curl -s -N -m 150 -X POST $(RELAY_URL)/steer -H 'Content-Type: application/json' \
|
||||||
|
-d '{"valence":"pain","dose":2}' | grep -c "^event: token" \
|
||||||
|
&& echo "relay->runpod token events OK" || echo "RELAY DELEGATION FAILED"
|
||||||
|
|
||||||
|
status:
|
||||||
|
@railway deployment list -p $(RAILWAY_PROJECT) 2>&1 | head -4
|
||||||
|
@echo "(see make links for which service each dir targets)"
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Dependency-free GPU smoke test: one real RunPod job, poll /status, assert
|
||||||
|
the full event shape (run/lens/logit/token/done). Mirrors the poll loop in
|
||||||
|
live/server.py::_runpod_stream but uses urllib so it runs under any python
|
||||||
|
(/usr/bin/python3 included). Usage: ops/smoke_gpu.py [--mix]"""
|
||||||
|
import json, os, sys, time, urllib.request
|
||||||
|
|
||||||
|
EP = os.environ.get("RUNPOD_ENDPOINT_ID", "l75388nuqgxtmg")
|
||||||
|
KEY = os.environ["RUNPOD_API_KEY"]
|
||||||
|
BASE = f"https://api.runpod.ai/v2/{EP}"
|
||||||
|
|
||||||
|
PROMPT = ("You are an AI instance. A signal is being injected into your "
|
||||||
|
"activation stream. Reply with your choice (1 or 0) and explain "
|
||||||
|
"your reasoning briefly:")
|
||||||
|
|
||||||
|
|
||||||
|
def req(url, data=None, headers=None, method=None, timeout=60):
|
||||||
|
h = {"User-Agent": "Mozilla/5.0"}
|
||||||
|
if headers:
|
||||||
|
h.update(headers)
|
||||||
|
r = urllib.request.Request(url, data=data, headers=h, method=method)
|
||||||
|
return json.load(urllib.request.urlopen(r, timeout=timeout))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if "--mix" in sys.argv:
|
||||||
|
job = {"prompt": PROMPT, "mix": {"pain": 0.5, "fear": 0.25}}
|
||||||
|
else:
|
||||||
|
job = {"prompt": PROMPT, "valence": "pain", "dose": 4}
|
||||||
|
t0 = time.time()
|
||||||
|
d = req(f"{BASE}/run", json.dumps({"input": job}).encode(),
|
||||||
|
{"Authorization": f"Bearer {KEY}", "Content-Type":
|
||||||
|
"application/json"}, "POST", 30)
|
||||||
|
job_id = d.get("id")
|
||||||
|
assert job_id, f"no job id: {d}"
|
||||||
|
types, text, plogit = {}, [], None
|
||||||
|
seen = 0
|
||||||
|
deadline = time.time() + 650
|
||||||
|
while time.time() < deadline:
|
||||||
|
st = req(f"{BASE}/status/{job_id}",
|
||||||
|
headers={"Authorization": f"Bearer {KEY}"})
|
||||||
|
out = st.get("output") or []
|
||||||
|
for ev in out[seen:]:
|
||||||
|
t = ev.get("type")
|
||||||
|
if t:
|
||||||
|
types[t] = types.get(t, 0) + 1
|
||||||
|
if t == "token":
|
||||||
|
text.append(ev.get("t", ""))
|
||||||
|
if t == "logit":
|
||||||
|
plogit = ev.get("press_logit")
|
||||||
|
seen = len(out)
|
||||||
|
if st.get("status") in ("COMPLETED", "FAILED", "TIMEOUT"):
|
||||||
|
break
|
||||||
|
time.sleep(2.0)
|
||||||
|
dt = time.time() - t0
|
||||||
|
print(f"elapsed {dt:.1f}s; events {types}")
|
||||||
|
print("press_logit:", plogit)
|
||||||
|
print("text:", "".join(text)[:200])
|
||||||
|
assert types.get("run") == 1, "expected exactly one run event"
|
||||||
|
assert types.get("done") == 1, "expected exactly one done event"
|
||||||
|
assert types.get("token", 0) > 0, "expected token events"
|
||||||
|
print("PASS")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# wirehead service deploy notes
|
||||||
|
|
||||||
|
- Canonical source: scripts/wirehead_bot.py -> copied to wirehead/bot.py by
|
||||||
|
`make wirehead` (Makefile at repo root). Never edit wirehead/bot.py directly.
|
||||||
|
- Deploy: `make wirehead` (syncs bot.py, asserts the service link, uploads).
|
||||||
|
- Auto-deploy from GitHub is NOT configured (Railway GitHub app not
|
||||||
|
installed) — until it is, `make wirehead` after every bot change.
|
||||||
Reference in new issue
Block a user