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
  • Loading branch information
awaelchli authored and lexierule committed Aug 25, 2022
1 parent 7a50034 commit ae6bd3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/pytorch_lightning/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed

- 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-16
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 @@ -19,6 +19,7 @@
import numbers
import os
import tempfile
import warnings
import weakref
from contextlib import contextmanager
from pathlib import Path
Expand All @@ -39,7 +40,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 @@ -764,6 +764,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 ae6bd3f

Please sign in to comment.