From e343b3574ca3f3e8e89b6accf2a310ab559617ea Mon Sep 17 00:00:00 2001 From: Kaushik B Date: Tue, 31 Aug 2021 15:51:03 +0530 Subject: [PATCH 1/5] Deprecate process_position from the Trainer constructor --- pytorch_lightning/trainer/connectors/callback_connector.py | 7 +++++++ pytorch_lightning/trainer/trainer.py | 5 +++++ tests/deprecated_api/test_remove_1-7.py | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index 4bdafbf97690b..fdceb9193d55e 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -19,6 +19,7 @@ from pytorch_lightning.callbacks.timer import Timer from pytorch_lightning.utilities import rank_zero_info from pytorch_lightning.utilities.exceptions import MisconfigurationException +from pytorch_lightning.utilities.warnings import rank_zero_deprecation class CallbackConnector: @@ -58,6 +59,12 @@ def on_trainer_init( self._configure_timer_callback(max_time) # init progress bar + if process_position != 0: + rank_zero_deprecation( + f"Setting `Trainer(process_position={process_position})` is deprecated in v1.5 and will be removed" + " in v1.7. Please pass :class:`~pytorch_lightning.callbacks.progress.ProgressBar` with" + " ``process_position`` directly to the Trainer's `callbacks` argument instead." + ) self.trainer._progress_bar_callback = self.configure_progress_bar(progress_bar_refresh_rate, process_position) # push all checkpoint callbacks to the end diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index f56a84b1d294d..a6ace2a04cdeb 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -247,6 +247,11 @@ def __init__( process_position: orders the progress bar when running multiple models on same machine. + .. deprecated:: v1.5 + ``process_position`` has been deprecated in v1.5 and will be removed in v1.7. + Please pass :class:`~pytorch_lightning.callbacks.progress.ProgressBar` with ``process_position`` + directly to the Trainer's ``callbacks`` argument instead. + progress_bar_refresh_rate: How often to refresh progress bar (in steps). Value ``0`` disables progress bar. Ignored when a custom progress bar is passed to :paramref:`~Trainer.callbacks`. Default: None, means a suitable value will be chosen based on the environment (terminal, Google COLAB, etc.). diff --git a/tests/deprecated_api/test_remove_1-7.py b/tests/deprecated_api/test_remove_1-7.py index 8c7b1a00d13d4..188b7f4a4a3fa 100644 --- a/tests/deprecated_api/test_remove_1-7.py +++ b/tests/deprecated_api/test_remove_1-7.py @@ -116,3 +116,8 @@ def test_v1_7_0_deprecated_on_train_dataloader(tmpdir): def test_v1_7_0_test_tube_logger(_, tmpdir): with pytest.deprecated_call(match="The TestTubeLogger is deprecated since v1.5 and will be removed in v1.7"): _ = TestTubeLogger(tmpdir) + + +def test_v1_7_0_process_position_trainer_constructor(tmpdir): + with pytest.deprecated_call(match=r"Setting `Trainer\(process_position=5\)` is deprecated in v1.5"): + _ = Trainer(process_position=5) From b13e97e7db6229aaefadb80dcc992a772ef31a61 Mon Sep 17 00:00:00 2001 From: Kaushik B Date: Tue, 31 Aug 2021 15:54:24 +0530 Subject: [PATCH 2/5] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69c194bfac5af..f8c16deaea346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -172,6 +172,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Updated deprecation of `argparse_utils.py` from removal in 1.4 to 2.0 ([#9162](https://github.com/PyTorchLightning/pytorch-lightning/pull/9162)) +- Deprecated passing `process_position` to the `Trainer` constructor ([#9222](https://github.com/PyTorchLightning/pytorch-lightning/pull/9222)) + + ### Removed From 4217dc1e929b957d4bb8f7a30bfd9000431c07ff Mon Sep 17 00:00:00 2001 From: Kaushik B Date: Tue, 31 Aug 2021 16:44:11 +0530 Subject: [PATCH 3/5] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c16deaea346..8d776968f6152 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -172,7 +172,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Updated deprecation of `argparse_utils.py` from removal in 1.4 to 2.0 ([#9162](https://github.com/PyTorchLightning/pytorch-lightning/pull/9162)) -- Deprecated passing `process_position` to the `Trainer` constructor ([#9222](https://github.com/PyTorchLightning/pytorch-lightning/pull/9222)) +- Deprecated passing `process_position` to the `Trainer` constructor in favor of adding the `ProgressBar` callback with `process_position` directly to the list of callbacks ([#9222](https://github.com/PyTorchLightning/pytorch-lightning/pull/9222)) From 21959ae23bb448a3fb8246f4cb65079adb21b9ae Mon Sep 17 00:00:00 2001 From: Kaushik B <45285388+kaushikb11@users.noreply.github.com> Date: Tue, 31 Aug 2021 16:45:43 +0530 Subject: [PATCH 4/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 fdceb9193d55e..ac0030e052a8c 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -62,7 +62,7 @@ def on_trainer_init( if process_position != 0: rank_zero_deprecation( f"Setting `Trainer(process_position={process_position})` is deprecated in v1.5 and will be removed" - " in v1.7. Please pass :class:`~pytorch_lightning.callbacks.progress.ProgressBar` with" + " in v1.7. Please pass `pytorch_lightning.callbacks.progress.ProgressBar` with" " ``process_position`` directly to the Trainer's `callbacks` argument instead." ) self.trainer._progress_bar_callback = self.configure_progress_bar(progress_bar_refresh_rate, process_position) From 7ec5cb76b342699afc65a60bace98f4eaa69d2f3 Mon Sep 17 00:00:00 2001 From: Kaushik B <45285388+kaushikb11@users.noreply.github.com> Date: Tue, 31 Aug 2021 16:45:50 +0530 Subject: [PATCH 5/5] Update pytorch_lightning/trainer/connectors/callback_connector.py Co-authored-by: Ethan Harris --- 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 ac0030e052a8c..e2153a0cd9341 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -63,7 +63,7 @@ def on_trainer_init( rank_zero_deprecation( f"Setting `Trainer(process_position={process_position})` is deprecated in v1.5 and will be removed" " in v1.7. Please pass `pytorch_lightning.callbacks.progress.ProgressBar` with" - " ``process_position`` directly to the Trainer's `callbacks` argument instead." + " `process_position` directly to the Trainer's `callbacks` argument instead." ) self.trainer._progress_bar_callback = self.configure_progress_bar(progress_bar_refresh_rate, process_position)