From dd2d52b5e35e00c4eec1df803bafade6d9b4ea90 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Apr 2026 19:34:58 +0000 Subject: [PATCH] Fix -m None passed to llama-server when cached model not found When LLAMA_CACHED_MODEL is set but the model isn't present in the cache, find_cached.py was printing Python's None as the string "None", causing start.sh to pass "-m None" to llama-server. - find_cached.py: print an error to stderr and exit 1 when the model path cannot be resolved, instead of printing "None" - start.sh: capture find_cached.py output into a local variable, check the exit code and guard against empty output before constructing CACHED_LLAMA_ARGS; also quote the env-var expansions to handle spaces https://claude.ai/code/session_011ny5CFYnrzPbRneSzio5CR --- src/find_cached.py | 7 +++++++ src/start.sh | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/find_cached.py b/src/find_cached.py index 97a5b95..5dfd6b2 100644 --- a/src/find_cached.py +++ b/src/find_cached.py @@ -3,6 +3,7 @@ Finds the full LLM GGUF path from the Hugging Face cache. """ import os +import sys import argparse CACHE_DIR = "/runpod-volume/huggingface-cache/hub" @@ -52,6 +53,12 @@ def main(): args = parser.parse_args() model_path = find_model_path(args.model, args.path) + if model_path is None: + print( + f"Error: Cached model not found. Model='{args.model}', GGUF='{args.path}', Cache dir='{CACHE_DIR}'", + file=sys.stderr, + ) + sys.exit(1) print(model_path, end="") diff --git a/src/start.sh b/src/start.sh index d57f7d3..52d5cb0 100644 --- a/src/start.sh +++ b/src/start.sh @@ -17,7 +17,13 @@ cleanup() { CACHED_LLAMA_ARGS="" find_cached_path() { - CACHED_LLAMA_ARGS="-m $(python ./find_cached.py $LLAMA_CACHED_MODEL $LLAMA_CACHED_GGUF_PATH)" + local model_path + model_path=$(python ./find_cached.py "$LLAMA_CACHED_MODEL" "$LLAMA_CACHED_GGUF_PATH") + if [ $? -ne 0 ] || [ -z "$model_path" ]; then + echo "start.sh: Error: Could not resolve cached model path. Check that LLAMA_CACHED_MODEL and LLAMA_CACHED_GGUF_PATH are correct and the model is fully cached on the network volume." + exit 1 + fi + CACHED_LLAMA_ARGS="-m $model_path" } # check if $LLAMA_CACHED_MODEL is set and not empty