Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3c4901

Browse files
qgallouedeczaristei
authored andcommitted
Improve is_wandb_available function to verify WandB installation (huggingface#39875)
Improve `is_wandb_available` function to verify WandB installation by checking for a key attribute
1 parent 9d2858c commit d3c4901

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/transformers/integrations/integration_utils.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ def is_wandb_available():
111111
"--report_to flag to control the integrations used for logging result (for instance --report_to none)."
112112
)
113113
return False
114-
return importlib.util.find_spec("wandb") is not None
114+
if importlib.util.find_spec("wandb") is not None:
115+
import wandb
116+
117+
# wandb might still be detected by find_spec after an uninstall (leftover files or metadata), but not actually
118+
# import correctly. To confirm it's fully installed and usable, we check for a key attribute like "run".
119+
return hasattr(wandb, "run")
120+
else:
121+
return False
115122

116123

117124
def is_trackio_available():

0 commit comments

Comments
 (0)