An adapter now has an owner (org, team, project, user or key): only callers there see it, and to anyone else it is a model that does not exist, absent from /v1/models too. A training job's owner defaults to the one collection its pairs come from, must be able to read every collection they come from, and pairs from a knowledge base are never made public. ctl train publish keeps the GGUF or PEFT files on the mirror, which accepts uploads now, and sets the owned adapter after the usual architecture check. The knowledge bases' cache_salt follows the collections searched rather than the organization, so two teams of one organization no longer share cached passages. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package mirror
|
|
|
|
import (
|
|
"context"
|
|
"net/http/httptest"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/tlsconf"
|
|
)
|
|
|
|
func TestAFileSentToTheMirrorIsKeptWithItsChecksumAndNeverReplaced(t *testing.T) {
|
|
root := t.TempDir()
|
|
srv := httptest.NewServer(NewAPI(NewManager(root, nil), "http://mirror:8081").Handler())
|
|
defer srv.Close()
|
|
c, err := NewClient(srv.URL, tlsconf.Config{}, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ctx := context.Background()
|
|
got, err := c.Upload(ctx, "politika-tonu", "train-1", "politika-tonu.gguf", []byte("GGUF adapter"), "trained by job train-1")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got.URL != "http://mirror:8081/politika-tonu/train-1/politika-tonu.gguf" || got.Status.BytesTotal != 12 {
|
|
t.Errorf("answered %+v", got)
|
|
}
|
|
e := Entry{Model: "politika-tonu", Version: "train-1", File: "politika-tonu.gguf"}
|
|
if b, _ := os.ReadFile(e.Path(root)); string(b) != "GGUF adapter" {
|
|
t.Errorf("kept %q", b)
|
|
}
|
|
if b, _ := os.ReadFile(sourcePath(e.Path(root))); !strings.Contains(string(b), "train-1") {
|
|
t.Errorf("source %q", b)
|
|
}
|
|
if _, err := os.Stat(checksumPath(e.Path(root))); err != nil {
|
|
t.Errorf("no checksum: %v", err)
|
|
}
|
|
if _, err := c.Upload(ctx, "politika-tonu", "train-1", "politika-tonu.gguf", []byte("other"), "x"); err == nil {
|
|
t.Error("an existing version was replaced")
|
|
}
|
|
if _, err := c.Upload(ctx, "../etc", "v", "f", []byte("x"), "x"); err == nil {
|
|
t.Error("a path outside the mirror was taken")
|
|
}
|
|
}
|