Skip to content

Commit 3f9dfe4

Browse files
authored
Fix iterating over a DummyLogger when fast_dev_run > 0 (#10232)
1 parent 70570f9 commit 3f9dfe4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
677677
- 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))
678678

679679

680+
- Fixed iterating over a logger collection when `fast_dev_run > 0` ([#10232](https://github.com/PyTorchLightning/pytorch-lightning/pull/10232))
681+
682+
683+
680684
## [1.4.9] - 2021-09-30
681685

682686
- Fixed `lr_find` to generate same results on multiple calls ([#9704](https://github.com/PyTorchLightning/pytorch-lightning/pull/9704))

pytorch_lightning/loggers/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,10 @@ def __getitem__(self, idx) -> "DummyLogger":
510510
# enables self.logger[0].experiment.add_image(...)
511511
return self
512512

513+
def __iter__(self):
514+
# if DummyLogger is substituting a logger collection, pretend it is empty
515+
yield from ()
516+
513517

514518
def merge_dicts(
515519
dicts: Sequence[Mapping],

tests/loggers/test_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,13 @@ def test_dummylogger_support_indexing():
227227
assert logger[0] == logger
228228

229229

230+
def test_dummylogger_empty_iterable():
231+
"""Test that DummyLogger represents an empty iterable."""
232+
logger = DummyLogger()
233+
for _ in logger:
234+
assert False
235+
236+
230237
def test_dummylogger_noop_method_calls():
231238
"""Test that the DummyLogger methods can be called with arbitrary arguments."""
232239
logger = DummyLogger()

0 commit comments

Comments
 (0)