From 3be886c3216e0b96d85ae877b01e5d8958d6facf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Fri, 29 Oct 2021 04:20:34 +0200 Subject: [PATCH 1/2] add fix and test --- pytorch_lightning/loggers/base.py | 4 ++++ tests/loggers/test_base.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/pytorch_lightning/loggers/base.py b/pytorch_lightning/loggers/base.py index 35b266dfc4ef4..e5ccae435d8c9 100644 --- a/pytorch_lightning/loggers/base.py +++ b/pytorch_lightning/loggers/base.py @@ -510,6 +510,10 @@ def __getitem__(self, idx) -> "DummyLogger": # 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 7b02d6d72b0fc..d6b753c0439ee 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() From 37646ae2abc152b8caeb16c94117711379dc3a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Fri, 29 Oct 2021 04:27:11 +0200 Subject: [PATCH 2/2] add chlog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c093e04184f..40435d66501fb 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))