Fix iterating over a DummyLogger when `fast_dev_run > 0` (#10232)

This commit is contained in:
Adrian Wälchli 2021-10-29 09:22:59 +02:00 committed by GitHub
parent 70570f9eaa
commit 3f9dfe4949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -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))

View File

@ -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],

View File

@ -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()