Skip to content

Commit ddf55a2

Browse files
authored
Prune deprecated Trainer(checkpoint_callback=ModelCheckpoint()) (#6166)
1 parent 4d96f19 commit ddf55a2

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2626
- Removed support for passing a bool value to `profiler` argument of Trainer ([#6164](https://github.com/PyTorchLightning/pytorch-lightning/pull/6164))
2727

2828

29+
- Removed passing a `ModelCheckpoint` instance to `Trainer(checkpoint_callback)` ([#6166](https://github.com/PyTorchLightning/pytorch-lightning/pull/6166))
30+
31+
2932
- Removed deprecated Trainer argument `enable_pl_optimizer` and `automatic_optimization` ([#6163](https://github.com/PyTorchLightning/pytorch-lightning/pull/6163))
3033

3134

pytorch_lightning/trainer/connectors/callback_connector.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from pytorch_lightning.callbacks import Callback, ModelCheckpoint, ProgressBar, ProgressBarBase
1818
from pytorch_lightning.core.lightning import LightningModule
19-
from pytorch_lightning.utilities import rank_zero_info, rank_zero_warn
19+
from pytorch_lightning.utilities import rank_zero_info
2020
from pytorch_lightning.utilities.exceptions import MisconfigurationException
2121

2222

@@ -63,15 +63,6 @@ def on_trainer_init(
6363
self.trainer.callbacks = self._reorder_callbacks(self.trainer.callbacks)
6464

6565
def configure_checkpoint_callbacks(self, checkpoint_callback: Union[ModelCheckpoint, bool]):
66-
if isinstance(checkpoint_callback, ModelCheckpoint):
67-
# TODO: deprecated, remove this block in v1.3.0
68-
rank_zero_warn(
69-
"Passing a ModelCheckpoint instance to Trainer(checkpoint_callbacks=...)"
70-
" is deprecated since v1.1 and will no longer be supported in v1.3."
71-
" Use `callbacks` argument instead.", DeprecationWarning
72-
)
73-
self.trainer.callbacks.append(checkpoint_callback)
74-
7566
if self._trainer_has_checkpoint_callbacks() and checkpoint_callback is False:
7667
raise MisconfigurationException(
7768
"Trainer was configured with checkpoint_callback=False but found ModelCheckpoint"

pytorch_lightning/trainer/trainer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ def __init__(
177177
It will configure a default ModelCheckpoint callback if there is no user-defined ModelCheckpoint in
178178
:paramref:`~pytorch_lightning.trainer.trainer.Trainer.callbacks`.
179179
180-
.. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since
181-
v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead.
182-
183180
check_val_every_n_epoch: Check val every n train epochs.
184181
185182
default_root_dir: Default path for logs and weights when no logger/ckpt_callback passed.

tests/checkpointing/test_model_checkpoint.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -899,16 +899,6 @@ def test_configure_model_checkpoint(tmpdir):
899899
assert trainer.checkpoint_callback == callback1
900900
assert trainer.checkpoint_callbacks == [callback1, callback2]
901901

902-
with pytest.warns(DeprecationWarning, match='will no longer be supported in v1.3'):
903-
trainer = Trainer(checkpoint_callback=callback1, **kwargs)
904-
assert [c for c in trainer.callbacks if isinstance(c, ModelCheckpoint)] == [callback1]
905-
assert trainer.checkpoint_callback == callback1
906-
907-
with pytest.warns(DeprecationWarning, match="will no longer be supported in v1.3"):
908-
trainer = Trainer(checkpoint_callback=callback1, callbacks=[callback2], **kwargs)
909-
assert trainer.checkpoint_callback == callback2
910-
assert trainer.checkpoint_callbacks == [callback2, callback1]
911-
912902
with pytest.raises(MisconfigurationException, match="checkpoint_callback=False but found ModelCheckpoint"):
913903
Trainer(checkpoint_callback=False, callbacks=[callback1], **kwargs)
914904

0 commit comments

Comments
 (0)