Visitar URL original
fix WandbLoggerConfig include additional kwargs in pydantic schema by deruyter92 · Pull Request #3469 · DeepLabCut/DeepLabCut · GitHub
Skip to content

fix WandbLoggerConfig include additional kwargs in pydantic schema - #3469

Merged
deruyter92 merged 11 commits into
devfrom
jaap/fix-wandb-logger-config
Sep 8, 2026
Merged

deruyter92 merged 11 commits into
devfrom
jaap/fix-wandb-logger-config

Conversation

@deruyter92

@deruyter92 deruyter92 commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

The Weights and Biases logger accepts a variety of extra arguments, such as notes, tags, etc. These were mediated through wandb_kwargs which could be defined at top-level. However since the introduction of the stricter pydantic schemas these top-level arguments with extra="forbid" would raise a ValidationError.

This PR:

  • fixes a dead wandb_kwargs field in the WandBloggerConfig (was never passed correctly to the logger)
  • adds common top-level fields such as notes, tags, group to the top-level config.

Edit:
To avoid breaking the current config schema I refrained from adding common WandB args like notes, tags, group as top-level fields. Since they may appear in older unversioned config yamls, I've added a before validator that scoops them into the wandb_kwargs field. I've also added testing, so that the following YAML forms are accounted for:

# Allow both top-level and nested args (even combined, when no conflicts):
logger:
  project_name: "deeplabcut"
  ...
  tags: ["mytag"]  # <-  top-level (will be moved into wandb_kwargs by the validator)
  wandb_kwargs:
     group: "mygroup"  # <- nested


# Don't allow configs like this:
logger:
  project_name: "deeplabcut"
  ...
  project: "myproject"  # <- Reserved fields are not allowed (already defined via "project name", "run_name")
  group: "mygroup"
  wandb_kwargs: 
      group: "repeated"   # <- Duplicate top-level and nested fields are not allowed.

@deruyter92 deruyter92 added this to the v3.1.0 milestone Aug 28, 2026
@deruyter92 deruyter92 added the 3.1 label Aug 28, 2026
@deruyter92
deruyter92 changed the base branch from main to dev August 31, 2026 09:41
@deruyter92
deruyter92 requested a lite review from Copilot September 1, 2026 07:11

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 updates the PyTorch pose-estimation W&B logger configuration and initialization flow so that commonly used wandb.init parameters (e.g., notes, tags, group) can be specified at the top level without failing strict Pydantic validation, and ensures nested wandb_kwargs are actually forwarded to wandb.init.

Changes:

  • Extend WandbLoggerConfig’s Pydantic schema with common wandb.init parameters (entity, notes, tags, group, job_type) and clarify how wandb_kwargs should be used.
  • Flatten a nested wandb_kwargs mapping inside WandbLogger.__init__ before calling wandb.init.

Reviewed changes

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

File Description
deeplabcut/pose_estimation_pytorch/runners/logger.py Flattens nested wandb_kwargs before calling wandb.init; updates docstring.
deeplabcut/pose_estimation_pytorch/config/logger.py Adds common W&B init fields to the Pydantic config schema and clarifies wandb_kwargs intent.
Suppressed comments (1)

deeplabcut/pose_estimation_pytorch/runners/logger.py:297

  • The new behavior that flattens nested wandb_kwargs (and the precedence between nested vs. explicit kwargs) is not covered by tests. Adding a unit test that mocks wandb.init and asserts the final kwargs passed would prevent regressions.
        wandb_kwargs.update(wandb_kwargs.pop("wandb_kwargs", None) or {})

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

deruyter92 and others added 5 commits September 3, 2026 18:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
introducing them here would break the schema (leading to internally inconsistent versions)
…options

It scoops the options into wandb_kwargs. Options cannot be duplicated.
@deruyter92
deruyter92 requested a lite review from Copilot September 3, 2026 18:47
@deruyter92
deruyter92 marked this pull request as ready for review September 3, 2026 18:47

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.

🟡 Changes recommended

There are small but user-visible issues (notably an unformatted ValidationError message and a minor typo) that should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

@deruyter92
deruyter92 requested a review from C-Achard September 4, 2026 07:57

@C-Achard C-Achard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few things worth checking, all good otherwise

deruyter92 and others added 4 commits September 4, 2026 13:55
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Cyril Achard <cyril.achard@epfl.ch>
@deruyter92

Copy link
Copy Markdown
Collaborator Author

@C-Achard, addressed your comments. Let me know if I missed anything. Thanks for the follow-up PR as well. Let's merge it separately

@C-Achard

C-Achard commented Sep 4, 2026

Copy link
Copy Markdown
Member

Sounds good, thanks!

@deruyter92
deruyter92 merged commit 3e8ce1a into dev Sep 8, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants