docker: model files left in the older /data/models stop the start instead of being downloaded again (#3421)

A volume or bind mount from the 0.1.x image keeps its models in /data/models. The entry point moves a folder that is part of the volume, but a folder the person
mounted there is left alone, and a failed move leaves the files too; with no MODEL_PATH the start then did not see them and downloaded the model again
(tens of GB) without a word. Now, when .gguf files are still in /data/models and MODEL_PATH is not set, the container stops with code 2 and names the folder,
says what to do (MODEL_PATH to the folder with the shards, or the files into /data/Strata-data/models) and that nothing was downloaded.
ALLOW_DOWNLOAD=1 goes on anyway with the same text as a warning. docs/DOCKER.md lists the setting. The other points of the issue (the key, the removed
variables, the status loop) are the owner's design questions and are not changed here. Tested by running the guard function with sh (tests/terminal/test_docker_files.py);
the whole container was not run (no docker on this PC).
This commit is contained in:
Niko1221 committed 2026-10-26 19:42:58 +01:00
1 parent ab48216a7b
commit 10a62b8d2f
3 files changed
+75 -1

No files matched your search

+13
View File
@@ -10,6 +10,7 @@
# MODEL model size, e.g. IQ3_XXS, Q2_0 (empty: Strata picks one for this card and says so)
# FAMILY model family when a size is offered by several (qwen, swift, coder, ...)
# MODEL_PATH GGUF files you already have, a folder or one .gguf, inside the container (mount it read-only)
# ALLOW_DOWNLOAD 1: go on and download the model although model files of the older layout (/data/models) were left unread (default: stop)
# CONTEXT 32k, 64k, 128k, 256k or a number of tokens
# PARALLEL requests answered at the same time, 1 to 8 (empty: fit to the card)
# VISION off | on | gpu | cpu (pictures; the picture reader file is downloaded with the model)
@@ -38,6 +39,17 @@ warn() { printf '[!] %s\n' "$*" >&2; }
die() { printf '[X] %s\n' "$*" >&2; exit "${2:-1}"; }
phase() { printf '%s\n' "$1" > "$PHASE_FILE" 2>/dev/null || true; }
# Model files of the older layout that this image did not move (a folder you mounted at /data/models, or a move that failed) are not read here, and
# the start would download the model again. Say so and stop instead (#3421); ALLOW_DOWNLOAD=1 goes on, with the same text as a warning.
# $1: MODEL_PATH (when it is set the files are named and nothing is lost), $2: the older models folder.
legacy_models_guard() {
[ -n "$1" ] && return 0
stuck=$(find "$2" -maxdepth 3 -name '*.gguf' 2>/dev/null | head -1)
[ -n "$stuck" ] || return 0
msg="There are model files in ${stuck%/*} (the older image's place). This image keeps its models in /data/Strata-data/models and does not read them there, so it would download the model again (tens of GB). To use them: mount that folder read-only and set MODEL_PATH to the folder that holds the shards (docs/DOCKER.md, \"Files you already have\"), or put them in /data/Strata-data/models/<model folder>/. To download anyway: set ALLOW_DOWNLOAD=1. Nothing was downloaded."
if [ "${ALLOW_DOWNLOAD:-0}" = "1" ]; then warn "$msg Going on, because ALLOW_DOWNLOAD=1."; else die "$msg" 2; fi
}
# ---- other commands: `docker run image strata ...`, `docker run image sh`
if [ "$#" -gt 0 ] && [ "$1" != "run" ] && [ "$1" != "serve" ]; then
case "$1" in strata) shift; exec "$STRATA" "$@" ;; *) exec "$@" ;; esac
@@ -174,6 +186,7 @@ if [ -n "$model_path" ]; then
die "MODEL_PATH=$model_path holds no .gguf files. Mount the folder with the model's shards (the -0000N-of-0000M.gguf files). Nothing was downloaded." 2
fi
fi
legacy_models_guard "$model_path" "${STRATA_LEGACY_MODELS:-/data/models}"
[ -n "${MODEL:-}" ] && { set -- "$@" --model "$MODEL"; have=1; }
[ -n "${FAMILY:-}" ] && { set -- "$@" --family "$FAMILY"; have=1; }
[ -n "$model_path" ] && { set -- "$@" --model-path "$model_path"; have=1; }