[dev] Refactor config constructors via build() methods - #3369
Merged
deruyter92 merged 26 commits intoJun 18, 2026
Conversation
- Split enums into separate file - Split PoseMetadata into separate file - Split PafParamters into separate file - Add canonical build methods for structured configs: e.g. build from project config
- build entire default dict for net_type from the yaml file, before validation. - deprecate `make_pytorch_test_config`, `make_pytorch_pose_config` and `make_basic_project_config`.
C-Achard
reviewed
Jun 15, 2026
C-Achard
left a comment
Collaborator
There was a problem hiding this comment.
Added some initial comments
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors PyTorch pose config construction into canonical build()/build_for_*() classmethods on the structured config models, aiming to ensure configs are fully-initialized/validated at construction time and to deprecate older factory/helper functions.
Changes:
- Introduces
PoseConfig.build(...),PoseConfig.build_for_superanimal_inference(...), andPoseConfig.build_for_superanimal_finetune(...)as canonical constructors. - Extracts config components into dedicated models/utilities (
PoseMetadata,PAFParameters, andconfig.enums) and updates config-building utilities accordingly. - Deprecates legacy config factory functions and adapts modelzoo/config writing paths to the new constructors.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| deeplabcut/pose_estimation_pytorch/modelzoo/utils.py | Deprecates load_super_animal_config and adjusts SuperAnimal config updating behavior. |
| deeplabcut/pose_estimation_pytorch/modelzoo/config.py | Adds SuperAnimal metadata/inference/finetune config builders and updates YAML writing. |
| deeplabcut/pose_estimation_pytorch/config/pose.py | Adds PoseConfig.build*() constructors and moves toward canonical build flow. |
| deeplabcut/pose_estimation_pytorch/config/paf_parameters.py | Introduces a typed PAF parameter model and builder. |
| deeplabcut/pose_estimation_pytorch/config/metadata.py | Introduces a typed Pose metadata model and builders (including SuperAnimal). |
| deeplabcut/pose_estimation_pytorch/config/make_pose_config.py | Deprecates legacy factory functions and refactors default-building helpers for structured config construction. |
| deeplabcut/pose_estimation_pytorch/config/enums.py | Extracts shared enums into a dedicated module. |
| deeplabcut/pose_estimation_pytorch/config/init.py | Re-exports enums/models and updates public API surface for deprecated factories. |
| deeplabcut/create_project/modelzoo.py | Updates modelzoo project creation to use new metadata/config construction. |
| deeplabcut/core/config/project_config.py | Adds ProjectConfig.bodyparts_list helper for animal-count-agnostic bodypart access. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nimal_inference()
…td shuffle. The documented primary workflow is: set conditions at shuffle / dataset creation, not defer until inference. This was not reflected in the test, and surfaced with the new structured configs. This commit makes the test in line with recommended workflow in API docstring; Config docs; BUCTD COLAB notebook; and GUI. -> ctd_conditions are passed at dataset creation time. making the shuffle a fully complete artefact, rather than somthing that requires patching in later API calls.
…ng training dataset
… instead of RunnerConfig
Collaborator
Author
|
merging into #3354 and rebasing everything on main (facilitates easier review as well) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The construction of configs used to be a bit of a spaghetti of loading yamls, adjusting fields midway, and then updating them once more in the API calls, such as train_network.
The structured configs refactor improved this a bit, but there was a mixed state with validation halfway construction, requiring the need for nullable fields and moving a lot back and forth between dicts and types.
This PR aims to move construction of configs for a specific deeplabcut project or deeplabcut net type to a canonical
build()method on the structured configs themselves.The construction is now always split in two steps. E.g. for PoseConfig:
net_type, derived from ProjectConfig + build args)API calls can still update the PoseConfig with overrides (e.g.
train_network), but these overrides are never required: the validated PoseConfig is always considered a fully initialized model that can be used downstream.