Skip to content

Commit 4c1b9ff

Browse files
author
Etay Livne
committed
added test to verify that the Experiment object of a CometLogger resets if .alive is False
1 parent a69dae1 commit 4c1b9ff

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/tests_pytorch/loggers/test_comet.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ def test_comet_logger_online(comet_mock):
6666
api.assert_called_once_with("rest")
6767

6868

69+
@mock.patch.dict(os.environ, {})
70+
def test_comet_experiment_resets_if_not_alive(comet_mock):
71+
"""Test that the CometLogger creates a new experiment if the old one is not alive anymore."""
72+
logger = CometLogger()
73+
assert logger._experiment is None
74+
alive_experiment = Mock(alive=True)
75+
logger._experiment = alive_experiment
76+
assert logger.experiment is alive_experiment
77+
78+
unalive_experiment = Mock(alive=False)
79+
logger._experiment = unalive_experiment
80+
assert logger.experiment is not unalive_experiment
81+
82+
6983
@mock.patch.dict(os.environ, {})
7084
def test_comet_logger_no_api_key_given(comet_mock):
7185
"""Test that CometLogger fails to initialize if both api key and save_dir are missing."""

0 commit comments

Comments
 (0)