[dev] C2 - Add typed configs as pydantic dataclasses & omegaconf dictconfigs#3191
Merged
deruyter92 merged 9 commits intofeat/structured_configsfrom Feb 4, 2026
Merged
Conversation
59b4623 to
5c950a5
Compare
17 tasks
5c950a5 to
d58be73
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces typed, validated configuration classes using Pydantic and OmegaConf to replace dictionary-based configurations. The changes establish a foundation for better type safety and validation while maintaining backward compatibility with existing dictionary structures.
Changes:
- Adds
ConfigMixinbase class providing common config operations (load, save, validate, convert) - Implements typed config classes for project, data, model, training, runner, inference, and logger configurations
- Migrates
WeightInitializationandGenSamplingConfigto use Pydantic dataclasses - Adds
omegaconf>=2.3.0andpydantic>=2.12.3as dependencies
Reviewed changes
Copilot reviewed 21 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/core/config/test_config_mixin.py | Comprehensive test coverage for ConfigMixin functionality |
| setup.py | Adds omegaconf and pydantic dependencies |
| deeplabcut/pose_estimation_pytorch/runners/inference.py | Removes InferenceConfig classes (moved to config module) |
| deeplabcut/pose_estimation_pytorch/data/generative_sampling.py | Removes GenSamplingConfig (moved to config/data.py) |
| deeplabcut/pose_estimation_pytorch/data/dataset.py | Updates import for GenSamplingConfig |
| deeplabcut/pose_estimation_pytorch/data/base.py | Updates import for GenSamplingConfig |
| deeplabcut/pose_estimation_pytorch/data/init.py | Updates import for GenSamplingConfig |
| deeplabcut/pose_estimation_pytorch/config/training.py | Adds TrainSettingsConfig dataclass |
| deeplabcut/pose_estimation_pytorch/config/runner.py | Adds OptimizerConfig, SchedulerConfig, SnapshotCheckpointConfig, and RunnerConfig |
| deeplabcut/pose_estimation_pytorch/config/project.py | Adds typed ProjectConfig matching old dictionary structure |
| deeplabcut/pose_estimation_pytorch/config/pose.py | Adds main PoseConfig with enums for method and network types |
| deeplabcut/pose_estimation_pytorch/config/model.py | Adds ModelConfig and DetectorModelConfig |
| deeplabcut/pose_estimation_pytorch/config/logger.py | Adds LoggerConfig classes for WandB and CSV loggers |
| deeplabcut/pose_estimation_pytorch/config/inference.py | Adds typed inference config classes |
| deeplabcut/pose_estimation_pytorch/config/data.py | Adds data config classes including GenSamplingConfig |
| deeplabcut/pose_estimation_pytorch/init.py | Updates import for GenSamplingConfig |
| deeplabcut/core/weight_init.py | Converts WeightInitialization to Pydantic dataclass with ConfigMixin |
| deeplabcut/core/types.py | Adds PydanticNDArray type alias for numpy array support |
| deeplabcut/core/config/project_config.py | Adds core ProjectConfig (duplicate of pose_estimation_pytorch version) |
| deeplabcut/core/config/config_mixin.py | Implements ConfigMixin base class |
| deeplabcut/core/config/init.py | Exports config utilities and classes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e290a0c to
8b5d13f
Compare
C-Achard
reviewed
Feb 3, 2026
C-Achard
reviewed
Feb 3, 2026
C-Achard
approved these changes
Feb 3, 2026
Base automatically changed from
jaap/centralize_project_configs
to
feat/structured_configs
February 4, 2026 08:40
This mixin provides methods for:
- Loading configurations from dictionaries or YAML files
- Validating configuration data against pydantic models
- Converting configurations to dictionaries
- Pretty printing configuration data
add imports from utils
- Introduced new configuration classes for inference, logging, model, pose, project, runner, and training settings. - Refactored data loading mechanisms to utilize new configuration structures. - Moved the multithreading and compilation options in inference configuration to the config module. - Typed configuration for logging. - Updated dataset loaders to accept model configurations directly or via file paths.
(The fields are kept identical to old multianimal project configs for now) move ProjectConfig to deeplabcut/core/config
…correct TypeAdapter usage)
The return value should be the dictionary, not the instantiated transforms
e00941b to
120aedc
Compare
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.
This PR is part of the WIP for migrating from dictionary configs to typed & validated configurations (see #3193 for an overview). (Credits to @arashsm79 for originally introducing these changes).
Motivation
Introduces typed, validated config classes (Pydantic + OmegaConf) and a shared
ConfigMixinfor project and pose configs. Replaces ad-hoc dicts with a consistent load/save/validation API and better type support.Changes:
ConfigMixin,ProjectConfig, and utils (moved fromcore/config.py). Newcore/types.pywithPydanticNDArray.WeightInitializationis a Pydantic dataclass usingConfigMixin;snapshot_pathoptional;conversion_arraytyped asPydanticNDArray.pose_estimation_pytorch/config/(data, inference, logger, model, pose, project, runner, training).GenSamplingConfigmoved fromdata/generative_sampling.pytoconfig/data.py. Inference config classes moved fromrunners/inference.pytoconfig/inference.py; inference runner usesInferenceConfig.from_any().omegaconf>=2.3.0,pydantic>=2.12.3.tests/core/config/test_config_mixin.pyforConfigMixin.Notes: