Skip to content

fix ruamel.yaml dumping newline for long filenames#3140

Merged
MMathisLab merged 4 commits intoDeepLabCut:mainfrom
deruyter92:jaap/fix_yaml_dump_newline
Feb 10, 2026
Merged

fix ruamel.yaml dumping newline for long filenames#3140
MMathisLab merged 4 commits intoDeepLabCut:mainfrom
deruyter92:jaap/fix_yaml_dump_newline

Conversation

@deruyter92
Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 commented Nov 7, 2025

Motivation
This PR fixes an issue with external package ruamel.yaml, causing corrupted yaml files when creating a project with long video paths containing spaces. (Fixes #3119)

Changes

  • The issue is patched by increasing the width parameter before dumping, preventing long sequences to be moved to a new line, as suggested by the author here.
  • Some unit tests are added for writing config files with various (unorthodox) video paths, to make sure that video configurations are loaded as intended.
  • An additional issue is fixed in deeplabcut.create_project.new: The create_project function unintendedly treated empty video directories as a video file, for which a symbolic link is created. This behavior is now fixed

@AlexEMG AlexEMG self-requested a review November 7, 2025 15:31
@deruyter92
Copy link
Copy Markdown
Collaborator Author

Also added a minor change to deeplabcut.create_project.new, to make sure that only video files and no directories are added to the final list of videos. (The create_project function unintendedly treated empty video directories as a video file, for which a symbolic link is created. This behavior is now fixed).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the ruamel.yaml library that causes corrupted YAML files when creating projects with long video paths containing spaces. The fix increases the width parameter before dumping to prevent long sequences from being moved to new lines.

Changes:

  • Added ruamelFile.width = 1_000_000 before YAML dumping to prevent line breaks in long video paths
  • Refactored video collection logic in create_new_project to use Path objects consistently
  • Added comprehensive unit tests for video configuration scenarios including long paths, spaces, and various edge cases

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/test_auxiliaryfunctions.py Added blank line for formatting
tests/create_project/test_video_set_configuration.py New test file with 253 lines covering various video path scenarios and edge cases
deeplabcut/utils/auxiliaryfunctions.py Added width parameter fix for ruamel.yaml to prevent newline insertion in long strings
deeplabcut/create_project/new.py Refactored video collection to use Path objects consistently

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deruyter92 deruyter92 requested a review from MMathisLab January 15, 2026 16:33
@C-Achard
Copy link
Copy Markdown
Collaborator

Shouldn't we have any coverage info in the thread from the CI tests @deruyter92 ? Is this something we need to setup ?

@C-Achard C-Achard added Another package code issue Bug/issue that relates to a dlc dependency bug fix! fix for a real buggy one... labels Jan 16, 2026
deruyter92 and others added 3 commits January 26, 2026 11:41
…paths

ruamel.yaml was inserting unintended newlines when dumping paths, leading to corrupted YAML files for long video paths containing spaces.

Fixes DeepLabCut#3119

Co-authored-by: Copilot <[email protected]>
- also add unit tests for video set configuration (and move to separate file).
- add typehints, remove unused packages
When providing an empty video directory to `create_new_project`, the empty directory was mistakenly treated as video file for which a symbolic link is created. The current commit fixes this unintended behaviour.
@deruyter92 deruyter92 force-pushed the jaap/fix_yaml_dump_newline branch from 8949be8 to 654abf9 Compare January 26, 2026 10:43
@deruyter92
Copy link
Copy Markdown
Collaborator Author

Shouldn't we have any coverage info in the thread from the CI tests @deruyter92 ? Is this something we need to setup ?

Yes good point. Let's address that in a separate PR.

@deruyter92
Copy link
Copy Markdown
Collaborator Author

@MMathisLab @AlexEMG, I think we should merge this PR. Let me know what you think.

@MMathisLab MMathisLab merged commit 2a3e5cd into DeepLabCut:main Feb 10, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Another package code issue Bug/issue that relates to a dlc dependency bug fix! fix for a real buggy one...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrectly formatted yaml file for long file name

4 participants