Skip to content

Replace str, os.path with pathlib.Path#3199

Merged
deruyter92 merged 3 commits intoDeepLabCut:mainfrom
deruyter92:juan-cobos/replace_str_with_pathlib
Feb 13, 2026
Merged

Replace str, os.path with pathlib.Path#3199
deruyter92 merged 3 commits intoDeepLabCut:mainfrom
deruyter92:juan-cobos/replace_str_with_pathlib

Conversation

@deruyter92
Copy link
Collaborator

@deruyter92 deruyter92 commented Feb 4, 2026

Replacement PR for #3170

Motivation (as phrased by @juan-cobos in the original PR):
Path handling is currently inconsistent (strings vs Path objects, mixed os.path and pathlib), making code hard to follow. This also causes subtle bugs (e.g., scorer.replace() on a Path attempts filesystem operations instead of string replacement). Standardizing on pathlib.Path would help to make older code consistent with newer parts of the codebase.

Changes:
Standardize on pathlib.Path internally with proper type hints in the following files:

  • deeplabcut/utils/make_labeled_video.py
  • deeplabcut/modelzoo/utils.py
  • deeplabcut/pose_estimation_pytorch/modelzoo/inference.py
  • deeplabcut/utils/auxiliaryfunctions.py

juan-cobos and others added 2 commits February 4, 2026 13:58
This commit contains squashed changes by juan-cobos
- Began to refactor pathlib for os
- Fixed filename replacement with Path
- Remove output_path, stick to dest_folder for compatibility
- refactored find_analyzed_data from auxiliaryfunctions

- removed accidental import
- match previous msg improving readibility
- Fixed underscore name
- remove comments and make scorer str for safety
- fixed paths when weights are provided
- address copilot and deruyter changes
- remove scorer str conversion
- find_analyzed_data using .glob
- fixed Path + str when using tmpfolder
- return True if videooutname already created, same as above logic
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Collaborator

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

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

Looks good ! Thanks

@deruyter92 deruyter92 merged commit d109faa into DeepLabCut:main Feb 13, 2026
9 of 10 checks passed
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.

3 participants