From 140b0c727e7c79dc33569e391948e1474d57449b Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Wed, 12 May 2021 19:19:30 +0200 Subject: [PATCH] Prune deprecated trainer attributes 2 (#7502) * accelerator_backend * get_model * clean * chlog * flake8 --- CHANGELOG.md | 1 + pytorch_lightning/trainer/deprecated_api.py | 20 +------------------- tests/deprecated_api/test_remove_1-4.py | 14 -------------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adf5113e9e..49b424c258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed +- Removed deprecated trainer attributes - `get_model` and `accelerator_backend` ([7502](https://github.com/PyTorchLightning/pytorch-lightning/pull/7502)) ### Fixed diff --git a/pytorch_lightning/trainer/deprecated_api.py b/pytorch_lightning/trainer/deprecated_api.py index 32dbc8c408..b772d6024b 100644 --- a/pytorch_lightning/trainer/deprecated_api.py +++ b/pytorch_lightning/trainer/deprecated_api.py @@ -11,8 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from pytorch_lightning.accelerators import Accelerator -from pytorch_lightning.core.lightning import LightningModule + from pytorch_lightning.trainer.connectors.accelerator_connector import AcceleratorConnector from pytorch_lightning.utilities import DeviceType, DistributedType, rank_zero_deprecation @@ -127,25 +126,8 @@ class DeprecatedDistDeviceAttributes: class DeprecatedTrainerAttributes: - accelerator: Accelerator - lightning_module: LightningModule sanity_checking: bool - @property - def accelerator_backend(self) -> Accelerator: - rank_zero_deprecation( - "The `Trainer.accelerator_backend` attribute is deprecated in favor of `Trainer.accelerator`" - " since 1.2 and will be removed in v1.4." - ) - return self.accelerator - - def get_model(self) -> LightningModule: - rank_zero_deprecation( - "The use of `Trainer.get_model()` is deprecated in favor of `Trainer.lightning_module`" - " and will be removed in v1.4." - ) - return self.lightning_module - @property def running_sanity_check(self) -> bool: rank_zero_deprecation( diff --git a/tests/deprecated_api/test_remove_1-4.py b/tests/deprecated_api/test_remove_1-4.py index 99e1b31f6e..09780d3a10 100644 --- a/tests/deprecated_api/test_remove_1-4.py +++ b/tests/deprecated_api/test_remove_1-4.py @@ -30,20 +30,6 @@ from tests.helpers import BoringModel from tests.helpers.runif import RunIf -def test_v1_4_0_deprecated_trainer_attributes(): - with pytest.deprecated_call(match="will be removed in v1.4."): - trainer = Trainer() - _ = trainer.accelerator_backend - assert trainer.accelerator == trainer.accelerator_backend - - -def test_v1_4_0_deprecated_trainer_methods(): - with pytest.deprecated_call(match='will be removed in v1.4'): - trainer = Trainer() - _ = trainer.get_model() - assert trainer.get_model() == trainer.lightning_module - - def test_v1_4_0_deprecated_imports(): _soft_unimport_module('pytorch_lightning.utilities.argparse_utils') with pytest.deprecated_call(match='will be removed in v1.4'):