diff --git a/CHANGELOG.md b/CHANGELOG.md index 69c194bfac5af..8d776968f6152 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 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)) + + ### Removed diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index 4bdafbf97690b..e2153a0cd9341 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 `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)