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) } }