Skip to content

Commit

Permalink
Fix access to logger attribute when multiple loggers are used (#14234)
Browse files Browse the repository at this point in the history
* Fix access to logger attribute when multiple loggers are used

* add changelog
  • Loading branch information
awaelchli authored Aug 18, 2022
1 parent bd55b56 commit 7879628
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Fixed an assertion error when using a `ReduceOnPlateau` scheduler with the Horovod strategy ([#14215](https://github.com/Lightning-AI/lightning/pull/14215))


- Fixed an `AttributeError` when accessing `LightningModule.logger` and the Trainer has multiple loggers ([#14234](https://github.com/Lightning-AI/lightning/pull/14234))


## [1.7.2] - 2022-08-17

Expand Down
3 changes: 2 additions & 1 deletion src/pytorch_lightning/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import numbers
import os
import tempfile
import warnings
import weakref
from contextlib import contextmanager
from pathlib import Path
Expand All @@ -38,7 +39,7 @@
from pytorch_lightning.core.saving import ModelIO
from pytorch_lightning.loggers import Logger, LoggerCollection
from pytorch_lightning.trainer.connectors.logger_connector.fx_validator import _FxValidator
from pytorch_lightning.utilities import _IS_WINDOWS, _TORCH_GREATER_EQUAL_1_10, GradClipAlgorithmType, warnings
from pytorch_lightning.utilities import _IS_WINDOWS, _TORCH_GREATER_EQUAL_1_10, GradClipAlgorithmType
from pytorch_lightning.utilities.apply_func import apply_to_collection, convert_to_tensors
from pytorch_lightning.utilities.cloud_io import get_filesystem
from pytorch_lightning.utilities.distributed import distributed_available, sync_ddp
Expand Down
6 changes: 6 additions & 0 deletions tests/tests_pytorch/deprecated_api/test_remove_1-8.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ def test_v1_8_0_logger_collection(tmpdir):
with pytest.deprecated_call(match="`LoggerCollection` is deprecated in v1.6"):
_ = LoggerCollection([logger1, logger2])

model = BoringModel()
trainer = Trainer(logger=[logger1, logger2])
model.trainer = trainer
with pytest.deprecated_call(match="logger` will return the first logger"):
_ = model.logger


def test_v1_8_0_precision_plugin_checkpoint_hooks(tmpdir):
class PrecisionPluginSaveHook(PrecisionPlugin):
Expand Down

0 comments on commit 7879628

Please sign in to comment.