Skip to content

Commit f931e27

Browse files
rschiremanRaymond G Schiremancarmocca
authored
Remove the deprecated get_progress_bar_dict (#12839)
Co-authored-by: Raymond G Schireman <raymond.schireman@uvm.edu> Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
1 parent c4bb078 commit f931e27

File tree

7 files changed

+5
-84
lines changed

7 files changed

+5
-84
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
129129

130130
- Removed deprecated `dataloader_idx` argument from `on_train_batch_start/end` hooks `Callback` and `LightningModule` ([#12769](https://github.com/PyTorchLightning/pytorch-lightning/pull/12769))
131131

132+
133+
- Removed deprecated `get_progress_bar_dict` property from `LightningModule` ([#12839](https://github.com/PyTorchLightning/pytorch-lightning/pull/12839))
134+
132135
### Fixed
133136

134137

pytorch_lightning/callbacks/progress/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def get_metrics(self, trainer, model):
220220
Return:
221221
Dictionary with the items to be displayed in the progress bar.
222222
"""
223-
standard_metrics = pl_module.get_progress_bar_dict()
223+
standard_metrics = get_standard_metrics(trainer, pl_module)
224224
pbar_metrics = trainer.progress_bar_metrics
225225
duplicates = list(standard_metrics.keys() & pbar_metrics.keys())
226226
if duplicates:

pytorch_lightning/core/lightning.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
import pytorch_lightning as pl
3434
from pytorch_lightning.callbacks.base import Callback
35-
from pytorch_lightning.callbacks.progress import base as progress_base
3635
from pytorch_lightning.core.hooks import CheckpointHooks, DataHooks, ModelHooks
3736
from pytorch_lightning.core.mixins import DeviceDtypeModuleMixin, HyperparametersMixin
3837
from pytorch_lightning.core.optimizer import LightningOptimizer
@@ -1731,35 +1730,6 @@ def unfreeze(self) -> None:
17311730

17321731
self.train()
17331732

1734-
def get_progress_bar_dict(self) -> Dict[str, Union[int, str]]:
1735-
r"""
1736-
.. deprecated:: v1.5
1737-
This method was deprecated in v1.5 in favor of
1738-
`pytorch_lightning.callbacks.progress.base.get_metrics` and will be removed in v1.7.
1739-
1740-
Implement this to override the default items displayed in the progress bar.
1741-
By default it includes the average loss value, split index of BPTT (if used)
1742-
and the version of the experiment when using a logger.
1743-
1744-
.. code-block::
1745-
1746-
Epoch 1: 4%|▎ | 40/1095 [00:03<01:37, 10.84it/s, loss=4.501, v_num=10]
1747-
1748-
Here is an example how to override the defaults:
1749-
1750-
.. code-block:: python
1751-
1752-
def get_progress_bar_dict(self):
1753-
# don't show the version number
1754-
items = super().get_progress_bar_dict()
1755-
items.pop("v_num", None)
1756-
return items
1757-
1758-
Return:
1759-
Dictionary with the items to be displayed in the progress bar.
1760-
"""
1761-
return progress_base.get_standard_metrics(self.trainer, self)
1762-
17631733
def _verify_is_manual_optimization(self, fn_name):
17641734
if self.automatic_optimization:
17651735
raise MisconfigurationException(

pytorch_lightning/trainer/configuration_validator.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ def verify_loop_configurations(trainer: "pl.Trainer") -> None:
4949

5050
__verify_dp_batch_transfer_support(trainer, model)
5151
_check_add_get_queue(model)
52-
# TODO: Delete _check_progress_bar in v1.7
53-
_check_progress_bar(model)
5452
# TODO: Delete _check_on_post_move_to_device in v1.7
5553
_check_on_post_move_to_device(model)
5654
_check_deprecated_callback_hooks(trainer)
@@ -143,20 +141,6 @@ def __verify_train_val_loop_configuration(trainer: "pl.Trainer", model: "pl.Ligh
143141
)
144142

145143

146-
def _check_progress_bar(model: "pl.LightningModule") -> None:
147-
r"""
148-
Checks if get_progress_bar_dict is overridden and sends a deprecation warning.
149-
150-
Args:
151-
model: The model to check the get_progress_bar_dict method.
152-
"""
153-
if is_overridden("get_progress_bar_dict", model):
154-
rank_zero_deprecation(
155-
"The `LightningModule.get_progress_bar_dict` method was deprecated in v1.5 and will be removed in v1.7."
156-
" Please use the `ProgressBarBase.get_metrics` instead."
157-
)
158-
159-
160144
def _check_on_post_move_to_device(model: "pl.LightningModule") -> None:
161145
r"""
162146
Checks if `on_post_move_to_device` method is overridden and sends a deprecation warning.

pytorch_lightning/trainer/trainer.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from copy import deepcopy
2424
from datetime import timedelta
2525
from pathlib import Path
26-
from typing import Any, Callable, cast, Dict, Generator, Iterable, List, Optional, Type, Union
26+
from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, Type, Union
2727
from weakref import proxy
2828

2929
import torch
@@ -2191,19 +2191,6 @@ def distributed_sampler_kwargs(self) -> Optional[dict]:
21912191
def data_parallel(self) -> bool:
21922192
return isinstance(self.strategy, ParallelStrategy)
21932193

2194-
@property
2195-
def progress_bar_dict(self) -> dict:
2196-
"""Read-only for progress bar metrics."""
2197-
rank_zero_deprecation(
2198-
"`trainer.progress_bar_dict` is deprecated in v1.5 and will be removed in v1.7."
2199-
" Use `ProgressBarBase.get_metrics` instead."
2200-
)
2201-
ref_model = self.lightning_module
2202-
ref_model = cast(pl.LightningModule, ref_model)
2203-
if self.progress_bar_callback:
2204-
return self.progress_bar_callback.get_metrics(self, ref_model)
2205-
return self.progress_bar_metrics
2206-
22072194
@property
22082195
def enable_validation(self) -> bool:
22092196
"""Check if we should run validation during training."""

tests/deprecated_api/test_remove_1-7.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,6 @@
3838
from tests.plugins.environments.test_lsf_environment import _make_rankfile
3939

4040

41-
def test_v1_7_0_moved_get_progress_bar_dict(tmpdir):
42-
class TestModel(BoringModel):
43-
def get_progress_bar_dict(self):
44-
items = super().get_progress_bar_dict()
45-
items.pop("v_num", None)
46-
return items
47-
48-
trainer = Trainer(
49-
default_root_dir=tmpdir,
50-
fast_dev_run=True,
51-
)
52-
test_model = TestModel()
53-
with pytest.deprecated_call(match=r"`LightningModule.get_progress_bar_dict` method was deprecated in v1.5"):
54-
trainer.fit(test_model)
55-
standard_metrics_postfix = trainer.progress_bar_callback.main_progress_bar.postfix
56-
assert "loss" in standard_metrics_postfix
57-
assert "v_num" not in standard_metrics_postfix
58-
59-
with pytest.deprecated_call(match=r"`trainer.progress_bar_dict` is deprecated in v1.5"):
60-
_ = trainer.progress_bar_dict
61-
62-
6341
def test_v1_7_0_deprecated_on_task_dataloader(tmpdir):
6442
class CustomBoringModel(BoringModel):
6543
def on_train_dataloader(self):

tests/trainer/logging_/test_logger_connector.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ def __init__(self, not_supported):
194194
"on_before_batch_transfer",
195195
"transfer_batch_to_device",
196196
"on_after_batch_transfer",
197-
"get_progress_bar_dict",
198197
}
199198
)
200199
# remove `nn.Module` hooks

0 commit comments

Comments
 (0)