Skip to content

Redesign --sync as optional-value option (ask/do) for download and upload#1835

Open
yarikoptic-gitmate wants to merge 2 commits intomasterfrom
claude/fix-existing-issue-T39NW
Open

Redesign --sync as optional-value option (ask/do) for download and upload#1835
yarikoptic-gitmate wants to merge 2 commits intomasterfrom
claude/fix-existing-issue-T39NW

Conversation

@yarikoptic-gitmate
Copy link
Copy Markdown
Collaborator

@yarikoptic-gitmate yarikoptic-gitmate commented Apr 11, 2026

Summary

  • Redesigns --sync from a boolean flag to an optional-value option accepting ask or do, on both dandi download and dandi upload
  • --sync alone (bare flag) defaults to ask — preserving full backward compatibility
  • --sync do skips the interactive prompt and proceeds with deletion, enabling headless usage (CI/CD, cron jobs)
  • Adds SyncMode enum in consts.py shared between download and upload
  • Python API still accepts bool for backward compatibility (True normalizes to SyncMode.ASK)

Usage

dandi download --sync ...         # prompts before deleting (same as before)
dandi download --sync ask ...     # prompts (explicit)
dandi download --sync do ...      # no prompt, headless-friendly

dandi upload --sync ...           # prompts before deleting (same as before)
dandi upload --sync do ...        # no prompt

Closes #1833

Changes

  • dandi/consts.py: Added SyncMode enum (ask, do)
  • dandi/cli/cmd_download.py: Changed --sync from is_flag=True to optional-value with flag_value="ask" and type=Choice(["ask", "do"]); removed the separate --yes flag from the prior commit
  • dandi/cli/cmd_upload.py: Same --sync redesign as download
  • dandi/download.py: Changed sync parameter type to bool | SyncMode | None; when SyncMode.DO, skips abbrev_prompt
  • dandi/upload.py: Changed sync parameter type to bool | SyncMode | None; when SyncMode.DO, skips click.confirm
  • dandi/tests/test_download.py: Added test_download_sync_do verifying prompt is skipped
  • dandi/tests/test_upload.py: Added test_upload_sync_do verifying prompt is skipped

Test plan

  • All pre-commit hooks pass (black, isort, flake8, codespell)
  • --sync with no value, --sync ask, --sync do, --sync=do all accepted by CLI
  • --yes flag removed from download
  • SyncMode enum logic verified (truthiness, normalization from bool)
  • Pure unit tests pass
  • test_download_sync_do and test_upload_sync_do verify prompt-free deletion
  • Full integration tests require docker — skipped in this environment but follow established patterns

https://claude.ai/code/session_01297X1VGdztFArkpVFB1zEk

When using `dandi download --sync`, the CLI prompts for confirmation
before deleting local assets not found on the server. This fails in
headless environments (CI/CD, cron jobs) where no interactive terminal
is available. The new `--yes` / `-y` flag auto-confirms such prompts.

Closes #1833

https://claude.ai/code/session_01297X1VGdztFArkpVFB1zEk
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 89.58333% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.57%. Comparing base (0af950f) to head (d8f433d).

Files with missing lines Patch % Lines
dandi/consts.py 0.00% 5 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0af950f) and HEAD (d8f433d). Click for more details.

HEAD has 47 uploads less than BASE
Flag BASE (0af950f) HEAD (d8f433d)
unittests 49 2
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1835       +/-   ##
===========================================
- Coverage   76.27%   51.57%   -24.70%     
===========================================
  Files          87       87               
  Lines       12484    12517       +33     
===========================================
- Hits         9522     6456     -3066     
- Misses       2962     6061     +3099     
Flag Coverage Δ
unittests 51.57% <89.58%> (-24.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…load

Instead of a separate --yes flag, make --sync itself accept an optional
value: 'ask' (default when --sync is passed bare, preserving backward
compatibility) prompts before deleting, while 'do' deletes without
prompting. This applies to both `dandi download --sync` and
`dandi upload --sync`, keeping the control co-located with the feature.

Usage:
  dandi download --sync ...         # prompts (same as before)
  dandi download --sync ask ...     # prompts (explicit)
  dandi download --sync do ...      # no prompt, headless-friendly

The Python API still accepts bool for backward compatibility
(True is normalized to SyncMode.ASK).

Closes #1833

https://claude.ai/code/session_01297X1VGdztFArkpVFB1zEk
@yarikoptic-gitmate yarikoptic-gitmate changed the title Add --yes/-y flag to dandi download for headless sync Redesign --sync as optional-value option (ask/do) for download and upload Apr 11, 2026
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.

Need --yes flag for --sync

2 participants