Skip to content

dataset download: progress bar shows 100% from the start #346

Closed

Description

@neuromechanist

Summary

nemar dataset download <id> displays 100% N/N files from almost the first file completion — the progress bar never climbs, and the final numbers shown mid-download disagree across runs of the same dataset (observed 381/381 · 4.7 GB on one run, 222/222 · 1.7 GB on another for nm000132).

Root cause

DownloadProgressTracker in src/lib/progress.ts is constructed with filesTotal = 0. On every file completion event, processLine does:

```ts
if (this.filesTotal === 0 || this.filesCompleted > this.filesTotal) {
this.filesTotal = this.filesCompleted;
}
```

(see src/lib/progress.ts:110-122)

So the denominator is pinned to the numerator, which guarantees 100%. Byte totals also come only from git-annex's total-size events, which are reported per-file as git-annex queries the S3 remote — that's why the displayed total bytes vary run-to-run.

Fix

  1. Pre-count files and bytes needing download before calling git annex get. Use git annex find --not --in=here --json (or equivalent) to get the list of files still to fetch and sum their sizes. Pass both to the tracker via setFilesTotal and a new setBytesTotal.
  2. Compute progress percentage from bytes (more stable than file count when file sizes vary wildly), keep file count as a secondary stat.
  3. Remove the `filesTotal = filesCompleted` fallback in `processLine` — once `filesTotal` is set authoritatively, stop mutating it.
  4. Add a unit test using a scripted sequence of `byte-progress` and `ok` JSON lines to verify monotonic progression 0→100%.

Files touched

  • `src/lib/progress.ts` — core fix
  • `src/lib/git-annex.ts` — add a helper that returns pending-file count + total bytes (wraps `git annex find --not --in=here --json`)
  • `src/commands/dataset.ts` (download and get commands) — call pre-count before starting the stream
  • Add `test/progress.test.ts` (or equivalent)

Acceptance

  • Downloading `nm000132` shows the bar progressing monotonically 0% → 100% with file count climbing alongside.
  • Final byte total matches `du -sh` of annexed files within rounding.
  • Unit test covers the tracker with a fixed input sequence.

Activity

  1. added
    bug
    on Apr 24, 2026
  2. added 2 commits that reference this issue on Apr 27, 2026
  3. neuromechanist commented on May 14, 2026

    @neuromechanist
    ContributorAuthor

    Closing as already fixed on dev.

    PRs #373 and #375 shipped the fix:

    • src/lib/progress.ts:202,211 has setFilesTotal and setBytesTotal
    • src/lib/git-annex.ts:1538 exports countPendingDownload (uses git annex find --not --in=here --json)
    • Both download and get commands pre-count files+bytes and pass them to the tracker
    • test/progress.test.ts has 10 tests including monotonic 0→100 and a regression-guard against the filesTotal = filesCompleted mutation

    Verified during a parallel cleanup batch (May 2026).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions