Skip to content

Commit

Permalink
types/model: fix tag case
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed May 8, 2024
1 parent 2a5302a commit 486a2c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 7 additions & 5 deletions types/model/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,14 @@ func (n Name) Filepath() string {
if !n.IsFullyQualified() {
panic("illegal attempt to get filepath of invalid name")
}
return strings.ToLower(filepath.Join(
n.Host,
n.Namespace,
n.Model,
return filepath.Join(
strings.ToLower(filepath.Join(
n.Host,
n.Namespace,
n.Model,
)),
n.Tag,
))
)
}

// LogValue returns a slog.Value that represents the name as a string.
Expand Down
14 changes: 12 additions & 2 deletions types/model/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ func TestParseNameParts(t *testing.T) {
wantFilepath string
wantValidDigest bool
}{
{
in: "registry.ollama.ai/library/dolphin-mistral:7b-v2.6-dpo-laser-q6_K",
want: Name{
Host: "registry.ollama.ai",
Namespace: "library",
Model: "dolphin-mistral",
Tag: "7b-v2.6-dpo-laser-q6_K",
},
wantFilepath: filepath.Join("registry.ollama.ai", "library", "dolphin-mistral", "7b-v2.6-dpo-laser-q6_K"),
},
{
in: "scheme://host:port/namespace/model:tag",
want: Name{
Expand Down Expand Up @@ -266,9 +276,9 @@ func TestFilepathAllocs(t *testing.T) {
allocs := testing.AllocsPerRun(1000, func() {
n.Filepath()
})
allowedAllocs := 2.0
var allowedAllocs float64 = 3
if runtime.GOOS == "windows" {
allowedAllocs = 4
allowedAllocs = 5
}
if allocs > allowedAllocs {
t.Errorf("allocs = %v; allowed %v", allocs, allowedAllocs)
Expand Down

0 comments on commit 486a2c1

Please sign in to comment.