mirror of
https://github.com/hasso5703/alzeo.git
synced 2026-12-05 12:24:28 +01:00
install, update: what an independent review found in this version, each with its test
A Load that prepares its lane is seen by an install (prepare-lane.sh becomes the lane's installer), and a script open in an editor is not one. A clone's path is refused for what breaks the cockpit's unit, not for an accent, and not with no cockpit. An image lane started by hand is not restarted under a run that says it stops none. A Download moves no refs/main. The user's opencode.jsonc counts in what restarts the agent's server, and one that names no provider of this box is not the fit's. HTTP_PROXY alone counts too, and the fit asks the engine straight. A checkpoint whole in a cache with no links asks no room. The record of a text lane goes with its units. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e22e96e44
commit
f3a2818065
14 files changed
+250
-60
No files matched your search
+2
-1
@@ -53,7 +53,8 @@ uninstalled), `./install.sh` and the one-liner took the 27B for the box's lane,
|
||||
weights again when Library had deleted them. Beside a lane started by hand they stopped it (the other text lane) or died at
|
||||
step 9 with the 27B enabled (a side lane): systemd refuses a restart beside an active unit it conflicts with both ways
|
||||
("Transaction order is cyclic", proved with stand-in units on systemd 255). Such a run now starts, enables and stops nothing,
|
||||
downloads nothing it was not asked for, keeps opencode's default on the lane it names, and says how to load one;
|
||||
downloads nothing it was not asked for, says how to load one, and with no lane at boot keeps opencode's default on the lane
|
||||
it names;
|
||||
`MODEL_CHOICE=` and `--recommended` still name the lane to serve. A lane is stopped then started, never restarted beside
|
||||
another, and a new box's install cut before its own unit is no flash box to the next run, which asked 230 GiB and fetched
|
||||
152 GB. Held by a bench that runs install.sh whole against a systemd that refuses what the real one refuses.
|
||||
|
||||
+18
-8
@@ -136,6 +136,15 @@ def download(repo, rev, kw):
|
||||
constants.HF_HUB_DISABLE_XET = True
|
||||
|
||||
|
||||
def whole_here(repo, rev, kw):
|
||||
"""The revision's folder in the cache when it is whole there, None otherwise."""
|
||||
try:
|
||||
path = snapshot_download(repo, revision=rev, local_files_only=True, **kw)
|
||||
return path if complete(path, kw.get("allow_patterns")) else None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def left_to_fetch(repo, rev, kw):
|
||||
"""The bytes of this revision's files that the cache does not hold, by the sizes the Hub gives; None when it does not
|
||||
answer, or gives no size for one of them: never what a fetch waits on."""
|
||||
@@ -158,7 +167,7 @@ def disk_left(path):
|
||||
return None
|
||||
|
||||
|
||||
def room(repo, rev, kw, need_gb, free_gb):
|
||||
def room(repo, rev, kw, need_gb, free_gb, known=False):
|
||||
"""Refused before the first byte rather than stopped by a full disk halfway. First by what this
|
||||
revision lacks (left_to_fetch), with a twentieth more, 1 GB at most, on the disk as it is: the
|
||||
blobs of the repository's other revisions do not count, as they did for a pin that moved, whose
|
||||
@@ -171,6 +180,10 @@ def room(repo, rev, kw, need_gb, free_gb):
|
||||
if lacks is not None:
|
||||
free = free_gb * 2**30 if free_gb else disk_left(constants.HF_HUB_CACHE)
|
||||
if lacks and free is not None and free < lacks + min(lacks // 20, 10**9):
|
||||
# refused, unless it is whole (known: looked for already): in a cache with no links (exFAT, a share), the blobs
|
||||
# say nothing of it
|
||||
if not known and whole_here(repo, rev, kw) is not None:
|
||||
return
|
||||
raise SystemExit(f"{free // 2**30} GiB free in the cache, and {repo} needs about {-(-lacks // 10**9)} GB more: "
|
||||
"free some space first")
|
||||
return
|
||||
@@ -180,6 +193,8 @@ def room(repo, rev, kw, need_gb, free_gb):
|
||||
have = sum(e.stat().st_size for e in os.scandir(blobs) if e.is_file()) if os.path.isdir(blobs) else 0
|
||||
rest = max(need_gb * 10**9 - have, 10**9)
|
||||
if free_gb * 2**30 < rest:
|
||||
if not known and whole_here(repo, rev, kw) is not None:
|
||||
return
|
||||
raise SystemExit(f"{free_gb} GiB free in the cache, and {repo} needs about {-(-rest // 10**9)} GB more: "
|
||||
"free some space first")
|
||||
|
||||
@@ -225,16 +240,11 @@ def main():
|
||||
kw = {"allow_patterns": a.allow.split()} if a.allow.split() else {}
|
||||
path = None
|
||||
if a.offline_first:
|
||||
try:
|
||||
path = snapshot_download(a.repo, revision=a.rev, local_files_only=True, **kw)
|
||||
if not complete(path, kw.get("allow_patterns")):
|
||||
path = None
|
||||
except Exception:
|
||||
path = None
|
||||
path = whole_here(a.repo, a.rev, kw)
|
||||
if path is None:
|
||||
print("not complete in the cache, fetching the rest", flush=True)
|
||||
if path is None:
|
||||
room(a.repo, a.rev, kw, a.need_gb, a.free_gb)
|
||||
room(a.repo, a.rev, kw, a.need_gb, a.free_gb, known=a.offline_first)
|
||||
with reporting(a.repo, revision=a.rev, **kw):
|
||||
for attempt in range(1, ATTEMPTS + 1): # a new attempt keeps every file already whole
|
||||
try:
|
||||
|
||||
@@ -340,8 +340,9 @@ ON_DISK="${OC_VERSION##* }"
|
||||
KEPT_FILE="$HOME/.config/qwen38/opencode-web.kept"
|
||||
STARTED="$(systemctl show -p ExecMainStartTimestamp --value --timestamp=unix "$UNIT" 2>/dev/null | tr -dc '0-9' || true)"
|
||||
READ_CONFIGS=()
|
||||
for which in artifact user; do
|
||||
case "$which" in artifact) f="$HOME/.config/qwen38/opencode.json" ;; *) f="$HOME/.config/opencode/opencode.json" ;; esac
|
||||
# the user's .jsonc too, which wins over their .json and which the limits are written in (2026-11-30)
|
||||
for f in "$HOME/.config/qwen38/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc"; do
|
||||
case "$f" in "$HOME/.config/qwen38/"*) which=artifact ;; *) which=user ;; esac
|
||||
if [ -n "$STARTED" ] && [ -f "$f" ] && [ -f "$KEPT_FILE" ] \
|
||||
&& grep -qxF "$which $(sha256sum < "$f" | cut -d' ' -f1) $STARTED" "$KEPT_FILE"; then
|
||||
continue
|
||||
|
||||
+4
-2
@@ -229,7 +229,7 @@ install_service(){
|
||||
same) echo "unit unchanged"
|
||||
sudo chmod 644 "$INSTALLED" ;; # a unit installed before this fix is still 0600
|
||||
deps) sudo systemctl daemon-reload
|
||||
echo "unit updated: only the lines naming the other lanes changed, which the lane does not read" ;;
|
||||
echo "unit updated: only lines the lane does not read changed (the other lanes it names, its checkpoint's revision)" ;;
|
||||
*) sudo systemctl daemon-reload
|
||||
echo "unit installed at $INSTALLED" ;;
|
||||
esac
|
||||
@@ -241,7 +241,9 @@ install_service(){
|
||||
# A serving image lane restarts to run them (Hasan, 2026-10-30, v1.40.6): about 70 s, and an image being made
|
||||
# then is lost. Its own sockets' filter came in with a unit, which a lane that kept serving never read. The
|
||||
# video lane, 12 to 15 min to boot, keeps its NOTE.
|
||||
if [ "$SMOKE" -eq 0 ] && lane_serves_older "$UNIT" "${LANE_FILES[@]}"; then
|
||||
if [ "$SMOKE" -eq 0 ] && [ -n "${QWEN38_KEEPS_SERVING:-}" ] && lane_serves_older "$UNIT" "${LANE_FILES[@]}"; then
|
||||
echo "NOTE: the image lane, started by hand, goes on serving with the files it started with: its next start takes the new ones"
|
||||
elif [ "$SMOKE" -eq 0 ] && lane_serves_older "$UNIT" "${LANE_FILES[@]}"; then
|
||||
echo "the image lane serves older files than the ones installed now (its unit, its runtime or its start scripts): restarting it (about 70 s)"
|
||||
sudo systemctl restart "$UNIT" \
|
||||
|| echo "NOTE: the image lane did not restart; it runs the older files until: sudo systemctl restart $UNIT"
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ install_service(){
|
||||
same) echo "unit unchanged"
|
||||
sudo chmod 644 "$INSTALLED" ;; # a unit installed before this fix is still 0600
|
||||
deps) sudo systemctl daemon-reload
|
||||
echo "unit updated: only the lines naming the other lanes changed, which the lane does not read" ;;
|
||||
echo "unit updated: only lines the lane does not read changed (the other lanes it names, its checkpoint's revision)" ;;
|
||||
*) sudo systemctl daemon-reload
|
||||
echo "unit installed at $INSTALLED" ;;
|
||||
esac
|
||||
|
||||
+13
-6
@@ -1245,6 +1245,7 @@ if [ -z "$SECONDARY" ] && [ "$NO_SERVICE" -eq 0 ] && [ -z "$_ENV_MODEL_CHOICE" ]
|
||||
fi
|
||||
if [ -z "$STARTS_NONE" ] && [ -n "$SERVES" ] && [ "$NO_START" -eq 0 ]; then STARTS_NONE=beside; fi
|
||||
fi
|
||||
[ -z "$STARTS_NONE" ] || export QWEN38_KEEPS_SERVING=1 # to the image lane's installer, which restarts a lane that serves older files
|
||||
if [ "$FLASH_READABLE" -eq 1 ] && [ "$FLASH_ENABLED" -eq 1 ] && [ "$SGL_ENABLED" -eq 1 ]; then
|
||||
echo "NOTE: both qwen38-sglang and qwen38-flash are enabled (only one can serve the port)."
|
||||
echo " Following the 27B unit; run ./switch-model.sh to resolve this cleanly."
|
||||
@@ -2193,15 +2194,18 @@ step "1/10 Preflight checks"
|
||||
# `bash -c` line, in a docker `-v src:dst`, and in systemd's own syntax, where % is a
|
||||
# specifier. A space, a colon, a quote, a $ or a % in one was accepted and broke the
|
||||
# unit it went into, seen only when that failed to start (found in review, 2026-09-24).
|
||||
# the clone too, for the cockpit's unit, which runs from it (2026-11-30)
|
||||
_paths=("HOME=$HOME" "HF_CACHE=$HF_CACHE" "PLE_DIR=$PLE_DIR"); [ "$NO_COCKPIT" -eq 1 ] || _paths+=("REPO_DIR=$REPO_DIR")
|
||||
for _p in "${_paths[@]}"; do
|
||||
for _p in "HOME=$HOME" "HF_CACHE=$HF_CACHE" "PLE_DIR=$PLE_DIR"; do
|
||||
case "${_p#*=}" in
|
||||
/*) case "${_p#*=}" in *[!A-Za-z0-9._/+@-]*) die "${_p%%=*}=${_p#*=}: the units this installs cannot carry that path. Use an absolute path of letters, digits and . _ / + @ - only." ;; esac ;;
|
||||
*) die "${_p%%=*}=${_p#*=}: an absolute path is needed (the units carry it as it is)." ;;
|
||||
esac
|
||||
done
|
||||
unset _p _paths
|
||||
unset _p
|
||||
# The clone too, for the cockpit's unit, which runs from it: what systemd, or the sed that renders it, reads as its own
|
||||
# (2026-11-30). A letter with an accent is none of them.
|
||||
if [ "$COCKPIT" -eq 1 ]; then
|
||||
case "$REPO_DIR" in *[[:space:]\"\'\$%\\\|\&:]*) die "this clone's path, $REPO_DIR, has a space, a quote or one of \$ % \\ | & : in it: the cockpit's unit, which runs from it, cannot carry that. Move the clone, or leave the cockpit out (--no-cockpit)." ;; esac
|
||||
fi
|
||||
for _p in "$HF_CACHE" "$PLE_DIR"; do
|
||||
_m="$(unmounted_disk_of "$_p")"
|
||||
[ -z "$_m" ] || die "$_p is on $_m, which /etc/fstab mounts and is not mounted now: its weights would be downloaded again onto the system disk. Mount it (sudo mount $_m), then run this again."
|
||||
@@ -2235,6 +2239,9 @@ docker_grant bash "$REPO_DIR/${BASH_SOURCE[0]##*/}" "$@"
|
||||
# this run, said to the cockpit while it lasts (lanes.sh, run_mark); the run it starts for the other
|
||||
# text lane is part of it
|
||||
[ -n "$SECONDARY" ] || run_mark "$CONFIG_DIR"; trap forget_run_mark EXIT
|
||||
# The record of the text lane a box had at boot means nothing on one whose units are gone (an uninstall up to v1.59.0 left
|
||||
# it): read by the run after this one, cut before its own unit, it said that somebody had taken that boot away.
|
||||
[ -n "$SECONDARY" ] || [ -f "$SGL_UNIT_PATH" ] || [ -f "$FLASH_UNIT_PATH" ] || rm -f "$CONFIG_DIR/text-lane"
|
||||
if [ -z "$SECONDARY" ]; then
|
||||
BESIDE="$(runs_beside "$CONFIG_DIR")"
|
||||
[ -z "$BESIDE" ] || die "this box is busy with $(printf '%s' "$BESIDE" | paste -sd ',' | sed 's/,/, /g'): an install now would cut it or meet it half way. Run this again once it is done (the cockpit's Now view says when)."
|
||||
@@ -2895,7 +2902,7 @@ step "7/10 opencode provider config + oc launcher"
|
||||
# is not there yet is part of the answer, not a failure: cat fails on a missing file, and
|
||||
# under pipefail that failed the assignment, so set -e ended every first install here,
|
||||
# where neither file exists yet (v1.18.7 on a box with nothing installed, 2026-09-30).
|
||||
oc_configs_sum(){ { cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum; }
|
||||
oc_configs_sum(){ { cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum; }
|
||||
OC_SUM_BEFORE="$(oc_configs_sum)"
|
||||
# ── opencode itself, at the pinned version (see the OPENCODE_VERSION pin) ─────────
|
||||
# Absent: the release asset is downloaded, checked against its pinned sha256 and put
|
||||
@@ -4584,6 +4591,7 @@ else
|
||||
beside) STAYS="the $SERVES_NAME lane goes on serving" ;;
|
||||
esac
|
||||
ENDS="$STAYS"; [ -n "$ENDS" ] || ENDS="the $SERVING_LANE lane stays this box's serving lane"
|
||||
[ "${WAITS_LOAD:-0}" -eq 0 ] || ENDS="all but what its next Load downloads and puts in place ($WAITS_WHAT); $ENDS"
|
||||
if [ -n "$ATS_CANNOT" ]; then
|
||||
step "Done: this box is up to date, and its flash lane, which this GPU cannot start, was not started"
|
||||
echo " why : $ATS_CANNOT"
|
||||
@@ -4638,7 +4646,6 @@ else
|
||||
esac
|
||||
else
|
||||
step "Done: the text lane is up to date; $ENDS"
|
||||
[ "$WAITS_LOAD" -eq 0 ] || echo " its update waits for its next Load, which downloads what it needs: $WAITS_WHAT"
|
||||
if [ "$STARTS_NONE" = beside ] && systemctl is-enabled --quiet "$UNIT_NAME" 2>/dev/null; then
|
||||
echo " text lane : installed as $UNIT_NAME, enabled at boot as before, not started"
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ LANES_UNIT_DIR="${LANES_UNIT_DIR:-/etc/systemd/system}"
|
||||
# Through a company proxy (http_proxy, and no no_proxy), curl sent each local probe there, the box's key in its
|
||||
# Authorization header, and took the proxy's page for the engine's answer (found 2026-11-30): this box's own addresses
|
||||
# never go through one, for every script that sources this one.
|
||||
if [ -n "${http_proxy:-}${https_proxy:-}${HTTPS_PROXY:-}${all_proxy:-}${ALL_PROXY:-}" ]; then
|
||||
if [ -n "${http_proxy:-}${HTTP_PROXY:-}${https_proxy:-}${HTTPS_PROXY:-}${all_proxy:-}${ALL_PROXY:-}" ]; then
|
||||
for _v in no_proxy NO_PROXY; do
|
||||
case ",${!_v:-}," in *,127.0.0.1,*|",*,") ;; *) export "$_v=127.0.0.1,localhost${!_v:+,${!_v}}" ;; esac
|
||||
done
|
||||
@@ -1205,10 +1205,12 @@ for d in os.listdir("/proc"):
|
||||
argv = [a.decode(errors="replace") for a in f.read().split(b"\0")[:-1]]
|
||||
except OSError:
|
||||
continue
|
||||
for i, a in enumerate(argv[:2]):
|
||||
if os.path.basename(a) in ("switch-model.sh", "prepare-lane.sh"):
|
||||
print(f"{' '.join([os.path.basename(a), *argv[i + 1:i + 3]])} (pid {d})")
|
||||
break
|
||||
# a script that runs, by its name or by a shell, not one an editor has open; and what prepare-lane.sh becomes
|
||||
names = [os.path.basename(a) for a in argv]
|
||||
i = next((k for k, a in enumerate(argv) if k and not a.startswith("-")), 0) if names[:1] and names[0] in ("bash", "sh", "dash") else 0
|
||||
if names[i:i + 1] and (names[i] in ("switch-model.sh", "prepare-lane.sh")
|
||||
or (re.fullmatch(r"install-[a-z0-9-]+\.sh", names[i]) and "--prepare" in argv)):
|
||||
print(f"{' '.join([names[i], *argv[i + 1:i + 3]])} (pid {d})")
|
||||
PY
|
||||
}
|
||||
# The mount point /etc/fstab has over $1 that is not mounted now; nothing when there is none. A cache on a disk that did not
|
||||
|
||||
+14
-2
@@ -22,6 +22,7 @@ generated artifact and the config opencode really reads, through
|
||||
oc-merge-limits.py, and does nothing at all when the integration is off.
|
||||
"""
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
import re
|
||||
import os
|
||||
@@ -234,6 +235,16 @@ def keep_agent(rewritten: list, started: str) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def shadow_config() -> list:
|
||||
"""The user's opencode.jsonc, when it names a provider of this box (oc-merge-limits.py, shadow): one that names none, or
|
||||
cannot be read, is not this fit's to fail on."""
|
||||
spec = importlib.util.spec_from_file_location("oc_merge_limits", REPO_DIR / "oc-merge-limits.py")
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
beside = mod.shadow(str(Path.home() / ".config/opencode/opencode.json"))
|
||||
return [Path(beside)] if beside else []
|
||||
|
||||
|
||||
def engine_info(base: str) -> dict:
|
||||
"""/server_info, and the deprecated /get_server_info only on an engine that answers
|
||||
404 to it: SGLang logs a warning for each call of the old route and says it will go."""
|
||||
@@ -241,7 +252,8 @@ def engine_info(base: str) -> dict:
|
||||
for path in ("/server_info", "/get_server_info"):
|
||||
req = urllib.request.Request(base + path, headers={"Authorization": f"Bearer {key}"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=10) as r:
|
||||
# this box's own engine, never through a proxy of the environment's, which got the key (2026-11-30)
|
||||
with urllib.request.build_opener(urllib.request.ProxyHandler({})).open(req, timeout=10) as r:
|
||||
return json.loads(r.read().decode())
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code != 404 or path == "/get_server_info":
|
||||
@@ -379,7 +391,7 @@ def main(argv: list[str]) -> int:
|
||||
started, rewritten = (agent_started() if restart_lowered else ""), []
|
||||
for which, target in (("artifact", CONFIG_DIR / "opencode.json"),
|
||||
("user", Path.home() / ".config/opencode/opencode.json"),
|
||||
("user", Path.home() / ".config/opencode/opencode.jsonc")): # it wins over the one above
|
||||
*(("user", p) for p in shadow_config())): # it wins over the one above
|
||||
if not target.exists():
|
||||
continue
|
||||
before = (int(target.stat().st_mtime), file_sha(target))
|
||||
|
||||
+21
-18
@@ -331,7 +331,7 @@ if [ "$CHOICE" = "kolibri" ] || [ "$CHOICE" = "kolibri-nvfp4" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
KOL_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
KOL_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
KOL_PAIR="$("$REPO_DIR/oc-limits.sh" "$CHOICE")" || KOL_PAIR=""
|
||||
KOL_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$CHOICE" 262144 || true)"
|
||||
KOL_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)"
|
||||
@@ -357,7 +357,7 @@ if [ "$CHOICE" = "kolibri" ] || [ "$CHOICE" = "kolibri-nvfp4" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$KOL_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$KOL_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -601,7 +601,7 @@ if [ "$CHOICE" = "nemotron" ] || [ "$CHOICE" = "nemotron-super" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
NEM_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
NEM_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
NEM_PAIR="$("$REPO_DIR/oc-limits.sh" "$CHOICE")" || NEM_PAIR=""
|
||||
NEM_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label "$CHOICE" "$NEM_WINDOW" || true)"
|
||||
NEM_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)"
|
||||
@@ -625,7 +625,7 @@ if [ "$CHOICE" = "nemotron" ] || [ "$CHOICE" = "nemotron-super" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$NEM_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$NEM_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -738,7 +738,7 @@ if [ "$CHOICE" = "flash-local" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
FLL_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
FLL_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
# the pair and the window of the unit just staged: 1,048,576 tokens with FLASH_LOCAL_CONTEXT=1m (v1.45.2)
|
||||
FLL_WINDOW="$({ grep -oE -- '--max-model-len [0-9]+' "$FLASH_LOCAL_UNIT" 2>/dev/null || true; } | awk 'NR == 1 {print $2}')"
|
||||
FLL_PAIR="$("$REPO_DIR/oc-limits.sh" flash-local --from "$FLASH_LOCAL_UNIT")" || FLL_PAIR=""
|
||||
@@ -776,7 +776,7 @@ if [ "$CHOICE" = "flash-local" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$FLL_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$FLL_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -884,7 +884,7 @@ if [ "$CHOICE" = "ornith-122b" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
ORN_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
ORN_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
ORN_PAIR="$("$REPO_DIR/oc-limits.sh" ornith-122b)" || ORN_PAIR=""
|
||||
ORN_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label ornith-122b 1048576 || true)"
|
||||
ORN_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)"
|
||||
@@ -908,7 +908,7 @@ if [ "$CHOICE" = "ornith-122b" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$ORN_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$ORN_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -1010,7 +1010,7 @@ if [ "$CHOICE" = "flash-unsloth" ] || [ "$CHOICE" = "flash-unsloth-iq3" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
FLU_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
FLU_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
# the window of the unit just staged (its -c, a window for each request), and its pair: 262,144 by default,
|
||||
# 1,048,576 with FLASH_UNSLOTH_CONTEXT=1m, the choice its installer kept (decisions 1316 and 1318); and the target it
|
||||
# serves, which the entry's name says (lanes.sh): the unit in place's with --clients, the one just staged otherwise
|
||||
@@ -1051,7 +1051,7 @@ if [ "$CHOICE" = "flash-unsloth" ] || [ "$CHOICE" = "flash-unsloth-iq3" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$FLU_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$FLU_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -1119,6 +1119,8 @@ if [ "$CHOICE" = "image" ] || [ "$CHOICE" = "image-turbo" ]; then
|
||||
IMG_HF="$(grep -m1 -E '^Environment=HF_HOME=' "$IMG_SRC" | cut -d= -f3- || true)"
|
||||
IMG_MODEL_DIR="${IMG_HF:-$HF_CACHE}/hub/models--${IMG_MODEL//\//--}"
|
||||
IMG_REV=""
|
||||
# A Download of Library's (--fetch) brings a revision and moves nothing: refs/main is what the unit in place serves.
|
||||
IMG_REFS=pin; [ "$FETCH_ONLY" -eq 0 ] || IMG_REFS=fill
|
||||
# an update that waits for this Load says the revision its unit serves: read after refs/main, which names the one
|
||||
# the box has, a pin that had moved came by no Load (2026-11-30)
|
||||
if [ "$IMG_SRC" != "$IMAGE_UNIT" ]; then IMG_REV="$(unit_checkpoint_rev "$IMG_SRC" "$IMG_MODEL")"; fi
|
||||
@@ -1151,7 +1153,7 @@ if [ "$CHOICE" = "image" ] || [ "$CHOICE" = "image-turbo" ]; then
|
||||
HF_HOME="${IMG_HF:-$HF_CACHE}" HF_HUB_DOWNLOAD_TIMEOUT=30 HF_HUB_DISABLE_XET=1 \
|
||||
HF_HUB_DISABLE_PROGRESS_BARS="$DL_NO_BARS" \
|
||||
"$IMG_PY" "$REPO_DIR/ckpt-fetch.py" "$IMG_MODEL" "$IMG_REV" --offline-first \
|
||||
--need-gb 34 --free-gb "$(dl_free_gb "${IMG_HF:-$HF_CACHE}")" --refs-main pin \
|
||||
--need-gb 34 --free-gb "$(dl_free_gb "${IMG_HF:-$HF_CACHE}")" --refs-main "$IMG_REFS" \
|
||||
|| die "the image checkpoint could not be verified or fetched (re-run to resume; set HF_TOKEN if it stalls)"
|
||||
fetched "$IMG_MODEL @ ${IMG_REV:0:12}"
|
||||
# The unit names one checkpoint; a switch between the lane's two rewrites that name and
|
||||
@@ -1331,6 +1333,7 @@ if [ "$CHOICE" = "video" ]; then
|
||||
if [ "$VID_SRC" != "$VIDEO_UNIT" ]; then
|
||||
VID_REV="$(unit_checkpoint_rev "$VID_SRC" "$VID_MODEL")"
|
||||
if [[ "$VID_REV" =~ ^[0-9a-f]{40}$ ]]; then VID_REFS=pin; else VID_REV=""; fi
|
||||
[ "$FETCH_ONLY" -eq 0 ] || VID_REFS=fill # a Download moves nothing, as the image lane's
|
||||
fi
|
||||
if [ -z "$VID_REV" ] && [ -f "$VID_MODEL_DIR/refs/main" ]; then VID_REV="$(cat "$VID_MODEL_DIR/refs/main")"; fi
|
||||
[[ "$VID_REV" =~ ^[0-9a-f]{40}$ ]] || VID_REV=""
|
||||
@@ -1745,7 +1748,7 @@ if [ "$CHOICE" = "lfm25" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
LFM25_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
LFM25_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
LFM25_LIMITS="$("$REPO_DIR/oc-limits.sh" lfm25)" || LFM25_LIMITS=""
|
||||
LFM25_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label lfm25 131072 || true)"
|
||||
LFM25_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)"
|
||||
@@ -1769,7 +1772,7 @@ if [ "$CHOICE" = "lfm25" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$LFM25_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$LFM25_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -1878,7 +1881,7 @@ if [ "$CHOICE" = "lfm3" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
LFM3_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
LFM3_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
LFM3_LIMITS="$("$REPO_DIR/oc-limits.sh" lfm3)" || LFM3_LIMITS=""
|
||||
LFM3_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label lfm3 262144 || true)"
|
||||
LFM3_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)"
|
||||
@@ -1902,7 +1905,7 @@ if [ "$CHOICE" = "lfm3" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$LFM3_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$LFM3_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -2012,7 +2015,7 @@ if [ "$CHOICE" = "inkling" ]; then
|
||||
if [ -f "$CONFIG_DIR/opencode.off" ]; then
|
||||
echo "opencode integration is off on this box (./install.sh --no-opencode): default model left alone"
|
||||
else
|
||||
INKLING_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
INKLING_OC_SUM="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
INKLING_LIMITS="$("$REPO_DIR/oc-limits.sh" inkling)" || INKLING_LIMITS=""
|
||||
INKLING_NAME="$(python3 "$REPO_DIR/oc-point-default.py" --label inkling 1048576 || true)"
|
||||
INKLING_PORT="$({ grep -m1 -oE 'PROXY_PORT=[0-9]+|keepalive-proxy.py [0-9]+' /etc/systemd/system/qwen38-keepalive.service 2>/dev/null || true; } | grep -oE '[0-9]+$' || true)"
|
||||
@@ -2036,7 +2039,7 @@ if [ "$CHOICE" = "inkling" ]; then
|
||||
python3 "$REPO_DIR/pi-gen.py" --config "$CONFIG_DIR/opencode.json" --out "$CONFIG_DIR" \
|
||||
|| echo "NOTE: could not regenerate the pi/omp artifacts; run ./pi-gen.py by hand"
|
||||
fi
|
||||
if [ "$INKLING_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$INKLING_OC_SUM" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl list-unit-files opencode-web.service >/dev/null 2>&1 && systemctl is-active --quiet opencode-web.service; then
|
||||
sudo systemctl restart opencode-web.service \
|
||||
&& echo "opencode-web.service restarted so it reads the new default" \
|
||||
@@ -2484,7 +2487,7 @@ else
|
||||
# what the opencode server reads, before this switch writes any of it (see 4d); a missing
|
||||
# file is part of the answer, not a failure (install.sh's first installs died on the same
|
||||
# line under pipefail)
|
||||
oc_configs_sum(){ { cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum; }
|
||||
oc_configs_sum(){ { cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum; }
|
||||
SW_OC_SUM_BEFORE="$(oc_configs_sum)"
|
||||
if read -r SW_CTX SW_OUT _SW_LABEL \
|
||||
<<<"$("$REPO_DIR/oc-limits.sh" "$CHOICE" --from "$INVOCATION")" \
|
||||
|
||||
@@ -289,6 +289,13 @@ class Room(unittest.TestCase):
|
||||
self.assertEqual(rc, 0, err)
|
||||
self.assertEqual([c["local"] for c in calls], [True, False])
|
||||
|
||||
def test_a_whole_snapshot_needs_no_room_without_offline_first_either(self):
|
||||
"""On a cache with no links (exFAT, a share), the blobs say nothing of it (found in review, 2026-11-30)."""
|
||||
rc, out, err, calls = Box(["model.safetensors"]).run("--need-gb", "100", "--free-gb", "2")
|
||||
self.assertEqual(rc, 0, err)
|
||||
rc, out, err, calls = Box(["config.json"]).run("--need-gb", "100", "--free-gb", "2")
|
||||
self.assertNotEqual(rc, 0, "the witness: not whole, it is refused")
|
||||
|
||||
def test_a_whole_snapshot_needs_no_room(self):
|
||||
rc, out, err, calls = Box(["model.safetensors"]).run("--offline-first", "--need-gb", "34", "--free-gb", "1")
|
||||
self.assertEqual(rc, 0, err)
|
||||
@@ -335,7 +342,7 @@ class Room(unittest.TestCase):
|
||||
rc, out, err, calls = b.run()
|
||||
self.assertNotEqual(rc, 0)
|
||||
self.assertIn("27 GiB free in the cache, and org/model needs about 35 GB more", err)
|
||||
self.assertEqual(calls, [], "nothing asked of the network")
|
||||
self.assertEqual([c["local"] for c in calls], [True], "nothing asked of the network")
|
||||
b.env["FAKE_FREE"] = str(36 * 10**9)
|
||||
rc, out, err, calls = b.run()
|
||||
self.assertEqual(rc, 0, err)
|
||||
|
||||
@@ -20,7 +20,7 @@ INSTALL = (REPO / "install.sh").read_text()
|
||||
|
||||
|
||||
def function(name, text=INSTALL):
|
||||
m = re.search(rf"(?ms)^{name}\(\)\s*\{{.*?^\}}$", text) or re.search(rf"(?m)^{name}\(\)\s*\{{.*\}}$", text)
|
||||
m = re.search(rf"(?m)^{name}\(\)\s*\{{.*\}}$", text) or re.search(rf"(?ms)^{name}\(\)\s*\{{.*?^\}}$", text)
|
||||
assert m, name
|
||||
return m.group(0) + "\n"
|
||||
|
||||
@@ -102,6 +102,7 @@ class TheBoxsOwnAddressesNeverGoThroughAProxy(Tmp):
|
||||
show = 'echo "${no_proxy-unset}|${NO_PROXY-unset}"'
|
||||
for env, want in (({}, "unset|unset"),
|
||||
({"http_proxy": "http://p:1"}, "127.0.0.1,localhost|127.0.0.1,localhost"),
|
||||
({"HTTP_PROXY": "http://p:1"}, "127.0.0.1,localhost|127.0.0.1,localhost"), # urllib reads it
|
||||
({"HTTPS_PROXY": "http://p:1", "NO_PROXY": "corp.lan"}, "127.0.0.1,localhost|127.0.0.1,localhost,corp.lan"),
|
||||
({"all_proxy": "http://p:1", "no_proxy": "*", "NO_PROXY": "*"}, "*|*"),
|
||||
({"http_proxy": "http://p:1", "no_proxy": "127.0.0.1", "NO_PROXY": "127.0.0.1"}, "127.0.0.1|127.0.0.1")):
|
||||
@@ -209,6 +210,29 @@ class AnInstallBesideAnotherOrALoad(Tmp):
|
||||
pid = self.sleeper(("bash", str(script), "flash-local"))
|
||||
self.assertIn(f"switch-model.sh flash-local (pid {pid})", self.beside())
|
||||
|
||||
def test_what_prepare_lane_becomes(self):
|
||||
"""prepare-lane.sh's preparation is an exec of the lane's installer, whose command line no longer names it."""
|
||||
(self.d / "install-image.sh").write_text("sleep 60; :\n")
|
||||
script = self.d / "prepare-lane.sh"
|
||||
script.write_text(f'exec bash "{self.d}/install-image.sh" --prepare image\n')
|
||||
pid = self.sleeper(("bash", str(script), "image", "image"))
|
||||
time.sleep(0.3)
|
||||
self.assertIn(f"install-image.sh --prepare image (pid {pid})", self.beside())
|
||||
|
||||
def test_an_installer_that_prepares_nothing_is_not_a_load(self):
|
||||
script = self.d / "install-image.sh"
|
||||
script.write_text("sleep 60; :\n")
|
||||
self.sleeper(("bash", str(script), "--units-only"))
|
||||
self.assertNotIn("install-image.sh", self.beside())
|
||||
|
||||
def test_a_script_open_in_an_editor_is_not_one(self):
|
||||
script = self.d / "switch-model.sh"
|
||||
script.write_text("sleep 60; :\n")
|
||||
self.sleeper(("tail", "-f", str(script)))
|
||||
self.assertNotIn("switch-model.sh", self.beside())
|
||||
pid = self.sleeper(("bash", "-x", str(script), "flash"))
|
||||
self.assertIn(f"switch-model.sh flash (pid {pid})", self.beside())
|
||||
|
||||
def test_a_load_of_another_home_is_not_this_boxs(self):
|
||||
"""The suite's own, beside an install it runs in another home."""
|
||||
script = self.d / "prepare-lane.sh"
|
||||
@@ -280,6 +304,117 @@ class SudosTimestampLastsAsLongAsTheRun(Tmp):
|
||||
self.assertEqual(r.stdout.strip(), "[]", r.stderr)
|
||||
|
||||
|
||||
class AnInstallBesideALaneStartedByHand(Tmp):
|
||||
"""The image lane is restarted to run new files (v1.40.6), but not under a run that says it starts and stops none."""
|
||||
TEXT = (REPO / "install-image.sh").read_text()
|
||||
BLOCK = TEXT[TEXT.index(' if [ "$SMOKE" -eq 0 ] && [ -n "${QWEN38_KEEPS_SERVING:-}" ]'):]
|
||||
BLOCK = BLOCK[:BLOCK.index("\n fi\n") + 6]
|
||||
|
||||
def run_block(self, **env):
|
||||
return bash('set -euo pipefail; SMOKE=0; UNIT=qwen38-image.service; LANE_FILES=(x)\nlane_serves_older(){ return 0; }\n'
|
||||
'sudo(){ echo "SUDO $*"; }\n' + self.BLOCK, env=env)
|
||||
|
||||
def test_it_goes_on(self):
|
||||
r = self.run_block(QWEN38_KEEPS_SERVING="1")
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertNotIn("SUDO", r.stdout)
|
||||
self.assertIn("goes on serving", r.stdout)
|
||||
|
||||
def test_and_is_restarted_as_before_otherwise(self):
|
||||
self.assertIn("SUDO systemctl restart qwen38-image.service", self.run_block().stdout)
|
||||
|
||||
def test_install_sh_says_it_to_the_lanes_installers(self):
|
||||
self.assertIn('[ -z "$STARTS_NONE" ] || export QWEN38_KEEPS_SERVING=1', INSTALL)
|
||||
|
||||
|
||||
class TheRecordOfATextLaneWhoseUnitsAreGone(Tmp):
|
||||
LINE = next(ln for ln in INSTALL.splitlines() if ln.startswith('[ -n "$SECONDARY" ] || [ -f "$SGL_UNIT_PATH" ]'))
|
||||
|
||||
def run_line(self, unit, secondary=""):
|
||||
(self.d / "text-lane").write_text("qwen38-sglang.service\n")
|
||||
if unit:
|
||||
(self.d / "u").write_text("x")
|
||||
bash(f'set -euo pipefail; SECONDARY="{secondary}"; SGL_UNIT_PATH="{self.d}/u"; FLASH_UNIT_PATH="{self.d}/v"; CONFIG_DIR="{self.d}"\n{self.LINE}\n')
|
||||
return (self.d / "text-lane").exists()
|
||||
|
||||
def test_goes_with_the_next_run(self):
|
||||
self.assertFalse(self.run_line(unit=False))
|
||||
self.assertTrue(self.run_line(unit=False, secondary="flash"))
|
||||
self.assertTrue(self.run_line(unit=True))
|
||||
|
||||
def test_it_is_after_what_plan_prints(self):
|
||||
self.assertLess(INSTALL.index('if [ "$PLAN_ONLY" -eq 1 ]; then'), INSTALL.index(self.LINE))
|
||||
|
||||
|
||||
class TheUsersJsoncCounts(Tmp):
|
||||
def test_in_what_restarts_the_agents_server(self):
|
||||
(self.d / ".config/opencode").mkdir(parents=True)
|
||||
out = []
|
||||
for limit in (999000, 700000):
|
||||
(self.d / ".config/opencode/opencode.jsonc").write_text(f'{{"limit": {limit}}}')
|
||||
out.append(bash(f'set -euo pipefail; CONFIG_DIR="{self.d}/c"; HOME="{self.d}"\n' + function("oc_configs_sum") + "oc_configs_sum").stdout)
|
||||
self.assertNotEqual(*out)
|
||||
for script in ("switch-model.sh", "vllm-lane.sh"):
|
||||
text = (REPO / script).read_text()
|
||||
self.assertNotIn('"$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum', text)
|
||||
agent = (REPO / "dashboard/install-agent.sh").read_text()
|
||||
self.assertIn('"$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc"; do', agent)
|
||||
|
||||
def test_one_that_names_no_provider_of_this_box_is_not_the_fits(self):
|
||||
import importlib.util
|
||||
spec = importlib.util.spec_from_file_location("fit_robust", REPO / "oc-fit-limits.py")
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
(self.d / ".config/opencode").mkdir(parents=True)
|
||||
jsonc = self.d / ".config/opencode/opencode.jsonc"
|
||||
saved = os.environ.get("HOME")
|
||||
os.environ["HOME"] = str(self.d)
|
||||
try:
|
||||
for text, want in ((None, []), ("", []), ("{ broken", []), ('{"theme": "x"}', []),
|
||||
('{// mine\n"provider": {"qwen38": {}}}', [jsonc]), ('{"provider": {"anthropic": {}}}', [])):
|
||||
if text is not None:
|
||||
jsonc.write_text(text)
|
||||
got = mod.shadow_config()
|
||||
self.assertEqual(got, want, text)
|
||||
finally:
|
||||
os.environ["HOME"] = saved
|
||||
|
||||
def test_the_fit_asks_the_engine_straight(self):
|
||||
import importlib.util
|
||||
seen = []
|
||||
|
||||
class H(http.server.BaseHTTPRequestHandler):
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
def do_GET(self):
|
||||
seen.append(self.path)
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Length", "2")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"{}")
|
||||
servers = [http.server.ThreadingHTTPServer(("127.0.0.1", 0), H) for _ in range(2)]
|
||||
for s in servers:
|
||||
threading.Thread(target=s.serve_forever, daemon=True).start()
|
||||
self.addCleanup(s.server_close)
|
||||
self.addCleanup(s.shutdown)
|
||||
proxy, engine = (s.server_address[1] for s in servers)
|
||||
spec = importlib.util.spec_from_file_location("fit_robust2", REPO / "oc-fit-limits.py")
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
(self.d / "api-key").write_text("k\n")
|
||||
mod.CONFIG_DIR = self.d
|
||||
saved = {k: os.environ.get(k) for k in ("http_proxy", "no_proxy", "NO_PROXY")}
|
||||
os.environ["http_proxy"] = f"http://127.0.0.1:{proxy}"
|
||||
os.environ.pop("no_proxy", None), os.environ.pop("NO_PROXY", None)
|
||||
try:
|
||||
mod.engine_info(f"http://127.0.0.1:{engine}")
|
||||
finally:
|
||||
for k, v in saved.items():
|
||||
os.environ.pop(k, None) if v is None else os.environ.__setitem__(k, v)
|
||||
self.assertEqual(seen, ["/server_info"], "through a proxy its path is the whole address")
|
||||
|
||||
|
||||
class GetShSaysWhatGitSaid(Tmp):
|
||||
def test_its_first_line_and_never_a_password(self):
|
||||
text = (REPO / "get.sh").read_text()
|
||||
|
||||
@@ -49,15 +49,15 @@ class TheDownloadHintNamesTheDraftPin(unittest.TestCase):
|
||||
class PathsTheUnitsCannotCarry(unittest.TestCase):
|
||||
"""HOME, HF_CACHE and PLE_DIR go into the units as they are: inside a quoted bash -c
|
||||
line, in a docker -v src:dst, and in systemd's syntax, where % is a specifier."""
|
||||
START = TEXT.index('_paths=("HOME=$HOME" "HF_CACHE=$HF_CACHE" "PLE_DIR=$PLE_DIR")')
|
||||
BLOCK = TEXT[START:TEXT.index("unset _p _paths\n", START)]
|
||||
START = TEXT.index('for _p in "HOME=$HOME" "HF_CACHE=$HF_CACHE" "PLE_DIR=$PLE_DIR"; do')
|
||||
BLOCK = TEXT[START:TEXT.index("\nfor _p in \"$HF_CACHE\"", START)]
|
||||
|
||||
def check(self, home="/home/u", hf="/home/u/.cache/huggingface", ple="/home/u/flashnext-ple", repo="/home/u/dgx-spark-qwen38",
|
||||
no_cockpit=0):
|
||||
script = (f"set -euo pipefail\nNO_COCKPIT={no_cockpit}; REPO_DIR='{repo}'\ndie(){{ echo \"DIE: $*\"; exit 1; }}\n"
|
||||
+ self.BLOCK + "\necho FINE\n")
|
||||
cockpit=1):
|
||||
script = "set -euo pipefail\ndie(){ echo \"DIE: $*\"; exit 1; }\n" + self.BLOCK + "\necho FINE\n"
|
||||
r = subprocess.run(["bash", "-c", script], capture_output=True, text=True, timeout=30,
|
||||
env={"PATH": "/usr/bin:/bin", "HOME": home, "HF_CACHE": hf, "PLE_DIR": ple})
|
||||
env={"PATH": "/usr/bin:/bin", "HOME": home, "HF_CACHE": hf, "PLE_DIR": ple, "REPO_DIR": repo,
|
||||
"COCKPIT": str(cockpit)})
|
||||
return r.stdout
|
||||
|
||||
def test_ordinary_paths_pass(self):
|
||||
@@ -73,8 +73,13 @@ class PathsTheUnitsCannotCarry(unittest.TestCase):
|
||||
self.assertIn("DIE: PLE_DIR=", self.check(ple="/data/ple:x"))
|
||||
|
||||
def test_the_clone_too_which_the_cockpits_unit_runs_from(self):
|
||||
self.assertIn("DIE: REPO_DIR=", self.check(repo="/home/u/my clones/alzeo"))
|
||||
self.assertIn("FINE", self.check(repo="/home/u/my clones/alzeo", no_cockpit=1))
|
||||
for bad in ("/home/u/my clones/alzeo", "/home/u/a'b", '/home/u/a"b', "/home/u/$x", "/home/u/100%", "/home/u/a:b", "/home/u/a|b",
|
||||
"/home/u/a&b", "/home/u/a\\b", "/home/u/a\tb"):
|
||||
self.assertIn("DIE: this clone's path", self.check(repo=bad), bad)
|
||||
self.assertIn("FINE", self.check(repo=bad, cockpit=0), "no cockpit, or one cut: nothing runs from it")
|
||||
# what v1.59.0 took, and systemd takes (found in review, 2026-11-30)
|
||||
for good in ("/home/u/Téléchargements/alzeo", "/home/u/a,b", "/home/u/a=b", "/home/u/a#b", "/home/u/a[1]", "/home/u/a~b"):
|
||||
self.assertIn("FINE", self.check(repo=good), good)
|
||||
|
||||
|
||||
class TheBindsAreCheckedAgainOnceReadBack(unittest.TestCase):
|
||||
|
||||
@@ -132,7 +132,7 @@ class AMovedPinWaits(unittest.TestCase):
|
||||
class TheLoadFetchesWhatWaits(unittest.TestCase):
|
||||
"""The revision a switch fetches, by its own lines: the waiting unit's when one waits, else what refs/main names."""
|
||||
|
||||
def rev(self, repo, waits, refs=OLD, names=NEW):
|
||||
def rev(self, repo, waits, refs=OLD, names=NEW, fetch_only=0):
|
||||
b = Box()
|
||||
if refs:
|
||||
b.snapshot(repo, refs)
|
||||
@@ -143,19 +143,24 @@ class TheLoadFetchesWhatWaits(unittest.TestCase):
|
||||
head = (f'IMG_MODEL="{repo}"; IMAGE_UNIT="{b.d}/in-place"; IMG_SRC="{src if waits else b.d / "in-place"}"; '
|
||||
f'IMG_MODEL_DIR="{b.hf}/hub/models--{repo.replace("/", "--")}"\n'
|
||||
f'IMAGE_MODEL_PIN={BASE}; IMAGE_MODEL_PIN_REV={"a" * 40}; IMAGE_TURBO_PIN={TURBO}; IMAGE_TURBO_PIN_REV={"b" * 40}\n')
|
||||
tail = 'echo "$IMG_REV"'
|
||||
tail = 'echo "$IMG_REV"' + (' "$IMG_REFS"' if fetch_only else '')
|
||||
else:
|
||||
start, end = SWITCH.index(' VID_REV=""'), SWITCH.index(" # Room first, the law the text branch learned", SWITCH.index(' VID_REV=""'))
|
||||
head = (f'VID_MODEL="{repo}"; VIDEO_UNIT="{b.d}/in-place"; VID_SRC="{src if waits else b.d / "in-place"}"; REPO_DIR="{REPO}"\n'
|
||||
f'VID_MODEL_DIR="{b.hf}/hub/models--{repo.replace("/", "--")}"; die(){{ echo "DIE $*"; exit 1; }}\n')
|
||||
tail = 'echo "$VID_REV ${VID_REFS:-}"'
|
||||
return b.bash(f'set -euo pipefail\n. "{REPO}/lanes.sh"\n' + head + SWITCH[start:end] + tail).split()
|
||||
return b.bash(f'set -euo pipefail; FETCH_ONLY={fetch_only}\n. "{REPO}/lanes.sh"\n' + head + SWITCH[start:end] + tail).split()
|
||||
|
||||
def test_the_waiting_units_revision_comes_before_refs_main(self):
|
||||
self.assertEqual(self.rev(BASE, True), [NEW])
|
||||
self.assertEqual(self.rev(TURBO, True), [NEW])
|
||||
self.assertEqual(self.rev(H3, True), [NEW, "pin"], "and refs/main, which the unit serves, is moved to it")
|
||||
|
||||
def test_a_download_moves_nothing_the_unit_in_place_serves(self):
|
||||
"""Library's Download of a lane whose update waits: the revision comes, refs/main stays (found in review, 2026-11-30)."""
|
||||
self.assertEqual(self.rev(BASE, True, fetch_only=1), [NEW, "fill"])
|
||||
self.assertEqual(self.rev(H3, True, fetch_only=1), [NEW, "fill"])
|
||||
|
||||
def test_with_nothing_waiting_the_box_keeps_what_refs_main_names(self):
|
||||
self.assertEqual(self.rev(BASE, False), [OLD])
|
||||
self.assertEqual(self.rev(H3, False), [OLD, "fill"], "never moved")
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@ vlane_uninstall_clients(){
|
||||
qwen38-flash.service) oc_lane=flash ;;
|
||||
*) oc_lane=27b ;;
|
||||
esac
|
||||
oc_sum_before="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)"
|
||||
oc_sum_before="$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)"
|
||||
for oc_json in "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json"; do
|
||||
[ -f "$oc_json" ] || continue
|
||||
was_default=0
|
||||
@@ -116,7 +116,7 @@ PYCTX
|
||||
# A restart that fails (no ticket, no terminal) is said: the uninstall goes on. As this function's
|
||||
# last line it was its return code, and set -e stopped the installer half done (found in review,
|
||||
# 2026-10-16).
|
||||
if [ "$oc_sum_before" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
if [ "$oc_sum_before" != "$({ cat "$CONFIG_DIR/opencode.json" "$HOME/.config/opencode/opencode.json" "$HOME/.config/opencode/opencode.jsonc" 2>/dev/null || true; } | sha256sum)" ] \
|
||||
&& systemctl is-active --quiet opencode-web.service 2>/dev/null; then
|
||||
if sudo systemctl restart opencode-web.service; then
|
||||
echo "opencode-web.service restarted so it reads the change"
|
||||
|
||||
Reference in new issue
Block a user