[WIP] Final migration to configuration version 1: structured and validated configs by deruyter92 · Pull Request #3198 · DeepLabCut/DeepLabCut

@deruyter92

@deruyter92

@deruyter92

…onverter_config.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@deruyter92

- reading breaks for corrupted yaml
- added tests for prefered behavior that is currently not implemented (yaml safeloading and validating config keys)

@deruyter92

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

@deruyter92

- 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.

@deruyter92

(The fields are kept identical to old multianimal project configs for now)

move ProjectConfig to deeplabcut/core/config

@deruyter92

…correct TypeAdapter usage)
The return value should be the dictionary, not the instantiated transforms

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

…fig/dict/None-type handling.

C3-II Additional refactoring of configurations 
Part 3-II of migration to typed configs, see issue #3193

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

…ith validate_assignment=True)

This is necessary to prevent a bug:
The isinstance(data, cls): return data shortcut in MigrationMixin.migrate_then_validate (a model_validator(mode="wrap")). Pydantic re-enters this validator during validate_assignment, passing the current instance as data. The shortcut returned it unchanged, silently discarding every field update. This broke all assignment — not just validation, but even plain cfg.count = 42 was a no-op.

The problem is that model_validator(mode="wrap") wraps the entire validation pipeline, including validate_assignment flow. Migration should only run during construction, not on every field assignment.
The clean solution is to switch from mode="wrap" to mode="before" — it transforms raw input data before validation and doesn't participate in validate_assignment at all.

@deruyter92

Part 4 of migration to typed configs, see issue #3193

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

@deruyter92

Part 5 of migration to typed configs, see issue [#3193](#3193)

Removes the intermediary DictConfig format and works with fully typed configuration dataclasses instead (which have dict access funcitonality).

@deruyter92