Skip to content

Commit ec0fb2f

Browse files
authored
Raise exception if rich is less than 10.2.2 (#10839)
1 parent f7c15f2 commit ec0fb2f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
190190
- Disabled batch_size extraction for torchmetric instances because they accumulate the metrics internally ([#10815](https://github.com/PyTorchLightning/pytorch-lightning/pull/10815))
191191

192192

193+
- Improved exception message if `rich` version is less than `10.2.2` ([#10839](https://github.com/PyTorchLightning/pytorch-lightning/pull/10839))
194+
195+
193196
## [1.5.4] - 2021-11-30
194197

195198
### Fixed

pytorch_lightning/callbacks/progress/rich_progress.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from typing import Any, Optional, Union
1818

1919
from pytorch_lightning.callbacks.progress.base import ProgressBarBase
20-
from pytorch_lightning.utilities import _RICH_AVAILABLE
20+
from pytorch_lightning.utilities.exceptions import MisconfigurationException
21+
from pytorch_lightning.utilities.imports import _RICH_AVAILABLE
2122

2223
Task, Style = None, None
2324
if _RICH_AVAILABLE:
@@ -228,9 +229,10 @@ def __init__(
228229
theme: RichProgressBarTheme = RichProgressBarTheme(),
229230
) -> None:
230231
if not _RICH_AVAILABLE:
231-
raise ModuleNotFoundError(
232-
"`RichProgressBar` requires `rich` to be installed. Install it by running `pip install -U rich`."
232+
raise MisconfigurationException(
233+
"`RichProgressBar` requires `rich` >= 10.2.2. Install it by running `pip install -U rich`."
233234
)
235+
234236
super().__init__()
235237
self._refresh_rate: int = refresh_rate
236238
self._leave: bool = leave

tests/callbacks/test_rich_progress_bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def predict_dataloader(self):
8585

8686
def test_rich_progress_bar_import_error():
8787
if not _RICH_AVAILABLE:
88-
with pytest.raises(ImportError, match="`RichProgressBar` requires `rich` to be installed."):
88+
with pytest.raises(ImportError, match="`RichProgressBar` requires `rich` >= 10.2.2."):
8989
Trainer(callbacks=RichProgressBar())
9090

9191

0 commit comments

Comments
 (0)