From bfda6ae2c670c3a0774574c18fc658a2b72390c6 Mon Sep 17 00:00:00 2001 From: edenlightning <66261195+edenlightning@users.noreply.github.com> Date: Thu, 12 Nov 2020 10:06:40 -0500 Subject: [PATCH 1/5] Clarify checkpoint deprecation message --- docs/source/trainer.rst | 10 +++++++++- .../trainer/connectors/callback_connector.py | 3 ++- pytorch_lightning/trainer/trainer.py | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/source/trainer.rst b/docs/source/trainer.rst index e82b0871ef85b..cb10b2d889be4 100644 --- a/docs/source/trainer.rst +++ b/docs/source/trainer.rst @@ -580,9 +580,17 @@ 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 ` for how to customize checkpointing. +.. code-block:: python + + # 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.0 and will be unsupported from v1.3.0. Use `callbacks` argument instead. default_root_dir diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index c9ef4ae32be77..284d911f6430b 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -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) diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index ad7a20e500687..c128e711c6c71 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -177,7 +177,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.0 and will be unsupported from v1.3.0. Use `callbacks` argument instead. check_val_every_n_epoch: Check val every n train epochs. From 3db2948cc231cb2b83abe997c66ba8dfaed67e08 Mon Sep 17 00:00:00 2001 From: edenlightning <66261195+edenlightning@users.noreply.github.com> Date: Thu, 12 Nov 2020 15:30:18 -0500 Subject: [PATCH 2/5] Update pytorch_lightning/trainer/connectors/callback_connector.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrian Wälchli --- 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 284d911f6430b..0f642d26a1157 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -60,7 +60,7 @@ def configure_checkpoint_callbacks(self, checkpoint_callback: Union[ModelCheckpo 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.", + " Use `callbacks` argument instead.", DeprecationWarning ) self.trainer.callbacks.append(checkpoint_callback) From 32796fa37d29af1260aefd0e55584088375565b6 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Fri, 20 Nov 2020 21:17:58 +0100 Subject: [PATCH 3/5] Apply suggestions from code review --- docs/source/trainer.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/trainer.rst b/docs/source/trainer.rst index e1d4fa0acb517..229b4e7c4f317 100644 --- a/docs/source/trainer.rst +++ b/docs/source/trainer.rst @@ -580,7 +580,7 @@ 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 ` for how to customize checkpointing. -.. code-block:: python +.. testcode:: # Init ModelCheckpoint callback, monitoring 'val_loss' checkpoint_callback = ModelCheckpoint(monitor='val_loss') @@ -1710,4 +1710,3 @@ The metrics sent to the progress bar. progress_bar_metrics = trainer.progress_bar_metrics assert progress_bar_metrics['a_val'] == 2 - From 8fa5ed92b8681bee505fab557406a800c1d74bf4 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Fri, 20 Nov 2020 23:33:07 +0100 Subject: [PATCH 4/5] Apply suggestions from code review --- docs/source/trainer.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/trainer.rst b/docs/source/trainer.rst index f41d19e2122ab..64ccac5f208c6 100644 --- a/docs/source/trainer.rst +++ b/docs/source/trainer.rst @@ -582,6 +582,7 @@ See :ref:`Saving and Loading Weights ` for how to customize che .. testcode:: + from pytorch_lightning.callbacks import ModelCheckpoint # Init ModelCheckpoint callback, monitoring 'val_loss' checkpoint_callback = ModelCheckpoint(monitor='val_loss') From 896c2a5da3a8d38ebd0b6af7d9aa415f1b90c7fe Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Sat, 21 Nov 2020 00:26:18 +0100 Subject: [PATCH 5/5] Apply suggestions from code review --- docs/source/trainer.rst | 2 +- pytorch_lightning/trainer/trainer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/trainer.rst b/docs/source/trainer.rst index 64ccac5f208c6..563234757995c 100644 --- a/docs/source/trainer.rst +++ b/docs/source/trainer.rst @@ -591,7 +591,7 @@ See :ref:`Saving and Loading Weights ` for how to customize che .. warning:: Passing a ModelCheckpoint instance to this argument is deprecated since - v1.1.0 and will be unsupported from v1.3.0. Use `callbacks` argument instead. + v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead. default_root_dir diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 9c3c8bc60ac8c..483c602de3f55 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -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. Use `callbacks` argument instead. + v1.1 and will be unsupported from v1.3. Use `callbacks` argument instead. check_val_every_n_epoch: Check val every n train epochs.