Prune deprecated trainer attributes 2 (#7502)

* accelerator_backend

* get_model

* clean

* chlog

* flake8
This commit is contained in:
Jirka Borovec 2021-05-12 19:19:30 +02:00 committed by GitHub
parent 83283fdb20
commit 140b0c727e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 33 deletions

View File

@ -55,6 +55,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Removed ### Removed
- Removed deprecated trainer attributes - `get_model` and `accelerator_backend` ([7502](https://github.com/PyTorchLightning/pytorch-lightning/pull/7502))
### Fixed ### Fixed

View File

@ -11,8 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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.trainer.connectors.accelerator_connector import AcceleratorConnector
from pytorch_lightning.utilities import DeviceType, DistributedType, rank_zero_deprecation from pytorch_lightning.utilities import DeviceType, DistributedType, rank_zero_deprecation
@ -127,25 +126,8 @@ class DeprecatedDistDeviceAttributes:
class DeprecatedTrainerAttributes: class DeprecatedTrainerAttributes:
accelerator: Accelerator
lightning_module: LightningModule
sanity_checking: bool 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 @property
def running_sanity_check(self) -> bool: def running_sanity_check(self) -> bool:
rank_zero_deprecation( rank_zero_deprecation(

View File

@ -30,20 +30,6 @@ from tests.helpers import BoringModel
from tests.helpers.runif import RunIf 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(): def test_v1_4_0_deprecated_imports():
_soft_unimport_module('pytorch_lightning.utilities.argparse_utils') _soft_unimport_module('pytorch_lightning.utilities.argparse_utils')
with pytest.deprecated_call(match='will be removed in v1.4'): with pytest.deprecated_call(match='will be removed in v1.4'):