Skip to content

Commit

Permalink
Clarify checkpoint deprecation message (#4640)
Browse files Browse the repository at this point in the history
* Clarify checkpoint deprecation message

* Update pytorch_lightning/trainer/connectors/callback_connector.py

Co-authored-by: Adrian Wälchli <[email protected]>

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Adrian Wälchli <[email protected]>
Co-authored-by: Jeff Yang <[email protected]>
Co-authored-by: Roger Shieh <[email protected]>
Co-authored-by: chaton <[email protected]>
Co-authored-by: Jirka Borovec <[email protected]>
  • Loading branch information
6 people authored Nov 22, 2020
1 parent b29757d commit a716ea6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 10 additions & 1 deletion docs/source/trainer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,18 @@ You can override the default behavior by initializing the :class:`~pytorch_light
callback, and adding it to the :paramref:`~pytorch_lightning.trainer.trainer.Trainer.callbacks` list.
See :ref:`Saving and Loading Weights <weights_loading>` for how to customize checkpointing.
.. testcode::
from pytorch_lightning.callbacks import ModelCheckpoint
# Init ModelCheckpoint callback, monitoring 'val_loss'
checkpoint_callback = ModelCheckpoint(monitor='val_loss')
# Add your callback to the callbacks list
trainer = Trainer(callbacks=[checkpoint_callback])
.. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since
v1.1.0 and will be unsupported from v1.3.0.
v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead.
default_root_dir
Expand Down
3 changes: 2 additions & 1 deletion pytorch_lightning/trainer/connectors/callback_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def configure_checkpoint_callbacks(self, checkpoint_callback: Union[ModelCheckpo
# 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.",
" 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)
Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __init__(
:paramref:`~pytorch_lightning.trainer.trainer.Trainer.callbacks`. Default: ``True``.
.. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since
v1.1.0 and will be unsupported from v1.3.0.
v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead.
check_val_every_n_epoch: Check val every n train epochs.
Expand Down

0 comments on commit a716ea6

Please sign in to comment.