Skip to content

dataset download: add --resume flag to retry partial downloads #347

Closed

Description

@neuromechanist

Summary

`nemar dataset download ` currently refuses to proceed if the output path already exists:

```
Error: Output path already exists: /Volumes/S1/Datasets/nm000132
Remove or rename the existing directory and try again.
```

(see `src/commands/dataset.ts:1704-1708`)

This makes partial downloads unrecoverable — the user must `rm -rf` and re-clone, discarding any data already pulled. A `--resume` flag should reuse the existing clone and only pull missing files (git-annex already supports this natively).

Proposed behavior

When `--resume` is passed:

  1. If `` exists, verify it is a git-annex repo and `getDatasetIdFromRemote` returns the requested ``. If either fails, error out clearly.
  2. Skip the `git clone` step.
  3. Re-fetch S3 download credentials (reusing `requestDownloadCredentials`) and re-enable the S3 remote (`enableS3Remote` is already idempotent).
  4. Run `getDatasetData` — `git annex get` skips files already present locally.
  5. Refuse resume if the working tree is dirty (uncommitted local changes).
  6. Refuse resume if the local `dataset_description.json` Version differs from the remote HEAD Version — point to `--update` (see #TBD) instead.

Without `--resume`, keep the current error (prevents accidental overwrite).

Files touched

  • `src/commands/dataset.ts` — `.command("download")` action at line 1621
  • Reuse existing `getDatasetIdFromRemote`, `isGitAnnexDataset`, `enableS3Remote`, `getDatasetData`

Acceptance

  • `nemar dataset download nm000132` interrupted mid-download → `nemar dataset download nm000132 --resume` completes the remaining files without re-cloning.
  • Running `--resume` against a wrong dataset ID or non-git-annex directory produces a clear error.
  • Running `--resume` with a dirty working tree is refused.
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions