Skip to content

Conversation

@yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented Jan 30, 2026

Description

During one of the recent Zooms @chrisfoulon pointed to his https://github.com/chrisfoulon/LAD, which I decided to give a shot to. So far experience was quite fun! Unfortunately because of that this PR is a cocktail of things, such as adding LAD itself and then making it review codebase regarding testing and also propose and implement some minor enhancements. For better digestion I will

  • fixup CI to get it green first (done in other PRs)
    • blocking: see if tests got broken or not
  • submit a separate PR with just addition of .lad/ to make it easier to review etc,
  • break into multiple PRs.

This PR enhances the developer experience through improved documentation and more actionable error messages. Changes were made systematically based on LAD (LLM-Assisted Development) test quality framework analysis, with each improvement committed separately and verified with the full test suite (548 tests, 100% pass rate).

Overview

  • Documentation improvements: Added comprehensive module docstrings and reorganized testing/contributing documentation into Sphinx
  • Error message enhancements: Made error messages more actionable with specific hints and command references
  • Code quality: Cleaned up type annotations and removed unnecessary complexity
  • File organization: Established guidelines to prevent temporary analysis files from cluttering the project root

Key Changes

1. Documentation Improvements (Commits: dedec0e, 5237428, 7494681, 15b1854)

Added comprehensive module docstrings to improve IDE support and code navigation:

  • Core API modules (dandiapi.py, exceptions.py, consts.py)
  • Operation modules (download.py, upload.py, delete.py, move.py, organize.py)
  • Validation modules (validate.py, pynwb_utils.py)

Reorganized testing documentation:

  • Created Sphinx-based development documentation (docs/source/development/)
  • Added comprehensive testing guide with Quick Reference, Test Organization, and Docker Setup
  • Added contributing workflow guide
  • Integrated into main documentation for better searchability
  • Updated CLAUDE.md with file placement guidelines
  • Updated DEVELOPMENT.md to reference new Sphinx docs

File organization:

  • Reserved .lad/tmp/ for LAD session artifacts and temporary analysis files
  • Added .lad/tmp/ to .gitignore
  • Prevents clutter in project root while maintaining working documents

See commits:

  • dedec0e - Reorganize testing documentation and add file placement guidelines
  • 5237428 - Add module docstrings to core API and configuration modules
  • 7494681 - Add module docstrings to operation modules
  • 15b1854 - Add module docstrings to validation and NWB utilities

2. Error Message Enhancements (Commits: 470467b, 3922285, 7c1788e, fb9ea70)

Made error messages more actionable with specific guidance on how to fix issues:

Dandiset metadata errors (dandiset.py):

  • "No dandiset.yaml found" → Now explains what's missing and suggests dandi download
  • "No metadata record found" → Explains file may be empty/corrupted with recovery steps
  • "No identifier found" → Clarifies required field structure

API client errors (dandiapi.py):

  • "api_url and dandi_instance are mutually exclusive" → Explains proper usage
  • "No such Dandiset" → Suggests verifying ID, checking permissions, and links to web UI
  • "No such asset" → References dandi ls command and includes version context

Path validation errors (move.py):

  • "Path outside of Dandiset" → Explains '..' restriction and directory structure requirements
  • "Cannot move current working directory" → Suggests changing directory first
  • "Path is a file" vs directory → Clarifies slash suffix convention

Upload/download errors (upload.py, download.py):

  • "File not found" → Adds file path context
  • "Failed validation" → References dandi validate command for details
  • "Failed to compute digest" → Suggests checking file readability and corruption
  • "Failed to extract metadata" → Explains NWB specification requirements
  • "No URLs provided" → Shows example usage

See commits:

  • 470467b - Enhance dandiset metadata error messages
  • 3922285 - Enhance API client error messages
  • 7c1788e - Enhance path validation error messages
  • fb9ea70 - Enhance upload/download operation error messages

3. Code Quality Improvements (Commit: 928ad98)

Type annotation cleanup:

  • Fixed incorrect use of reduce() in upload sync path calculation
  • Replaced with direct os.path.commonprefix() call (which already accepts a list)
  • Removed unnecessary type: ignore comment
  • Improved code clarity

See commit:

  • 928ad98c - Fix type annotation in upload sync path prefix calculation

Testing

All changes verified with full test suite:

  • 548 tests passed (100% success rate on executed tests)
  • 277 tests skipped (require Docker - expected)
  • 1 xfailed, 8 xpassed (expected)
  • No regressions introduced

Each improvement category was tested independently before committing.

Additional Analysis Performed

As part of LAD framework analysis, the following were investigated but not changed:

Windows path handling (utils.py TODOs):

  • Investigated is_interactive() hasattr checks - current implementation works correctly on Windows
  • Investigated path separator uniformization - optimization, not critical
  • Both TODOs are "nice to have" rather than bugs

Type annotations:

  • Reviewed all 41 type: ignore comments in codebase
  • Most are legitimate (Pydantic model_construct, mypy bugs, test ANY usage)
  • Only actionable issue was the upload.py reduce/commonprefix fix (completed)

Large function refactoring:

  • Identified organize.py:act() (248 lines) and files/bases.py:iter_upload() as candidates
  • Deferred as lower priority (estimated 4-8 hours, high risk)
  • Can be addressed in future PR if needed

