From bfd11004bb3e719a54e1d42250ae6c3bd262f457 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Thu, 8 Oct 2020 10:09:56 +0200 Subject: [PATCH] remove deprecated model hooks --- docs/source/hooks.rst | 2 -- pytorch_lightning/core/hooks.py | 21 ------------------- pytorch_lightning/core/lightning.py | 32 ----------------------------- tests/test_deprecated.py | 29 -------------------------- 4 files changed, 84 deletions(-) diff --git a/docs/source/hooks.rst b/docs/source/hooks.rst index 27f63952bf203..c5b18b4337946 100644 --- a/docs/source/hooks.rst +++ b/docs/source/hooks.rst @@ -40,7 +40,6 @@ Training loop ^^^^^^^^^^^^^ - :meth:`~pytorch_lightning.core.hooks.ModelHooks.on_epoch_start` -- :meth:`~pytorch_lightning.core.hooks.ModelHooks.on_batch_start` - :meth:`~pytorch_lightning.core.lightning.LightningModule.tbptt_split_batch` - :meth:`~pytorch_lightning.core.lightning.LightningModule.training_step` - :meth:`~pytorch_lightning.core.lightning.LightningModule.training_step_end` (optional) @@ -48,7 +47,6 @@ Training loop - :meth:`~pytorch_lightning.core.hooks.ModelHooks.backward` - :meth:`~pytorch_lightning.core.hooks.ModelHooks.on_after_backward` - ``optimizer.step()`` -- :meth:`~pytorch_lightning.core.hooks.ModelHooks.on_batch_end` - :meth:`~pytorch_lightning.core.lightning.LightningModule.training_epoch_end` - :meth:`~pytorch_lightning.core.hooks.ModelHooks.on_epoch_end` diff --git a/pytorch_lightning/core/hooks.py b/pytorch_lightning/core/hooks.py index 3608ea07d490e..3734d535b65dd 100644 --- a/pytorch_lightning/core/hooks.py +++ b/pytorch_lightning/core/hooks.py @@ -209,27 +209,6 @@ def on_test_model_train(self) -> None: """ self.train() - def on_batch_start(self, batch: Any) -> None: - """ - Called in the training loop before anything happens for that batch. - - If you return -1 here, you will skip training for the rest of the current epoch. - - Args: - batch: The batched data as it is returned by the training DataLoader. - - .. warning:: Deprecated in 0.9.0 will remove 1.0.0 (use `on_train_batch_start` instead) - """ - # do something when the batch starts - - def on_batch_end(self) -> None: - """ - Called in the training loop after the batch. - - .. warning:: Deprecated in 0.9.0 will remove 1.0.0 (use `on_train_batch_end` instead) - """ - # do something when the batch ends - def on_epoch_start(self) -> None: """ Called in the training loop at the very beginning of the epoch. diff --git a/pytorch_lightning/core/lightning.py b/pytorch_lightning/core/lightning.py index 5f21d93f584c9..3219035a48d93 100644 --- a/pytorch_lightning/core/lightning.py +++ b/pytorch_lightning/core/lightning.py @@ -685,13 +685,6 @@ def validation_epoch_end(self, val_step_outputs): See the :ref:`multi_gpu` guide for more details. """ - def validation_end(self, outputs): - """ - Warnings: - Deprecated in v0.7.0. Use :meth:`validation_epoch_end` instead. - Will be removed in 1.0.0. - """ - def validation_epoch_end( self, outputs: List[Any] ) -> None: @@ -868,13 +861,6 @@ def test_epoch_end(self, output_results): See the :ref:`multi_gpu` guide for more details. """ - def test_end(self, outputs): - """ - Warnings: - Deprecated in v0.7.0. Use :meth:`test_epoch_end` instead. - Will be removed in 1.0.0. - """ - def test_epoch_end( self, outputs: List[Any] ) -> None: @@ -1288,24 +1274,6 @@ def get_progress_bar_dict(self): return tqdm_dict - def get_tqdm_dict(self) -> Dict[str, Union[int, str]]: - """ - Additional items to be displayed in the progress bar. - - Return: - Dictionary with the items to be displayed in the progress bar. - - Warning: - Deprecated since v0.7.3. - Use :meth:`get_progress_bar_dict` instead. - """ - rank_zero_warn( - "`get_tqdm_dict` was renamed to `get_progress_bar_dict` in v0.7.3" - " and this method will be removed in v1.0.0", - DeprecationWarning, - ) - return self.get_progress_bar_dict() - @classmethod def _auto_collect_arguments(cls, frame=None) -> Tuple[Dict, Dict]: """""" diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 00f142e79e71e..1cdec33ae7519 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -52,32 +52,3 @@ def test_dataloader(self): def test_end(self, outputs): return {'test_loss': torch.tensor(0.7)} - - -# def test_tbd_remove_in_v1_0_0_model_hooks(): -# -# model = ModelVer0_6() -# -# with pytest.deprecated_call(match='will be removed in v1.0. Use `test_epoch_end` instead'): -# trainer = Trainer(logger=False) -# trainer.test(model) -# assert trainer.logger_connector.callback_metrics == {'test_loss': torch.tensor(0.6)} -# -# with pytest.deprecated_call(match='will be removed in v1.0. Use `validation_epoch_end` instead'): -# trainer = Trainer(logger=False) -# # TODO: why `dataloder` is required if it is not used -# result = trainer._evaluate(model, dataloaders=[[None]], max_batches=1) -# assert result[0] == {'val_loss': torch.tensor(0.6)} -# -# model = ModelVer0_7() -# -# with pytest.deprecated_call(match='will be removed in v1.0. Use `test_epoch_end` instead'): -# trainer = Trainer(logger=False) -# trainer.test(model) -# assert trainer.logger_connector.callback_metrics == {'test_loss': torch.tensor(0.7)} -# -# with pytest.deprecated_call(match='will be removed in v1.0. Use `validation_epoch_end` instead'): -# trainer = Trainer(logger=False) -# # TODO: why `dataloder` is required if it is not used -# result = trainer._evaluate(model, dataloaders=[[None]], max_batches=1) -# assert result[0] == {'val_loss': torch.tensor(0.7)}