Skip to content

[dev] C7 - Configs refactor: finalize and simplify infrastructure #3354

Draft
deruyter92 wants to merge 4 commits into
feat/structured_configsfrom
jaap/C7_config_cleanup_simplify
Draft

[dev] C7 - Configs refactor: finalize and simplify infrastructure #3354
deruyter92 wants to merge 4 commits into
feat/structured_configsfrom
jaap/C7_config_cleanup_simplify

Conversation

@deruyter92
Copy link
Copy Markdown
Collaborator

@deruyter92 deruyter92 commented Jun 1, 2026

This PR is part of the WIP (see #3198) for migrating from dictionary configs to typed & validated configurations (overview is tracked in #3193).

This PR finalizes, cleans and simplifies the infrastructure for structured configs before moving migrating to the structured config (schema V1).

Changes:

  • base_config: settle for Pydantic BaseModel instead of several mixins and Pydantic dataclass.
  • Expand the test coverage
  • Make migration system class-aware (instead of single migration logic for both PoseConfig and ProjectConfig)
  • Remove legacy references to OmegaConfig

@deruyter92 deruyter92 requested a review from C-Achard June 1, 2026 13:49
@deruyter92
Copy link
Copy Markdown
Collaborator Author

@C-Achard, would be very helpful if you could give an intermediate review on the deeplabcut.core.config module and corresponding tests. (diff with main, there are some intermediate states that are irrelevant). Thanks a lot!!

Copy link
Copy Markdown
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.

@deruyter92 Here are some first comments, mostly focusing on usability/possible refactor artifacts.

Note that I only reviewed the diff of C7 to the feature branch; happy to review the full version once this is finalized.

Comment on lines +133 to +138
def print(
self,
indent: int = 0,
print_fn: Callable[[str], None] | None = None,
) -> None:
pretty_print(config=self.to_dict(), indent=indent, print_fn=print_fn)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would a __repr__ be useful ?

)
return self

def to_dict(self) -> dict:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs the normalize keyword, right? Since super().to_yaml calls dict_data = self.to_dict(normalize=True)

Comment on lines 26 to 33
@@ -35,8 +33,7 @@ class DataLoaderConfig(ConfigMixin):
type: str
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this needed? I don't think this is used anywhere now

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

_post_yaml_load_updates calls the parent class function, but the parent just passes. Is this intended?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it some sort of future proofing? What would be potential use cases if yes?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

        if project_path.resolve() != self.project_path.resolve():

resolve() or absolute() here?

return resolved


def normalize_for_serialization(obj: Any) -> Any:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this need to handle list/tuples/set recursively?

},
)

# Annotation data set configuration (and individual video cropping parameters)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Annotation data set configuration (and individual video cropping parameters)
# Annotation dataset configuration, individual video cropping parameters

multianimalbodyparts: list[str] = field(default_factory=list) # multi-animal project key
unique_bodyparts: list[str] = field(default_factory=list) # metadata key; same as uniquebodyparts
individuals: list[str] = Field(default_factory=lambda: ["individual_1"])
uniquebodyparts: list[str] = Field(default_factory=list) # multi-animal project key
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This appears several times, I assume the one with aliases defs should stay?

Comment on lines 123 to 127
@@ -126,9 +127,9 @@ class ProjectConfig(ChangeTrackingMixin, MigrationMixin, ConfigMixin):
colormap: str = "rainbow"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What would be the plan for validation/documenting valid values? This will come at a later time, right? (Apologies if we discussed that point already)

json_schema_extra={"comment": "Alias for 'uniquebodyparts'. Kept for backwards compatibility."},
)

# TODO @deruyter92 2026-02-06: These parameters are no longer used in the new pipeline.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we comment them out then? If it's really dead code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Most model config is in the pytorch backend, but this is "core" config. Is this desirable, or would it be good to move?

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.

2 participants