Commit-by-Commit Details

For detailed information about each change, please review individual commits:

  1. Documentation reorganization and file placement guidelines
  2. Core API module docstrings
  3. Operation module docstrings
  4. Validation module docstrings
  5. Dandiset metadata error message improvements
  6. API client error message improvements
  7. Path validation error message improvements
  8. Upload/download error message improvements
  9. Type annotation cleanup

Each commit includes detailed descriptions and co-author attribution.

Files Changed

19 files changed: +692 insertions, -26 deletions

  • Documentation: CLAUDE.md, DEVELOPMENT.md, .gitignore, docs/source/development/ (new files)
  • Core modules: dandiapi.py, dandiset.py, exceptions.py, consts.py
  • Operations: upload.py, download.py, delete.py, move.py, organize.py, validate.py
  • Utilities: pynwb_utils.py
  • Tests: test_move.py (updated assertions to match improved error messages)

Note: This PR also includes LAD (LLM-Assisted Development) framework files in .lad/ directory which add comprehensive test quality analysis workflows. These are development tools and do not affect runtime code.

Related Issues

This work was motivated by achieving 100% meaningful test success and improving the developer experience. While no specific issues are directly closed, these improvements address common user friction points when errors occur.

yarikoptic and others added 11 commits January 29, 2026 18:59
git-subtree-dir: .lad
git-subtree-split: d765702eb44e88c33d93261ccb89139ca31cf5d1
- Add comprehensive testing guide to Sphinx docs (docs/source/development/testing.rst)
- Add contributing guide to Sphinx docs (docs/source/development/contributing.rst)
- Update CLAUDE.md with file placement guidelines to prevent root clutter
- Update DEVELOPMENT.md to reference new Sphinx documentation
- Add .lad/tmp/ to .gitignore for LAD session artifacts
- Integrate development docs into main Sphinx documentation index

This improves documentation organization and prevents temporary files
from cluttering the project root. LAD-generated analysis files now go
to .lad/tmp/, while permanent documentation goes to docs/source/.

Testing documentation now properly integrated with Sphinx for better
searchability and navigation.
- dandiapi.py: Document REST API client classes and main functionality
- exceptions.py: Document custom exception hierarchy
- consts.py: Document constants, metadata fields, and configuration
- download.py: Document download functionality and features
- upload.py: Document upload workflow and validation
- delete.py: Document deletion operations
- move.py: Document move/rename functionality
- organize.py: Document file organization and naming
- validate.py: Document validation functionality
- pynwb_utils.py: Document NWB file handling utilities
Improve error messages in dandiset.py to provide actionable guidance:
- Add hint about using 'dandi download' when dandiset.yaml is missing
- Explain that metadata file may be empty or corrupted
- Clarify required 'identifier' field in metadata structure

These improvements help users quickly diagnose and fix common metadata issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Improve error messages in dandiapi.py to provide clearer guidance:
- Explain mutually exclusive api_url/dandi_instance parameters
- Add hint to verify Dandiset ID and check permissions
- Reference 'dandi ls' command for listing assets
- Include version context in "No asset at path" errors

These improvements help users quickly troubleshoot API access issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Improve error messages in move.py to provide clearer guidance:
- Explain why paths cannot navigate above Dandiset root
- Add hints for file vs directory path requirements
- Clarify "Cannot move current working directory" restriction
- Reference 'dandi ls' command for checking remote paths
- Explain dandiset.yaml requirement with actionable hints

Update test assertions to match improved error messages.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Improve error messages in upload.py and download.py to provide clearer guidance:
- Add file path context to "File not found" errors
- Reference 'dandi validate' command for validation failures
- Suggest checking file format and corruption for digest errors
- Explain NWB specification requirements for metadata extraction
- Provide example usage for download command when no URLs given

These improvements help users quickly diagnose and fix upload/download issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace incorrect use of reduce() with direct os.path.commonprefix() call.
The original code used reduce() incorrectly - os.path.commonprefix() already
accepts a list of paths and returns the longest common prefix.

This removes one type: ignore comment and improves code clarity.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 13.63636% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.43%. Comparing base (ccdb659) to head (928ad98).

Files with missing lines Patch % Lines
dandi/move.py 22.22% 7 Missing ⚠️
dandi/upload.py 0.00% 5 Missing ⚠️
dandi/dandiapi.py 0.00% 4 Missing ⚠️
dandi/dandiset.py 0.00% 2 Missing ⚠️
dandi/download.py 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ccdb659) and HEAD (928ad98). Click for more details.

HEAD has 288 uploads less than BASE
Flag BASE (ccdb659) HEAD (928ad98)
unittests 300 12
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1781       +/-   ##
===========================================
- Coverage   75.11%   50.43%   -24.68%     
===========================================
  Files          84       84               
  Lines       11921    11920        -1     
===========================================
- Hits         8954     6012     -2942     
- Misses       2967     5908     +2941     
Flag Coverage Δ
unittests 50.43% <13.63%> (-24.68%) ⬇️

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.

@yarikoptic yarikoptic added the patch Increment the patch version when merged label Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants