CI / test (push) Successful in 9m15s
- Revoking a server's tools takes them from every level beneath too, and a level left naming no tool stays closed ([]) while any level above or beneath names tools: an organization's revoke left its teams the copies their first grants took, and going back to no list opened the level to what was above it. A closed level is shown on the page and in the console with an action to open it (store.OpenTools). A key's owner's list is among the levels above a key. - The flag check matches short flags as written again (-m, -hf, -mu were let through), takes a long flag's beginning for it only for the engines that parse with argparse (vLLM, SGLang, ComfyUI: --li is --listen), so llama.cpp's own --chat-template is not refused, and refuses llama.cpp's short spellings (-hfr, -hff, -mm, -jf, …). - A stored model with an adapter by Hugging Face id can be changed again: what it already had is not asked about anew. - The catalog reads a Hugging Face id as the agent does (engines.IsHubID). - The page's form cannot move llmgw:admin to another address. - server init skips the memory check only where the gateway already runs, not wherever a half-finished first run left server.yaml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.9 KiB
Go
77 lines
2.9 KiB
Go
package catalog
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAModelInAPickleFormatIsRefusedUnlessItSaysSo(t *testing.T) {
|
|
m := Model{Name: "triposr", Source: "hf:stabilityai/TripoSR/model.ckpt",
|
|
Adapters: []Adapter{{Name: "a", Source: "http://m/a/adapter_model.bin"}}}
|
|
err := m.CheckPickle()
|
|
if err == nil || !strings.Contains(err.Error(), "model.ckpt") || !strings.Contains(err.Error(), "allow_pickle") {
|
|
t.Fatalf("not refused, or not said why: %v", err)
|
|
}
|
|
if got := m.PickleSources(); len(got) != 2 {
|
|
t.Errorf("pickle sources %v, want the model's and the adapter's", got)
|
|
}
|
|
// A source that was there before is not asked about again: changing
|
|
// the scaling of a model that runs does not need allow_pickle.
|
|
if err := m.CheckPickle(m.PickleSources()...); err != nil {
|
|
t.Errorf("sources already there were refused: %v", err)
|
|
}
|
|
m.AllowPickle = true
|
|
if err := m.CheckPickle(); err != nil {
|
|
t.Errorf("allow_pickle was not honoured: %v", err)
|
|
}
|
|
if err := (Model{Name: "q", Source: "http://m/q/v/q-Q4_K_M.gguf"}).CheckPickle(); err != nil {
|
|
t.Errorf("a GGUF was refused: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestTheTripoSRPresetSaysItsCheckpointIsAllowed(t *testing.T) {
|
|
p, ok := PresetNamed("triposr")
|
|
if !ok {
|
|
t.Fatal("no triposr preset")
|
|
}
|
|
if err := p.Model.CheckPickle(); err != nil {
|
|
t.Errorf("the preset llmgw ships is refused by its own check: %v", err)
|
|
}
|
|
}
|
|
|
|
func TestWhatAnEngineDownloadsByIDIsAskedAbout(t *testing.T) {
|
|
m := Model{Name: "m", Source: "http://mirror/m/v/", Profiles: []Profile{{Name: "gpu", Engine: "vllm"}},
|
|
Adapters: []Adapter{{Name: "a", Source: "someone/lora-x"}}}
|
|
if err := m.CheckPickle(); err == nil || !strings.Contains(err.Error(), "someone/lora-x") {
|
|
t.Errorf("an adapter by its id: %v", err)
|
|
}
|
|
m.Adapters = []Adapter{{Name: "a", Source: "http://mirror/a/v/adapter_model.safetensors"}}
|
|
if err := m.CheckPickle(); err != nil {
|
|
t.Errorf("a mirrored adapter: %v", err)
|
|
}
|
|
trt := Model{Name: "t", Source: "meta-llama/Llama-3.1-8B-Instruct", Profiles: []Profile{{Name: "gpu", Engine: "trtllm"}}}
|
|
if err := trt.CheckPickle(); err == nil {
|
|
t.Error("TensorRT-LLM downloading by id was not asked about")
|
|
}
|
|
vllm := Model{Name: "v", Source: "meta-llama/Llama-3.1-8B-Instruct", Profiles: []Profile{{Name: "gpu", Engine: "vllm"}}}
|
|
if err := vllm.CheckPickle(); err != nil {
|
|
t.Errorf("vLLM reads a model by id as safetensors only: %v", err)
|
|
}
|
|
for s, want := range map[string]bool{"Qwen/Qwen2.5-7B": true, "meta-llama/Llama-3.1-8B-Instruct": true,
|
|
"org/model.gguf": false, "o/r:Q4_K_M": false, "/models/x": false, "hf:o/r/f.gguf": false,
|
|
"gpt2": true, "~me/x": false} {
|
|
if hubID(s) != want {
|
|
t.Errorf("hubID(%q) = %v", s, !want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestEveryPresetPassesItsOwnPickleCheck(t *testing.T) {
|
|
// What llmgw ships must be addable: TripoSR was not, once.
|
|
for _, p := range Presets() {
|
|
if err := p.Model.CheckPickle(); err != nil {
|
|
t.Errorf("%s: %v", p.Model.Name, err)
|
|
}
|
|
}
|
|
}
|