Skip to content

Commit 987dd54

Browse files
committed
Fix access to logger attribute when multiple loggers are used (#14234)
* Fix access to logger attribute when multiple loggers are used
1 parent c6c283f commit 987dd54

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/pytorch_lightning/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
99
### Fixed
1010

1111
- Fixed an assertion error when using a `ReduceOnPlateau` scheduler with the Horovod strategy ([#14215](https://github.com/Lightning-AI/lightning/pull/14215))
12-
12+
- Fixed an `AttributeError` when accessing `LightningModule.logger` and the Trainer has multiple loggers ([#14234](https://github.com/Lightning-AI/lightning/pull/14234))
1313

1414

1515
## [1.7.2] - 2022-08-16

src/pytorch_lightning/core/module.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import numbers
2020
import os
2121
import tempfile
22+
import warnings
2223
import weakref
2324
from contextlib import contextmanager
2425
from pathlib import Path
@@ -39,7 +40,7 @@
3940
from pytorch_lightning.core.saving import ModelIO
4041
from pytorch_lightning.loggers import Logger, LoggerCollection
4142
from pytorch_lightning.trainer.connectors.logger_connector.fx_validator import _FxValidator
42-
from pytorch_lightning.utilities import _IS_WINDOWS, _TORCH_GREATER_EQUAL_1_10, GradClipAlgorithmType, warnings
43+
from pytorch_lightning.utilities import _IS_WINDOWS, _TORCH_GREATER_EQUAL_1_10, GradClipAlgorithmType
4344
from pytorch_lightning.utilities.apply_func import apply_to_collection, convert_to_tensors
4445
from pytorch_lightning.utilities.cloud_io import get_filesystem
4546
from pytorch_lightning.utilities.distributed import distributed_available, sync_ddp

tests/tests_pytorch/deprecated_api/test_remove_1-8.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,12 @@ def test_v1_8_0_logger_collection(tmpdir):
764764
with pytest.deprecated_call(match="`LoggerCollection` is deprecated in v1.6"):
765765
_ = LoggerCollection([logger1, logger2])
766766

767+
model = BoringModel()
768+
trainer = Trainer(logger=[logger1, logger2])
769+
model.trainer = trainer
770+
with pytest.deprecated_call(match="logger` will return the first logger"):
771+
_ = model.logger
772+
767773

768774
def test_v1_8_0_precision_plugin_checkpoint_hooks(tmpdir):
769775
class PrecisionPluginSaveHook(PrecisionPlugin):

0 commit comments

Comments
 (0)