Skip to content

Add max path-length warning on Windows - #46

Open
C-Achard wants to merge 2 commits into
mainfrom
cy/config-windows-path-length
Open

C-Achard wants to merge 2 commits into
mainfrom
cy/config-windows-path-length

Conversation

@C-Achard

@C-Achard C-Achard commented Dec 4, 2026

Copy link
Copy Markdown
Member

On Windows without long paths enabled, files DeepLabCut writes deep inside a project can exceed the 260-character MAX_PATH and fail with a bare FileNotFoundError (e.g. savemat in create_training_dataset, at 277 characters).

ProjectConfig now logs a warning, once per project, when len(project_path) + 2 * len(Task) + 120 reaches 260. The estimate is a heuristic based on the evaluation results path.
The message suggests toggling LongPathsEnabled, moving the project closer to the drive root, or shortening Task.

Longer network or video names can still exceed the limit without a warning. It is meant as an estimate rather than a catch-all check.

  • Runs only on Windows with LongPathsEnabled unset; the registry is read once per session (windows_max_path_applies in validation.py).
  • Skipped when project_path is not an existing directory, so a moved project's stale path does not warn. The repaired path is checked when _post_yaml_load_updates assigns it (validate_assignment reruns the validator).

@C-Achard C-Achard added enhancement New feature or request io: config config.yaml reading, writing and its schema consumer: deeplabcut Needed by or affects DeepLabCut labels Dec 4, 2026
@C-Achard
C-Achard requested a review from deruyter92 December 4, 2026 09:11
@C-Achard C-Achard added this to the Config migration milestone Dec 4, 2026
@C-Achard C-Achard self-assigned this Dec 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Windows-specific long-path detection lacks mocked-registry tests for enabled/disabled values, missing or inaccessible entries, and once-per-session caching.

1 open issue
What changed in this PR

Adds an early warning for DeepLabCut projects whose generated file paths may exceed Windows’ path-length limit.

Changes:

  • Caches detection of the Windows long-path registry setting.
  • Warns once per project using a path-length estimate, skipping nonexistent project directories.
  • Tests warning behavior, deduplication, and repaired project paths.
File Description
tests/​config/​test_project_config.py Adds path-length warning tests.
dlccore/​config/​validation.py Adds cached Windows path-limit detection.
dlccore/​config/​project_config.py Adds heuristic warnings with mitigation guidance.

Review effort: Balanced

Comment on lines +37 to +41
try:
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\FileSystem") as key:
enabled, _ = winreg.QueryValueEx(key, "LongPathsEnabled")
except OSError:
return True

This branch has not been deployed

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

Labels

consumer: deeplabcut Needed by or affects DeepLabCut enhancement New feature or request io: config config.yaml reading, writing and its schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants