Skip to content

feat: cog weights download progress#3087

Open
anish-sahoo wants to merge 6 commits into
mainfrom
weights-loading
Open

feat: cog weights download progress#3087
anish-sahoo wants to merge 6 commits into
mainfrom
weights-loading

Conversation

@anish-sahoo

@anish-sahoo anish-sahoo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • show live Docker-style download progress while cog weights import warms the local weight store
  • show live Docker-style download progress while cog weights pull populates a cold local cache
  • add focused tests for import and pull progress events

Testing

  • mise run fmt:go:fix
  • go test ./pkg/cli
  • go test ./pkg/model
  • go test ./pkg/weights
  • mise run lint:go

@anish-sahoo anish-sahoo requested a review from a team as a code owner June 30, 2026 21:50
@ask-bonk

ask-bonk Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@anish-sahoo anish-sahoo changed the title Show weights import download progress feat: cog weights import progress bar Jun 30, 2026
@anish-sahoo anish-sahoo changed the title feat: cog weights import progress bar feat: weights import progress bar Jun 30, 2026
@ask-bonk

ask-bonk Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR adds live download progress display during cog weights import by plumbing a progress callback through the weight builder and ingress pipeline, with a focused test verifying progress event generation.

I found one issue with the progress display logic.

Comment thread pkg/cli/weights.go Outdated
id = model.ShortDigest(prog.FileDigest)
}

if prog.Done && prog.Complete >= prog.Total {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intermediate files that finish downloading aren't marked as complete:

The prog.Done flag is set for every file that finishes ingress, but the prog.Complete >= prog.Total check prevents marking any file except the last one as "Download complete". Each file has its own progress line (via the weightName/fileName ID), so completed files should show completion regardless of cumulative progress.

Suggested change
if prog.Done && prog.Complete >= prog.Total {
if prog.Done {
pw.WriteStatus(id, "Download complete")
return
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7f1d0fb by marking a file complete whenever prog.Done is set, regardless of cumulative weight progress.

@ask-bonk

ask-bonk Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

This PR adds live download progress display during cog weights import by plumbing a progress callback through the weight builder and ingress pipeline, with a focused test verifying progress event generation.

I found one issue with the progress display logic.

Posted a batch review with a suggestion to fix intermediate files not being marked as "Download complete" in pkg/cli/weights.go:175.

github run

@anish-sahoo anish-sahoo changed the title feat: weights import progress bar Show weights download progress Jun 30, 2026
@anish-sahoo anish-sahoo changed the title Show weights download progress feat: cog weights download progress Jun 30, 2026

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR adds live download progress display during cog weights import and cog weights pull by plumbing progress callbacks through the weight builder and ingress/pull pipeline, with focused tests verifying progress event generation.

I found two issues with the progress display logic.

Comment thread pkg/cli/weights.go
Comment thread pkg/weights/pull.go
@ask-bonk

ask-bonk Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Posted a batch review on PR #3087 with two suggestions:

  1. pkg/cli/weights.go:175 — Remove prog.Complete >= prog.Total so intermediate files show "Download complete" when they finish.
  2. pkg/weights/pull.go:305-318 — Add throttling to pullProgressReader (matching progressReader's 250ms interval) to prevent console flooding on large files.

github run

@ask-bonk

ask-bonk Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@anish-sahoo Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR adds live download progress display during cog weights import and cog weights pull by plumbing progress callbacks through the weight builder and ingress/pull pipeline, with focused tests verifying progress event generation.

I found one remaining issue with the progress display logic.

Comment thread pkg/weights/pull.go
@ask-bonk

ask-bonk Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

This PR adds live download progress display during cog weights import and cog weights pull by plumbing progress callbacks through the weight builder and ingress/pull pipeline, with focused tests verifying progress event generation.

I found one remaining issue with the progress display logic.

1. pkg/weights/pull.go:305-318pullProgressReader emits a progress event on every Read() call without throttling, while progressReader in pkg/model/packer.go uses a 250ms interval to avoid flooding the console. For large files this can mean thousands of progress events per file. Add the same throttling behavior for consistent UX (also add "time" to the imports):

type pullProgressReader struct {
	r            io.Reader
	complete     int64
	lastReported int64
	lastUpdate   time.Time
	interval     time.Duration
	fn           func(int64)
}

func (r *pullProgressReader) Read(p []byte) (int, error) {
	n, err := r.r.Read(p)
	if n > 0 {
		r.complete += int64(n)
		now := time.Now()
		interval := r.interval
		if interval == 0 {
			interval = 250 * time.Millisecond
		}
		if r.lastReported == 0 || now.Sub(r.lastUpdate) >= interval {
			r.lastReported = r.complete
			r.lastUpdate = now
			r.fn(r.complete)
		}
	}
	return n, err
}

Posted a batch review on PR #3087 with this suggestion.

github run

@ask-bonk

ask-bonk Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I've reviewed the current state of PR #3087. Both previously identified issues have been addressed:

  1. pkg/cli/weights.go:175 — Fixed to mark each file complete when prog.Done is set, without the cumulative progress check.
  2. pkg/weights/pull.gopullProgressReader now implements proper throttling with a 250ms default interval, matching progressReader in packer.go.

I've also verified the progress event plumbing through weight_builder.go, the pull command in weights_pull.go, and the focused tests in both packer_test.go and pull_test.go. Everything looks consistent and correct.

LGTM

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant