mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-06 04:44:19 +01:00
- cockpit: a non-digit Content-Length is a 400 before any read (-1 read an unlimited body before login) - proxy v6.24: the identity wall covers every route and method but /health; a path still escaped after one decode is refused; relayed /server_info loses the engine key fields; an unreadable keys file says so - docs/clients.md: the keys file is installed owned by the user, the engine key goes in an EnvironmentFile - image unit: After= on the text units, so a switch stops before it starts - lifecycle: a down unit with a live container is an orphan, busy for the gate - cockpit: its own /health probe no longer counts as activity (the canary never ran) - install.sh: sudo asked at step 1 and renewed at step 8 with a prompt; CONTEXT_MODE=1m refused on a flash box after the convergence; the flash engine bind is read from the launcher - switch-model.sh: downloads into the cache the installed unit mounts - uninstall.sh, install-image.sh: remove only venv/ and sglang/ of the lane - opencode limits hold the engine window (205000/32000 flash, 173000/64000 native), fit() and the cockpit's verdict and autofit use the same rule, the 27B entry of a flash install comes from the table; collect_opencode has its @guard back - Setup's Fit button has a click handler - bench-agent: the TTFT slope is in the unit it prints - CI: negated grep, generated script lists, exact sudoers argv, flash flags read from install.sh Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
4.2 KiB
Python
98 lines
4.2 KiB
Python
#!/usr/bin/env python3
|
|
"""A switch downloads into the cache the installed engine mounts.
|
|
|
|
switch-model.sh took HF_CACHE from the environment or the default, never from the unit.
|
|
On a box installed with HF_CACHE=/data/hf, the cockpit's Switch (which passes no
|
|
HF_CACHE) downloaded, YaRN-patched and templated into ~/.cache/huggingface, rewrote the
|
|
unit to the new model, and left it mounting /data/hf: the offline engine found no
|
|
checkpoint at its next start and looped under Restart=always, after the script had said
|
|
"Switch queued" (found in review, 2026-09-24). install.sh already reads the mount back.
|
|
|
|
The script runs as written, on a copy whose unit paths point at this test's files, with a
|
|
fake docker that records the download container's argv and then fails, so nothing past
|
|
the download is reached and nothing on the host is touched.
|
|
"""
|
|
import pathlib
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
REPO = pathlib.Path(__file__).resolve().parents[1]
|
|
|
|
FAKE_DOCKER = """#!/bin/sh
|
|
case "$1" in
|
|
image) exit 0 ;; # the serving image is present
|
|
run) printf '%s\\n' "$*" >> "$DOCKER_LOG"; exit 1 ;; # the download "fails": stop here
|
|
esac
|
|
exit 0
|
|
"""
|
|
|
|
|
|
class Box:
|
|
def __init__(self, mount):
|
|
self.t = pathlib.Path(tempfile.mkdtemp(prefix="switch-cache-"))
|
|
self.home = self.t / "home"
|
|
(self.home / ".config/qwen38").mkdir(parents=True)
|
|
units = self.t / "units"
|
|
units.mkdir()
|
|
(units / "qwen38-sglang.service").write_text(
|
|
"[Service]\nExecStart=/bin/bash -c 'exec docker run --rm --name qwen38-sglang \\\n"
|
|
f" -v {mount}:/root/.cache/huggingface \\\n"
|
|
" lmsysorg/sglang@sha256:" + "a" * 64 + " \\\n"
|
|
" python3 -m sglang.launch_server --model-path RadixArk/Qwen3.8-27B-NVFP4 \\\n"
|
|
" --host 127.0.0.1 --port 30000'\n")
|
|
repo = self.t / "repo"
|
|
repo.mkdir()
|
|
(repo / "install.sh").write_text((REPO / "install.sh").read_text())
|
|
text = (REPO / "switch-model.sh").read_text()
|
|
for unit in ("qwen38-sglang.service", "qwen38-flash.service"):
|
|
old = f'"/etc/systemd/system/{unit}"'
|
|
assert old in text, f"switch-model.sh no longer names {unit} that way"
|
|
text = text.replace(old, f'"{units}/{unit}"')
|
|
(repo / "switch-model.sh").write_text(text)
|
|
(repo / "switch-model.sh").chmod(0o755)
|
|
self.bin = self.t / "bin"
|
|
self.bin.mkdir()
|
|
(self.bin / "docker").write_text(FAKE_DOCKER)
|
|
(self.bin / "systemctl").write_text("#!/bin/sh\nexit 1\n") # nothing enabled
|
|
for n in ("docker", "systemctl"):
|
|
(self.bin / n).chmod(0o755)
|
|
self.log = self.t / "docker.log"
|
|
self.script = repo / "switch-model.sh"
|
|
|
|
def switch(self, target, **env):
|
|
e = {"PATH": f"{self.bin}:/usr/bin:/bin", "HOME": str(self.home), "DOCKER_LOG": str(self.log)}
|
|
e.update(env)
|
|
r = subprocess.run([str(self.script), target], capture_output=True, text=True, env=e, timeout=60)
|
|
runs = self.log.read_text().splitlines() if self.log.exists() else []
|
|
return r.returncode, r.stdout + r.stderr, runs
|
|
|
|
|
|
class TheSwitchFollowsTheInstalledCache(unittest.TestCase):
|
|
def test_the_download_goes_where_the_unit_mounts(self):
|
|
box = Box("/data/hf")
|
|
rc, out, runs = box.switch("uncensored")
|
|
self.assertNotEqual(rc, 0, "the fake download fails, so the script stops there")
|
|
self.assertEqual(len(runs), 1, out)
|
|
self.assertIn("-v /data/hf:/hf", runs[0])
|
|
self.assertNotIn(".cache/huggingface:/hf", runs[0])
|
|
|
|
def test_an_explicit_hf_cache_still_wins(self):
|
|
box = Box("/data/hf")
|
|
_, out, runs = box.switch("uncensored", HF_CACHE="/elsewhere/hf")
|
|
self.assertEqual(len(runs), 1, out)
|
|
self.assertIn("-v /elsewhere/hf:/hf", runs[0])
|
|
|
|
def test_the_default_box_is_unchanged(self):
|
|
box = Box(None)
|
|
default = str(box.home / ".cache/huggingface")
|
|
unit = box.t / "units/qwen38-sglang.service"
|
|
unit.write_text(unit.read_text().replace("None", default))
|
|
_, out, runs = box.switch("uncensored")
|
|
self.assertEqual(len(runs), 1, out)
|
|
self.assertIn(f"-v {default}:/hf", runs[0])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(verbosity=2)
|