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
acfc376e
Commit
acfc376e
authored
Dec 15, 2023
by
Michael Yang
Browse files
add .golangci.yaml
parent
99725314
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
10 deletions
+37
-10
.golangci.yaml
.golangci.yaml
+27
-0
readline/history.go
readline/history.go
+2
-2
server/download.go
server/download.go
+3
-3
server/manifests.go
server/manifests.go
+2
-2
server/routes.go
server/routes.go
+2
-1
server/routes_test.go
server/routes_test.go
+0
-1
server/upload.go
server/upload.go
+1
-1
No files found.
.golangci.yaml
0 → 100644
View file @
acfc376e
run
:
timeout
:
5m
linters
:
enable
:
-
asasalint
-
bidichk
-
bodyclose
-
containedctx
-
contextcheck
-
exportloopref
-
gocheckcompilerdirectives
# FIXME: for some reason this errors on windows
# - gofmt
# - goimports
-
misspell
-
nilerr
-
unused
linters-settings
:
errcheck
:
# exclude the following functions since we don't generally
# need to be concerned with the returned errors
exclude-functions
:
-
encoding/binary.Read
-
(*os.File).Seek
-
(*bufio.Writer).WriteString
-
(*github.com/spf13/pflag.FlagSet).Set
-
(*github.com/jmorganca/ollama/llm.readSeekOffset).Seek
readline/history.go
View file @
acfc376e
...
@@ -49,7 +49,7 @@ func (h *History) Init() error {
...
@@ -49,7 +49,7 @@ func (h *History) Init() error {
h
.
Filename
=
path
h
.
Filename
=
path
f
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_CREATE
|
os
.
O_RDONLY
,
0600
)
f
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_CREATE
|
os
.
O_RDONLY
,
0
o
600
)
if
err
!=
nil
{
if
err
!=
nil
{
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
if
errors
.
Is
(
err
,
os
.
ErrNotExist
)
{
return
nil
return
nil
...
@@ -132,7 +132,7 @@ func (h *History) Save() error {
...
@@ -132,7 +132,7 @@ func (h *History) Save() error {
tmpFile
:=
h
.
Filename
+
".tmp"
tmpFile
:=
h
.
Filename
+
".tmp"
f
,
err
:=
os
.
OpenFile
(
tmpFile
,
os
.
O_CREATE
|
os
.
O_WRONLY
|
os
.
O_TRUNC
|
os
.
O_APPEND
,
0666
)
f
,
err
:=
os
.
OpenFile
(
tmpFile
,
os
.
O_CREATE
|
os
.
O_WRONLY
|
os
.
O_TRUNC
|
os
.
O_APPEND
,
0
o
666
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
server/download.go
View file @
acfc376e
...
@@ -98,7 +98,7 @@ func (b *blobDownload) Prepare(ctx context.Context, requestURL *url.URL, opts *R
...
@@ -98,7 +98,7 @@ func (b *blobDownload) Prepare(ctx context.Context, requestURL *url.URL, opts *R
b
.
Total
,
_
=
strconv
.
ParseInt
(
resp
.
Header
.
Get
(
"Content-Length"
),
10
,
64
)
b
.
Total
,
_
=
strconv
.
ParseInt
(
resp
.
Header
.
Get
(
"Content-Length"
),
10
,
64
)
var
size
=
b
.
Total
/
numDownloadParts
size
:
=
b
.
Total
/
numDownloadParts
switch
{
switch
{
case
size
<
minDownloadPartSize
:
case
size
<
minDownloadPartSize
:
size
=
minDownloadPartSize
size
=
minDownloadPartSize
...
@@ -132,7 +132,7 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
...
@@ -132,7 +132,7 @@ func (b *blobDownload) run(ctx context.Context, requestURL *url.URL, opts *Regis
defer
blobDownloadManager
.
Delete
(
b
.
Digest
)
defer
blobDownloadManager
.
Delete
(
b
.
Digest
)
ctx
,
b
.
CancelFunc
=
context
.
WithCancel
(
ctx
)
ctx
,
b
.
CancelFunc
=
context
.
WithCancel
(
ctx
)
file
,
err
:=
os
.
OpenFile
(
b
.
Name
+
"-partial"
,
os
.
O_CREATE
|
os
.
O_RDWR
,
0644
)
file
,
err
:=
os
.
OpenFile
(
b
.
Name
+
"-partial"
,
os
.
O_CREATE
|
os
.
O_RDWR
,
0
o
644
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -246,7 +246,7 @@ func (b *blobDownload) readPart(partName string) (*blobDownloadPart, error) {
...
@@ -246,7 +246,7 @@ func (b *blobDownload) readPart(partName string) (*blobDownloadPart, error) {
}
}
func
(
b
*
blobDownload
)
writePart
(
partName
string
,
part
*
blobDownloadPart
)
error
{
func
(
b
*
blobDownload
)
writePart
(
partName
string
,
part
*
blobDownloadPart
)
error
{
partFile
,
err
:=
os
.
OpenFile
(
partName
,
os
.
O_CREATE
|
os
.
O_RDWR
|
os
.
O_TRUNC
,
0644
)
partFile
,
err
:=
os
.
OpenFile
(
partName
,
os
.
O_CREATE
|
os
.
O_RDWR
|
os
.
O_TRUNC
,
0
o
644
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
server/manifests.go
View file @
acfc376e
...
@@ -26,9 +26,9 @@ func WriteManifest(name string, config *Layer, layers []*Layer) error {
...
@@ -26,9 +26,9 @@ func WriteManifest(name string, config *Layer, layers []*Layer) error {
return
err
return
err
}
}
if
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
manifestPath
),
0755
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
manifestPath
),
0
o
755
);
err
!=
nil
{
return
err
return
err
}
}
return
os
.
WriteFile
(
manifestPath
,
b
.
Bytes
(),
0644
)
return
os
.
WriteFile
(
manifestPath
,
b
.
Bytes
(),
0
o
644
)
}
}
server/routes.go
View file @
acfc376e
...
@@ -198,7 +198,8 @@ func GenerateHandler(c *gin.Context) {
...
@@ -198,7 +198,8 @@ func GenerateHandler(c *gin.Context) {
c
.
JSON
(
http
.
StatusOK
,
api
.
GenerateResponse
{
c
.
JSON
(
http
.
StatusOK
,
api
.
GenerateResponse
{
CreatedAt
:
time
.
Now
()
.
UTC
(),
CreatedAt
:
time
.
Now
()
.
UTC
(),
Model
:
req
.
Model
,
Model
:
req
.
Model
,
Done
:
true
})
Done
:
true
,
})
return
return
}
}
...
...
server/routes_test.go
View file @
acfc376e
...
@@ -201,5 +201,4 @@ func Test_Routes(t *testing.T) {
...
@@ -201,5 +201,4 @@ func Test_Routes(t *testing.T) {
}
}
}
}
}
}
server/upload.go
View file @
acfc376e
...
@@ -88,7 +88,7 @@ func (b *blobUpload) Prepare(ctx context.Context, requestURL *url.URL, opts *Reg
...
@@ -88,7 +88,7 @@ func (b *blobUpload) Prepare(ctx context.Context, requestURL *url.URL, opts *Reg
return
nil
return
nil
}
}
var
size
=
b
.
Total
/
numUploadParts
size
:
=
b
.
Total
/
numUploadParts
switch
{
switch
{
case
size
<
minUploadPartSize
:
case
size
<
minUploadPartSize
:
size
=
minUploadPartSize
size
=
minUploadPartSize
...
...
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