diff --git a/CHANGELOG.md b/CHANGELOG.md index 437d57a933169..58c6d70679fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -252,6 +252,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Deprecated `LightningLoggerBase.close`, `LoggerCollection.close` in favor of `LightningLoggerBase.finalize`, `LoggerCollection.finalize` ([#9422](https://github.com/PyTorchLightning/pytorch-lightning/pull/9422)) +- Deprecated passing `progress_bar_refresh_rate` to the `Trainer` constructor in favor of adding the `ProgressBar` callback with `refresh_rate` directly to the list of callbacks ([#9616](https://github.com/PyTorchLightning/pytorch-lightning/pull/9616)) + ### Removed diff --git a/pytorch_lightning/trainer/connectors/callback_connector.py b/pytorch_lightning/trainer/connectors/callback_connector.py index cafad831cbb30..95e9e930100ba 100644 --- a/pytorch_lightning/trainer/connectors/callback_connector.py +++ b/pytorch_lightning/trainer/connectors/callback_connector.py @@ -74,6 +74,14 @@ def on_trainer_init( " in v1.7. Please pass `pytorch_lightning.callbacks.progress.ProgressBar` with" " `process_position` directly to the Trainer's `callbacks` argument instead." ) + + if progress_bar_refresh_rate is not None: + rank_zero_deprecation( + f"Setting `Trainer(progress_bar_refresh_rate={progress_bar_refresh_rate})` is deprecated in v1.5 and" + " will be removed in v1.7. Please pass `pytorch_lightning.callbacks.progress.ProgressBar` with" + " `refresh_rate` directly to the Trainer's `callbacks` argument instead." + ) + self.trainer._progress_bar_callback = self.configure_progress_bar(progress_bar_refresh_rate, process_position) # configure the ModelSummary callback diff --git a/pytorch_lightning/trainer/trainer.py b/pytorch_lightning/trainer/trainer.py index 7cabcb292622a..b0dbe77a18e0a 100644 --- a/pytorch_lightning/trainer/trainer.py +++ b/pytorch_lightning/trainer/trainer.py @@ -137,7 +137,7 @@ def __init__( tpu_cores: Optional[Union[List[int], str, int]] = None, ipus: Optional[int] = None, log_gpu_memory: Optional[str] = None, - progress_bar_refresh_rate: Optional[int] = None, + progress_bar_refresh_rate: Optional[int] = None, # TODO: remove in v1.7 overfit_batches: Union[int, float] = 0.0, track_grad_norm: Union[int, float, str] = -1, check_val_every_n_epoch: int = 1, @@ -284,6 +284,11 @@ def __init__( 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.). + .. deprecated:: v1.5 + ``progress_bar_refresh_rate`` has been deprecated in v1.5 and will be removed in v1.7. + Please pass :class:`~pytorch_lightning.callbacks.progress.ProgressBar` with ``refresh_rate`` + directly to the Trainer's ``callbacks`` argument instead. + profiler: To profile individual steps during training and assist in identifying bottlenecks. overfit_batches: Overfit a fraction of training data (float) or a set number of batches (int). diff --git a/tests/deprecated_api/test_remove_1-7.py b/tests/deprecated_api/test_remove_1-7.py index 25ab1ea5fd3cc..2fa8f96e77148 100644 --- a/tests/deprecated_api/test_remove_1-7.py +++ b/tests/deprecated_api/test_remove_1-7.py @@ -227,6 +227,11 @@ def test_v1_7_0_deprecate_add_get_queue(tmpdir): trainer.fit(model) +def test_v1_7_0_progress_bar_refresh_rate_trainer_constructor(tmpdir): + with pytest.deprecated_call(match=r"Setting `Trainer\(progress_bar_refresh_rate=1\)` is deprecated in v1.5"): + _ = Trainer(progress_bar_refresh_rate=1) + + def test_v1_7_0_lightning_logger_base_close(tmpdir): logger = CustomLogger() with pytest.deprecated_call(