diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c093e041..40435d6650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -677,6 +677,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed an issue with `pl.utilities.seed.reset_seed` converting the `PL_SEED_WORKERS` environment variable to `bool` ([#10099](https://github.com/PyTorchLightning/pytorch-lightning/pull/10099)) +- Fixed iterating over a logger collection when `fast_dev_run > 0` ([#10232](https://github.com/PyTorchLightning/pytorch-lightning/pull/10232)) + + + ## [1.4.9] - 2021-09-30 - Fixed `lr_find` to generate same results on multiple calls ([#9704](https://github.com/PyTorchLightning/pytorch-lightning/pull/9704)) diff --git a/pytorch_lightning/loggers/base.py b/pytorch_lightning/loggers/base.py index 35b266dfc4..e5ccae435d 100644 --- a/pytorch_lightning/loggers/base.py +++ b/pytorch_lightning/loggers/base.py @@ -510,6 +510,10 @@ class DummyLogger(LightningLoggerBase): # enables self.logger[0].experiment.add_image(...) return self + def __iter__(self): + # if DummyLogger is substituting a logger collection, pretend it is empty + yield from () + def merge_dicts( dicts: Sequence[Mapping], diff --git a/tests/loggers/test_base.py b/tests/loggers/test_base.py index 7b02d6d72b..d6b753c043 100644 --- a/tests/loggers/test_base.py +++ b/tests/loggers/test_base.py @@ -227,6 +227,13 @@ def test_dummylogger_support_indexing(): assert logger[0] == logger +def test_dummylogger_empty_iterable(): + """Test that DummyLogger represents an empty iterable.""" + logger = DummyLogger() + for _ in logger: + assert False + + def test_dummylogger_noop_method_calls(): """Test that the DummyLogger methods can be called with arbitrary arguments.""" logger = DummyLogger()