fix: 500er bei register/update_model/install-recipe, Download & favicon
- write_config schreibt atomar (tmp + os.replace) -> llama-swap (-watch-config) sieht nie eine halb geschriebene config.yaml; PermissionError wird in eine klare Klartext-Meldung uebersetzt (Hinweis auf chown) - generischer Exception-Handler: unerwartete Fehler kommen als lesbare JSON- Meldung im UI an statt als nackter 500 (Anfaenger-Diagnose) - Download: nutzt die `hf`-CLI aus dem venv (Dienst-PATH kennt venv/bin nicht) + HF_HUB_DISABLE_XET=1 statt HF_XET_HIGH_PERFORMANCE (XET-Haenger bei ~6 MB) - huggingface_hub als Dependency ergaenzt (liefert `hf`) - favicon.ico: themed SVG (Link-Tag + Route) -> kein 404 mehr Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+12
-2
@@ -19,11 +19,20 @@ from llamaswap import _swap_get, read_config, write_config
|
||||
from hw_math import extract_params_b, max_ctx_for, estimate_memory_gb
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import psutil
|
||||
|
||||
router = APIRouter(prefix="/api", dependencies=[Depends(auth)])
|
||||
|
||||
|
||||
def _hf_bin() -> str:
|
||||
"""Pfad zur `hf`-CLI. Bevorzugt die im venv installierte (neben dem laufenden
|
||||
Python), da der Dienst-PATH das venv/bin meist nicht enthaelt. Faellt sonst auf
|
||||
ein global installiertes `hf` zurueck."""
|
||||
cand = os.path.join(os.path.dirname(sys.executable), "hf")
|
||||
return cand if os.path.exists(cand) else "hf"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Request-Modelle
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -139,8 +148,9 @@ def download(req: DownloadReq):
|
||||
sub = req.subdir or req.repo.split("/")[-1]
|
||||
target = MODELS_DIR / sub
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
args = ["hf", "download", req.repo, req.file, "--local-dir", str(target)]
|
||||
env = {"HF_XET_HIGH_PERFORMANCE": "1"}
|
||||
args = [_hf_bin(), "download", req.repo, req.file, "--local-dir", str(target)]
|
||||
# XET deaktivieren: mit aktivem XET haengt der Download reproduzierbar bei ~6 MB (siehe CLAUDE.md).
|
||||
env = {"HF_HUB_DISABLE_XET": "1"}
|
||||
if req.hf_token:
|
||||
env["HF_TOKEN"] = req.hf_token
|
||||
job_id = start_job(args, f"download {req.repo}/{req.file}", env=env)
|
||||
|
||||
Reference in New Issue
Block a user