File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
pytorch_lightning/loggers Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 2929from pytorch_lightning .utilities import _module_available , rank_zero_only
3030from pytorch_lightning .utilities .exceptions import MisconfigurationException
3131from pytorch_lightning .utilities .imports import _compare_version
32- from pytorch_lightning .utilities .warnings import WarningCache
33-
34- warning_cache = WarningCache ()
32+ from pytorch_lightning .utilities .warnings import rank_zero_deprecation , rank_zero_warn
3533
3634_WANDB_AVAILABLE = _module_available ("wandb" )
3735_WANDB_GREATER_EQUAL_0_10_22 = _compare_version ("wandb" , operator .ge , "0.10.22" )
@@ -129,7 +127,7 @@ def __init__(
129127 )
130128
131129 if log_model and not _WANDB_GREATER_EQUAL_0_10_22 :
132- warning_cache . warn (
130+ rank_zero_warn (
133131 f"Providing log_model={ log_model } requires wandb version >= 0.10.22"
134132 " for logging associated model metadata.\n "
135133 "Hint: Upgrade with `pip install --ugrade wandb`."
@@ -186,7 +184,7 @@ def experiment(self) -> Run:
186184 if wandb .run is None :
187185 self ._experiment = wandb .init (** self ._wandb_init )
188186 else :
189- warning_cache . warn (
187+ rank_zero_warn (
190188 "There is a wandb run already in progress and newly created instances of `WandbLogger` will reuse"
191189 " this run. If this is not desired, call `wandb.finish()` before instantiating `WandbLogger`."
192190 )
Original file line number Diff line number Diff line change @@ -56,8 +56,8 @@ def test_wandb_logger_init(wandb):
5656 # verify default resume value
5757 assert logger ._wandb_init ["resume" ] == "allow"
5858
59- _ = logger . experiment
60- assert any ( "There is a wandb run already in progress" in w for w in pytorch_lightning . loggers . wandb . warning_cache )
59+ with pytest . warns ( UserWarning , match = "There is a wandb run already in progress" ):
60+ _ = logger . experiment
6161
6262 logger .log_metrics ({"acc" : 1.0 }, step = 3 )
6363 wandb .init .assert_called_once ()
You can’t perform that action at this time.
0 commit comments