Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove last bits of ParseModelPath #4292

Open
wants to merge 10 commits into
base: mxyng/modelname-7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/lifecycle/server_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func terminate(cmd *exec.Cmd) error {
if err != nil {
return err
}
defer dll.Release() // nolint: errcheck
//nolint:errcheck
defer dll.Release()

pid := cmd.Process.Pid

Expand Down Expand Up @@ -73,7 +74,8 @@ func isProcessExited(pid int) (bool, error) {
if err != nil {
return false, fmt.Errorf("failed to open process: %v", err)
}
defer windows.CloseHandle(hProcess) // nolint: errcheck
//nolint:errcheck
defer windows.CloseHandle(hProcess)

var exitCode uint32
err = windows.GetExitCodeProcess(hProcess, &exitCode)
Expand Down
2 changes: 1 addition & 1 deletion readline/readline.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (i *Instance) Readline() (string, error) {

defer func() {
fd := int(syscall.Stdin)
// nolint: errcheck
//nolint:errcheck
UnsetRawMode(fd, i.Terminal.termios)
i.Terminal.rawmode = false
}()
Expand Down
13 changes: 7 additions & 6 deletions server/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/ollama/ollama/api"
"github.com/ollama/ollama/format"
"github.com/ollama/ollama/types/model"
)

const maxRetries = 6
Expand Down Expand Up @@ -332,15 +333,16 @@ func (b *blobDownload) Wait(ctx context.Context, fn func(api.ProgressResponse))
}
}

type downloadOpts struct {
mp ModelPath
type downloadOptions struct {
name model.Name
baseURL *url.URL
digest string
regOpts *registryOptions
fn func(api.ProgressResponse)
}

// downloadBlob downloads a blob from the registry and stores it in the blobs directory
func downloadBlob(ctx context.Context, opts downloadOpts) error {
func downloadBlob(ctx context.Context, opts downloadOptions) error {
fp, err := GetBlobsPath(opts.digest)
if err != nil {
return err
Expand All @@ -365,14 +367,13 @@ func downloadBlob(ctx context.Context, opts downloadOpts) error {
data, ok := blobDownloadManager.LoadOrStore(opts.digest, &blobDownload{Name: fp, Digest: opts.digest})
download := data.(*blobDownload)
if !ok {
requestURL := opts.mp.BaseURL()
requestURL = requestURL.JoinPath("v2", opts.mp.GetNamespaceRepository(), "blobs", opts.digest)
requestURL := opts.baseURL.JoinPath("blobs", opts.digest)
if err := download.Prepare(ctx, requestURL, opts.regOpts); err != nil {
blobDownloadManager.Delete(opts.digest)
return err
}

// nolint: contextcheck
//nolint:contextcheck
go download.Run(context.Background(), requestURL, opts.regOpts)
}

Expand Down
Loading
Loading