From da5453d880e96f1b6b8ea35e3bae3545412b614e Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Wed, 24 Feb 2021 00:40:12 +0100 Subject: [PATCH 1/5] Remove code --- CHANGELOG.md | 3 +++ .../trainer/connectors/callback_connector.py | 9 --------- pytorch_lightning/trainer/trainer.py | 3 --- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dfc9a1c021ac..a2c21cb877d6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed +- Removed passing a `ModelCheckpoint` instance to `Trainer(checkpoint_callback)` ([#6165](https://github.com/PyTorchLightning/pytorch-lightning/pull/6165)) + + ### Fixed - Fixed incorrect yield logic for the amp autocast context manager ([#6080](https://github.com/PyTorchLightning/pytorch-lightning/pull/6080)) diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index 14694c8f77811..e6ad64c903791 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -68,15 +68,6 @@ def on_trainer_init( self.trainer.callbacks = self._reorder_callbacks(self.trainer.callbacks) def configure_checkpoint_callbacks(self, checkpoint_callback: Union[ModelCheckpoint, bool]): - if isinstance(checkpoint_callback, ModelCheckpoint): - # TODO: deprecated, remove this block in v1.3.0 - rank_zero_warn( - "Passing a ModelCheckpoint instance to Trainer(checkpoint_callbacks=...)" - " is deprecated since v1.1 and will no longer be supported in v1.3." - " Use `callbacks` argument instead.", DeprecationWarning - ) - self.trainer.callbacks.append(checkpoint_callback) - if self._trainer_has_checkpoint_callbacks() and checkpoint_callback is False: raise MisconfigurationException( "Trainer was configured with checkpoint_callback=False but found ModelCheckpoint" diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index cf3bfd7a3e5a3..2a4771a447382 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -179,9 +179,6 @@ def __init__( It will configure a default ModelCheckpoint callback if there is no user-defined ModelCheckpoint in :paramref:`~pytorch_lightning.trainer.trainer.Trainer.callbacks`. Default: ``True``. - .. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since - v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead. - check_val_every_n_epoch: Check val every n train epochs. default_root_dir: Default path for logs and weights when no logger/ckpt_callback passed. From e7984d047e3cc32d5dc83e50022d83aec3816469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Wed, 24 Feb 2021 00:43:00 +0100 Subject: [PATCH 2/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c21cb877d6f..1bdd306fc8231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ### Removed -- Removed passing a `ModelCheckpoint` instance to `Trainer(checkpoint_callback)` ([#6165](https://github.com/PyTorchLightning/pytorch-lightning/pull/6165)) +- Removed passing a `ModelCheckpoint` instance to `Trainer(checkpoint_callback)` ([#6166](https://github.com/PyTorchLightning/pytorch-lightning/pull/6166)) ### Fixed From d6066a69be88a74ff76177bb16886376b9aa31c2 Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Wed, 24 Feb 2021 00:45:39 +0100 Subject: [PATCH 3/5] Remove test --- tests/checkpointing/test_model_checkpoint.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/checkpointing/test_model_checkpoint.py b/tests/checkpointing/test_model_checkpoint.py index bd4a02536c5c3..2eab43b6353fb 100644 --- a/tests/checkpointing/test_model_checkpoint.py +++ b/tests/checkpointing/test_model_checkpoint.py @@ -776,16 +776,6 @@ def test_configure_model_checkpoint(tmpdir): assert trainer.checkpoint_callback == callback1 assert trainer.checkpoint_callbacks == [callback1, callback2] - with pytest.warns(DeprecationWarning, match='will no longer be supported in v1.3'): - trainer = Trainer(checkpoint_callback=callback1, **kwargs) - assert [c for c in trainer.callbacks if isinstance(c, ModelCheckpoint)] == [callback1] - assert trainer.checkpoint_callback == callback1 - - with pytest.warns(DeprecationWarning, match="will no longer be supported in v1.3"): - trainer = Trainer(checkpoint_callback=callback1, callbacks=[callback2], **kwargs) - assert trainer.checkpoint_callback == callback2 - assert trainer.checkpoint_callbacks == [callback2, callback1] - with pytest.raises(MisconfigurationException, match="checkpoint_callback=False but found ModelCheckpoint"): Trainer(checkpoint_callback=False, callbacks=[callback1], **kwargs) From 9829dd6a374ba030a8c5405c2d7787031900f375 Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Wed, 24 Feb 2021 00:50:52 +0100 Subject: [PATCH 4/5] Unused import --- pytorch_lightning/trainer/connectors/callback_connector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index e6ad64c903791..6d6d2f02cd476 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -21,7 +21,7 @@ ProgressBarBase, ) from pytorch_lightning.core.lightning import LightningModule -from pytorch_lightning.utilities import rank_zero_info, rank_zero_warn +from pytorch_lightning.utilities import rank_zero_info from pytorch_lightning.utilities.exceptions import MisconfigurationException From c6cf06d133e44bde0392db0b93c0abf7459e35be Mon Sep 17 00:00:00 2001 From: Carlos Mocholi Date: Wed, 24 Feb 2021 13:54:58 +0100 Subject: [PATCH 5/5] Remove test --- tests/deprecated_api/test_remove_1-3.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/deprecated_api/test_remove_1-3.py b/tests/deprecated_api/test_remove_1-3.py index 99cb280e96797..7e4a7b482a533 100644 --- a/tests/deprecated_api/test_remove_1-3.py +++ b/tests/deprecated_api/test_remove_1-3.py @@ -24,10 +24,6 @@ def test_v1_3_0_deprecated_arguments(tmpdir): - with pytest.deprecated_call(match='will no longer be supported in v1.3'): - callback = ModelCheckpoint() - Trainer(checkpoint_callback=callback, callbacks=[], default_root_dir=tmpdir) - # Deprecate prefix with pytest.deprecated_call(match='will be removed in v1.3'): ModelCheckpoint(prefix='temp')