mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Fix cached GGUF model metadata in Cookbook Serve
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
|
||||
from routes.cookbook_helpers import (
|
||||
_cached_model_scan_script,
|
||||
_append_serve_exit_code_lines,
|
||||
_append_serve_preflight_exit_lines,
|
||||
_local_tooling_path_export,
|
||||
@@ -92,3 +97,29 @@ def test_serve_runner_preserves_command_exit_code():
|
||||
assert "ODYSSEUS_CMD_EXIT=$?" in script
|
||||
assert 'echo "=== Process exited with code $ODYSSEUS_CMD_EXIT ==="' in script
|
||||
assert 'echo "=== Process exited with code $? ==="' not in script
|
||||
|
||||
|
||||
def test_cached_model_scan_reports_plain_dir_gguf(tmp_path):
|
||||
"""Custom download dirs may sit inside the HF hub cache and contain plain
|
||||
per-model folders. They must show up in Serve and keep the GGUF signal."""
|
||||
plain = tmp_path / "Qwen3.6-27B"
|
||||
plain.mkdir()
|
||||
(plain / "Qwen3.6-27B-Q4_K_M.gguf").write_bytes(b"gguf")
|
||||
|
||||
hf_internal = tmp_path / "models--Qwen--Qwen3.6-27B"
|
||||
(hf_internal / "snapshots" / "abc").mkdir(parents=True)
|
||||
(hf_internal / "snapshots" / "abc" / "model.safetensors").write_bytes(b"safe")
|
||||
|
||||
scan_py = tmp_path / "scan_cache.py"
|
||||
scan_py.write_text(_cached_model_scan_script([str(tmp_path)]), encoding="utf-8")
|
||||
proc = subprocess.run(
|
||||
[sys.executable, str(scan_py)],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
by_repo = {m["repo_id"]: m for m in json.loads(proc.stdout)}
|
||||
assert "models--Qwen--Qwen3.6-27B" not in by_repo
|
||||
assert by_repo["Qwen3.6-27B"]["is_local_dir"] is True
|
||||
assert by_repo["Qwen3.6-27B"]["is_gguf"] is True
|
||||
|
||||
Reference in New Issue
Block a user