Skip to content

Commit 491e4a2

Browse files
Deprecate progress_bar_refresh_rate from Trainer constructor (#9616)
1 parent 86dd318 commit 491e4a2

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
257257
- Deprecated `LightningLoggerBase.close`, `LoggerCollection.close` in favor of `LightningLoggerBase.finalize`, `LoggerCollection.finalize` ([#9422](https://github.com/PyTorchLightning/pytorch-lightning/pull/9422))
258258

259259

260+
- 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))
261+
260262

261263
### Removed
262264

pytorch_lightning/trainer/connectors/callback_connector.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ def on_trainer_init(
7474
" in v1.7. Please pass `pytorch_lightning.callbacks.progress.ProgressBar` with"
7575
" `process_position` directly to the Trainer's `callbacks` argument instead."
7676
)
77+
78+
if progress_bar_refresh_rate is not None:
79+
rank_zero_deprecation(
80+
f"Setting `Trainer(progress_bar_refresh_rate={progress_bar_refresh_rate})` is deprecated in v1.5 and"
81+
" will be removed in v1.7. Please pass `pytorch_lightning.callbacks.progress.ProgressBar` with"
82+
" `refresh_rate` directly to the Trainer's `callbacks` argument instead."
83+
)
84+
7785
self.trainer._progress_bar_callback = self.configure_progress_bar(progress_bar_refresh_rate, process_position)
7886

7987
# configure the ModelSummary callback

pytorch_lightning/trainer/trainer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(
135135
tpu_cores: Optional[Union[List[int], str, int]] = None,
136136
ipus: Optional[int] = None,
137137
log_gpu_memory: Optional[str] = None,
138-
progress_bar_refresh_rate: Optional[int] = None,
138+
progress_bar_refresh_rate: Optional[int] = None, # TODO: remove in v1.7
139139
overfit_batches: Union[int, float] = 0.0,
140140
track_grad_norm: Union[int, float, str] = -1,
141141
check_val_every_n_epoch: int = 1,
@@ -282,6 +282,11 @@ def __init__(
282282
Ignored when a custom progress bar is passed to :paramref:`~Trainer.callbacks`. Default: None, means
283283
a suitable value will be chosen based on the environment (terminal, Google COLAB, etc.).
284284
285+
.. deprecated:: v1.5
286+
``progress_bar_refresh_rate`` has been deprecated in v1.5 and will be removed in v1.7.
287+
Please pass :class:`~pytorch_lightning.callbacks.progress.ProgressBar` with ``refresh_rate``
288+
directly to the Trainer's ``callbacks`` argument instead.
289+
285290
profiler: To profile individual steps during training and assist in identifying bottlenecks.
286291
287292
overfit_batches: Overfit a fraction of training data (float) or a set number of batches (int).

tests/deprecated_api/test_remove_1-7.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ def test_v1_7_0_deprecate_add_get_queue(tmpdir):
227227
trainer.fit(model)
228228

229229

230+
def test_v1_7_0_progress_bar_refresh_rate_trainer_constructor(tmpdir):
231+
with pytest.deprecated_call(match=r"Setting `Trainer\(progress_bar_refresh_rate=1\)` is deprecated in v1.5"):
232+
_ = Trainer(progress_bar_refresh_rate=1)
233+
234+
230235
def test_v1_7_0_lightning_logger_base_close(tmpdir):
231236
logger = CustomLogger()
232237
with pytest.deprecated_call(

0 commit comments

Comments
 (0)