Skip to content

Update None-type validation for legacy ProjectConfig templates Remove ignore_empty - #3439

Open
deruyter92 wants to merge 4 commits into
DeepLabCut:mainfrom
deruyter92:jaap/project-config-null-normalization
Open

Update None-type validation for legacy ProjectConfig templates Remove ignore_empty#3439
deruyter92 wants to merge 4 commits into
DeepLabCut:mainfrom
deruyter92:jaap/project-config-null-normalization

Conversation

@deruyter92

@deruyter92 deruyter92 commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Motivation:
Currently, template project configurations may contain placeholder fields with empty values. Even when the schema does not allow None-type.

e.g.

# examples/openfield-Pranav-2018-10-30/config.yaml
Task: openfield
...
multianimalproject:      # <- empty empty but should be boolean
identity:                # <- empty but should be boolean

To make the validation flexible, ProjectConfig.from_yaml(..., ignore_empty=True) always dropped None-type values, treating empty yaml fields as unset. However, this caused two issues:

  • It only works for from_yaml but not for from_dict, yielding different validation behavior between ProjectConfig.from_dict(read_config_as_dict("config.yaml") (strict) and ProjectConfig.from_yaml("config.yaml") (None-type allowed)
  • It always drops None-types when ignore_empty is True, treating it as unset. Which is conceptually an unclear policy.

The current PR changes this by removing the ignore_empty parameter and adding instead a ProjectConfig validator that treats top-level None-types as unset, emitting an actionable warning.

Changes

  • Update DLCBaseConfig.from_yaml(): remove the ignore_empty parameter (⚠️ this is API breaking for 3.0.1, but I doubt that anyone is using this parameter already)
  • Update core.config.utils.read_config(): deprecate ignore_empty parameter
  • Add top-level None-type validation in existing validator ProjectConfig.normalize_legacy_empty_values()
  • Add tests for ProjectConfig.normalize_legacy_empty_values() and core.config.utils.read_config()

Extend ProjectConfig.normalize_legacy_empty_vales to treat a bare/null YAML value as unset for fields whose type doesn't accept None
(e.g. multianimalproject). This is required to universally support legacy config templates with unset fields.
Mark the parameter as deprecated in utils.read_config. This parameter was only needed for supporting empty values in legacy project configs. Instead, currently a more strict policy is enforced: null/empty is loaded as None, and fails validation if not supported.

since f7305aa None-type support specifically for ProjectConfigs is tolerated using an after validator, which makes the current `ignore_empty` parameter obsolete
@deruyter92 deruyter92 changed the title Update None-type validation for legacy ProjectConfig templates Remove ignore_empty Update None-type validation for legacy ProjectConfig templates Remove ignore_empty Aug 9, 2026
@deruyter92
deruyter92 requested a lite review from Copilot August 9, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the legacy ignore_empty option from DLCBaseConfig.from_yaml() and shifts legacy “bare/null YAML key” handling into ProjectConfig validation so that from_dict() and from_yaml() behave consistently when configs contain placeholder null values.

Changes:

  • Removed ignore_empty from DLCBaseConfig.from_yaml() and updated read_config() to deprecate (and ignore) ignore_empty.
  • Added/extended ProjectConfig.normalize_legacy_empty_values() to treat top-level None values as “unset” only for non-optional fields, emitting a warning.
  • Added tests covering legacy null/empty handling for both ProjectConfig entrypoints and read_config().

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
deeplabcut/core/config/base_config.py Removes ignore_empty handling from base YAML loader to unify behavior.
deeplabcut/core/config/project_config.py Adds validator logic to normalize legacy None placeholders and warn.
deeplabcut/core/config/utils.py Deprecates ignore_empty parameter in read_config() and routes to ProjectConfig.from_yaml() without it.
tests/core/config/test_project_config.py Adds unit tests for normalization of legacy empty/null values and parity between from_dict()/from_yaml().
tests/core/config/test_core_config.py Adds tests for read_config() behavior with null placeholders and deprecation warning behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread deeplabcut/core/config/project_config.py
Comment thread deeplabcut/core/config/utils.py
Comment thread deeplabcut/core/config/utils.py
@deruyter92
deruyter92 marked this pull request as ready for review August 9, 2026 13:35
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