File size: 1,858 Bytes
857a91b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package store

import "testing"

func TestModelProfilesAndInstallations(t *testing.T) {
	s := newTestStore(t)
	u, err := s.Signup("Neo", "neo@zion.io", "redpill1", "")
	if err != nil {
		t.Fatal(err)
	}
	ws := u.WorkspaceID

	p, err := s.CreateProfile(ModelProfile{
		WorkspaceID: ws, SourceType: "huggingface", Provider: "Hugging Face",
		ExternalID: "deepseek-ai/DeepSeek-V3", DisplayName: "deepseek-ai/DeepSeek-V3",
		Task: "text-generation", Library: "transformers", License: "mit",
		Tags: []string{"moe"}, Metadata: map[string]any{"gpu": true},
	})
	if err != nil {
		t.Fatal(err)
	}
	if p.Status != "profile_only" {
		t.Errorf("default status = %q", p.Status)
	}

	list, err := s.ListProfiles(ws)
	if err != nil || len(list) != 1 || list[0].Tags[0] != "moe" {
		t.Fatalf("ListProfiles = %v err=%v", list, err)
	}

	in, err := s.CreateInstallation(ModelInstallation{
		WorkspaceID: ws, ModelProfileID: p.ID, RuntimeID: "rt_gpu_01",
		InstallMode: "pull_from_source", ServingEngine: "vLLM",
	})
	if err != nil {
		t.Fatal(err)
	}
	if err := s.UpdateInstallation(in.ID, "downloading", 43, "", ""); err != nil {
		t.Fatal(err)
	}
	if err := s.UpdateInstallation(in.ID, "ready", 100, "/var/lib/x", ""); err != nil {
		t.Fatal(err)
	}
	if err := s.SetProfileStatus(p.ID, "ready"); err != nil {
		t.Fatal(err)
	}

	ins, err := s.ListInstallations(ws)
	if err != nil || len(ins) != 1 {
		t.Fatalf("ListInstallations = %v err=%v", ins, err)
	}
	got := ins[0]
	if got.Status != "ready" || got.Progress != 100 || got.LocalPath != "/var/lib/x" {
		t.Errorf("installation not updated: %+v", got)
	}
	if got.ModelName != "deepseek-ai/DeepSeek-V3" || got.Provider != "Hugging Face" {
		t.Errorf("join fields missing: %+v", got)
	}

	pr, err := s.GetProfile(ws, p.ID)
	if err != nil || pr.Status != "ready" {
		t.Fatalf("GetProfile status = %v err=%v", pr, err)
	}
}