File tree 2 files changed +5
-7
lines changed
pytorch_lightning/loggers 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change 29
29
from pytorch_lightning .utilities import _module_available , rank_zero_only
30
30
from pytorch_lightning .utilities .exceptions import MisconfigurationException
31
31
from 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
35
33
36
34
_WANDB_AVAILABLE = _module_available ("wandb" )
37
35
_WANDB_GREATER_EQUAL_0_10_22 = _compare_version ("wandb" , operator .ge , "0.10.22" )
@@ -129,7 +127,7 @@ def __init__(
129
127
)
130
128
131
129
if log_model and not _WANDB_GREATER_EQUAL_0_10_22 :
132
- warning_cache . warn (
130
+ rank_zero_warn (
133
131
f"Providing log_model={ log_model } requires wandb version >= 0.10.22"
134
132
" for logging associated model metadata.\n "
135
133
"Hint: Upgrade with `pip install --ugrade wandb`."
@@ -186,7 +184,7 @@ def experiment(self) -> Run:
186
184
if wandb .run is None :
187
185
self ._experiment = wandb .init (** self ._wandb_init )
188
186
else :
189
- warning_cache . warn (
187
+ rank_zero_warn (
190
188
"There is a wandb run already in progress and newly created instances of `WandbLogger` will reuse"
191
189
" this run. If this is not desired, call `wandb.finish()` before instantiating `WandbLogger`."
192
190
)
Original file line number Diff line number Diff line change @@ -56,8 +56,8 @@ def test_wandb_logger_init(wandb):
56
56
# verify default resume value
57
57
assert logger ._wandb_init ["resume" ] == "allow"
58
58
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
61
61
62
62
logger .log_metrics ({"acc" : 1.0 }, step = 3 )
63
63
wandb .init .assert_called_once ()
You can’t perform that action at this time.
0 commit comments