Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/transformers/integrations/integration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ def setup(self, args, state, model, **kwargs):
self._wandb.config["model/num_parameters"] = model.num_parameters()
except AttributeError:
logger.info("Could not log the number of model parameters in Weights & Biases.")
except self._wandb.sdk.lib.config_util.ConfigError:
Copy link
Member

Choose a reason for hiding this comment

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

Is there a path for the ConfigError that doesn't depend on self?

Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to #33464, but we could import the error at __init__ instead imo:

def __init__(self):
has_wandb = is_wandb_available()
if not has_wandb:
raise RuntimeError("WandbCallback requires wandb to be installed. Run `pip install wandb`.")
if has_wandb:
import wandb

Copy link
Author

Choose a reason for hiding this comment

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

Hello thanks for the comment, yes I tried to remain consistent with the other wandb references in this file which are all made through self._wandb. Feel free to close this PR in favor of #33464 if you prefer the other implementation :-)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks both! IMO it's a bit cleaner to have the error be imported here rather than as a reference to self, so I'll go ahead and merge the other PR.

I appreciate your contribution, please keep them coming!

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, I will abandon this PR.

logger.warning(
"A ConfigError was raised whilst setting the number of model parameters in Weights & Biases config."
)

# log the initial model architecture to an artifact
if self._log_model.is_enabled:
Expand Down