Skip to content

Commit

Permalink
fix the wandb logging issue (huggingface#33464)
Browse files Browse the repository at this point in the history
* fix the wandb logging issue

* handle ConfigError in WandbCallback; move import to local scope

* update integration_utils.py; move import of ConfigError

* Update integration_utils.py: remove trailing whitespace
  • Loading branch information
ZIYU-DEEP authored and itazap committed Sep 20, 2024
1 parent cc40c76 commit 2b0af42
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/transformers/integrations/integration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,10 @@ def setup(self, args, state, model, **kwargs):
if self._wandb is None:
return
self._initialized = True

# prepare to handle potential configuration issues during setup
from wandb.sdk.lib.config_util import ConfigError as WandbConfigError

if state.is_world_process_zero:
logger.info(
'Automatic Weights & Biases logging enabled, to disable set os.environ["WANDB_DISABLED"] = "true"'
Expand Down Expand Up @@ -852,7 +856,13 @@ def setup(self, args, state, model, **kwargs):
try:
self._wandb.config["model/num_parameters"] = model.num_parameters()
except AttributeError:
logger.info("Could not log the number of model parameters in Weights & Biases.")
logger.info(
"Could not log the number of model parameters in Weights & Biases due to an AttributeError."
)
except WandbConfigError:
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

0 comments on commit 2b0af42

Please sign in to comment.