Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
eeb40a67
"docs/git@developer.sourcefind.cn:OpenDAS/pytorch3d.git" did not exist on "6c053a6cea38ad323047d92da99d38e740f19845"
Commit
eeb40a67
authored
Aug 30, 2023
by
Michael Yang
Browse files
fix list models for windows
parent
0f541a03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
27 deletions
+14
-27
server/modelpath.go
server/modelpath.go
+1
-1
server/routes.go
server/routes.go
+13
-26
No files found.
server/modelpath.go
View file @
eeb40a67
...
@@ -46,7 +46,7 @@ func ParseModelPath(name string) ModelPath {
...
@@ -46,7 +46,7 @@ func ParseModelPath(name string) ModelPath {
name
=
after
name
=
after
}
}
parts
:=
strings
.
Split
(
name
,
"/"
)
parts
:=
strings
.
Split
(
name
,
string
(
os
.
PathSeparator
)
)
switch
len
(
parts
)
{
switch
len
(
parts
)
{
case
3
:
case
3
:
mp
.
Registry
=
parts
[
0
]
mp
.
Registry
=
parts
[
0
]
...
...
server/routes.go
View file @
eeb40a67
...
@@ -3,7 +3,6 @@ package server
...
@@ -3,7 +3,6 @@ package server
import
(
import
(
"context"
"context"
"encoding/json"
"encoding/json"
"errors"
"fmt"
"fmt"
"io"
"io"
"log"
"log"
...
@@ -371,26 +370,12 @@ func ListModelsHandler(c *gin.Context) {
...
@@ -371,26 +370,12 @@ func ListModelsHandler(c *gin.Context) {
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
err
=
filepath
.
Walk
(
fp
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
!=
nil
{
walkFunc
:=
func
(
path
string
,
info
os
.
FileInfo
,
_
error
)
error
{
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
log
.
Printf
(
"manifest file does not exist: %s"
,
fp
)
return
nil
}
return
err
}
if
!
info
.
IsDir
()
{
if
!
info
.
IsDir
()
{
fi
,
err
:=
os
.
Stat
(
path
)
dir
,
file
:=
filepath
.
Split
(
path
)
if
err
!=
nil
{
dir
=
strings
.
Trim
(
strings
.
TrimPrefix
(
dir
,
fp
),
string
(
os
.
PathSeparator
))
log
.
Printf
(
"skipping file: %s"
,
fp
)
tag
:=
strings
.
Join
([]
string
{
dir
,
file
},
":"
)
return
nil
}
path
:=
path
[
len
(
fp
)
+
1
:
]
slashIndex
:=
strings
.
LastIndex
(
path
,
"/"
)
if
slashIndex
==
-
1
{
return
nil
}
tag
:=
path
[
:
slashIndex
]
+
":"
+
path
[
slashIndex
+
1
:
]
mp
:=
ParseModelPath
(
tag
)
mp
:=
ParseModelPath
(
tag
)
manifest
,
digest
,
err
:=
GetManifest
(
mp
)
manifest
,
digest
,
err
:=
GetManifest
(
mp
)
...
@@ -398,17 +383,19 @@ func ListModelsHandler(c *gin.Context) {
...
@@ -398,17 +383,19 @@ func ListModelsHandler(c *gin.Context) {
log
.
Printf
(
"skipping file: %s"
,
fp
)
log
.
Printf
(
"skipping file: %s"
,
fp
)
return
nil
return
nil
}
}
model
:=
api
.
ModelResponse
{
models
=
append
(
models
,
api
.
ModelResponse
{
Name
:
mp
.
GetShortTagname
(),
Name
:
mp
.
GetShortTagname
(),
Size
:
manifest
.
GetTotalSize
(),
Size
:
manifest
.
GetTotalSize
(),
Digest
:
digest
,
Digest
:
digest
,
ModifiedAt
:
fi
.
ModTime
(),
ModifiedAt
:
info
.
ModTime
(),
}
})
models
=
append
(
models
,
model
)
}
}
return
nil
return
nil
})
}
if
err
!=
nil
{
if
err
:=
filepath
.
Walk
(
fp
,
walkFunc
);
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error"
:
err
.
Error
()})
return
return
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment