Save WandB run information to model folder#3017
Merged
Conversation
Avoid crashes when an invalid argument is passed to a registered constructor
Member
|
hi @maximpavliv shall we add this to the docs? |
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a mechanism to persist WandB run identifiers to disk and tightens argument filtering when instantiating registered objects. Key changes:
- WandbLogger now requires a
train_folder, writes run info towandb_info.yaml, and prints a confirmation. - Registry’s
build_from_cfgfilters extra constructor kwargs based on the function signature. - Training entrypoint passes
train_folderfrom the data loader into the logger config.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| deeplabcut/pose_estimation_pytorch/runners/logger.py | Imported yaml; added _save_wandb_info() and updated CSVLogger to accept str paths |
| deeplabcut/pose_estimation_pytorch/registry.py | Enhanced build_from_cfg to drop unexpected kwargs before calling constructors |
| deeplabcut/pose_estimation_pytorch/apis/training.py | Modified LOGGER.build invocation to inject train_folder from loader.model_folder |
Comments suppressed due to low confidence (2)
deeplabcut/pose_estimation_pytorch/runners/logger.py:399
- The constructor only accepts
strfortrain_folderbut immediately converts toPath; consider annotating asstr | Pathto reflect the accepted types and improve clarity.
def __init__(self, train_folder: str, log_filename: str) -> None:
deeplabcut/pose_estimation_pytorch/apis/training.py:102
- The variable
loaderisn’t defined in this scope, which will raise a NameError. You should reference the actual training loader variable (e.g.,train_loader.model_folder) or pass the folder path directly intotrain.
{**logger_config, "model": model, "train_folder": loader.model_folder}
| with open(output_path, "w") as f: | ||
| yaml.dump(wandb_info, f) | ||
|
|
||
| print(f"WandB run info saved to {output_path}") |
There was a problem hiding this comment.
[nitpick] Using print in library code can clutter stdout; consider using the project’s logger (e.g., logging.info) so output can be controlled by the user’s log level.
Suggested change
| print(f"WandB run info saved to {output_path}") | |
| logging.info(f"WandB run info saved to {output_path}") |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Contributor
Author
|
@MMathisLab I integrated Copilot's suggestion, and added a description of the feature to the docs. |
AlexEMG
approved these changes
Aug 26, 2025
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 Pull Request adds a run identifiers saving mechanism to the
WandbLogger:When
WandbLoggeris configured as a logger - the WandB run information (entity,project,run_id) are saved to a file named wandb_info.yaml in the model folder.This information can be used later to recover the WandB run to which the training process has been logged.