From 168f593096ccc1d2f2a8a6edb08a2456f30c99c7 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Tue, 7 Jul 2026 01:56:02 +0000 Subject: [PATCH] Fix Cookbook download runner for Python 3.11 Avoid backslashes inside f-string expressions when generating Hugging Face install fallback commands. GitHub Actions compileall runs on Python 3.11, which rejects that syntax. Verified with Python 3.11 feature-version AST parse, CI-scoped compileall, focused Cookbook import tests, and full container pytest: 4515 passed, 4 skipped. --- routes/cookbook_routes.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/routes/cookbook_routes.py b/routes/cookbook_routes.py index 6629e1542..b64f1d3c3 100644 --- a/routes/cookbook_routes.py +++ b/routes/cookbook_routes.py @@ -1214,7 +1214,12 @@ def setup_cookbook_routes() -> APIRouter: runner_lines.append('fi') runner_lines.append('if [ -z "$ODYSSEUS_OLLAMA_PULL_CMD" ]; then echo "ERROR: Ollama not found on this server. Install Ollama or start an ollama-rocm/ollama-test container."; exit 127; fi') else: - runner_lines.append(f"command -v hf >/dev/null 2>&1 || command -v huggingface-cli >/dev/null 2>&1 || {_pip_install_fallback_chain('huggingface_hub', python_cmd='\"$ODYSSEUS_PY\" -m pip', upgrade=True)}") + hf_hub_install = _pip_install_fallback_chain( + "huggingface_hub", + python_cmd='"$ODYSSEUS_PY" -m pip', + upgrade=True, + ) + runner_lines.append(f"command -v hf >/dev/null 2>&1 || command -v huggingface-cli >/dev/null 2>&1 || {hf_hub_install}") runner_lines.append('hash -r 2>/dev/null || true') runner_lines.append('ODYSSEUS_HF_CLI="$(command -v hf || command -v huggingface-cli || true)"') runner_lines.append('if [ -z "$ODYSSEUS_HF_CLI" ]; then echo "ERROR: HF CLI not found after installing huggingface_hub."; exit 127; fi') @@ -1222,7 +1227,11 @@ def setup_cookbook_routes() -> APIRouter: runner_lines.append("export HF_HUB_ENABLE_HF_TRANSFER=0") runner_lines.append("export HF_HUB_DOWNLOAD_MAX_WORKERS=4") else: - runner_lines.append(f"\"$ODYSSEUS_PY\" -c 'import hf_transfer' 2>/dev/null || {_pip_install_fallback_chain('hf_transfer', python_cmd='\"$ODYSSEUS_PY\" -m pip')}") + hf_transfer_install = _pip_install_fallback_chain( + "hf_transfer", + python_cmd='"$ODYSSEUS_PY" -m pip', + ) + runner_lines.append(f"\"$ODYSSEUS_PY\" -c 'import hf_transfer' 2>/dev/null || {hf_transfer_install}") runner_lines.append("\"$ODYSSEUS_PY\" -c 'import hf_transfer' 2>/dev/null && export HF_HUB_ENABLE_HF_TRANSFER=1") runner_lines.append("export HF_HUB_DOWNLOAD_MAX_WORKERS=8") # Surface whether the HF token actually reached THIS server, so a gated