Skip to content

Commit

Permalink
Raise exception if rich is less than 10.2.2 (#10839)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushikb11 authored Dec 1, 2021
1 parent f7c15f2 commit ec0fb2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Disabled batch_size extraction for torchmetric instances because they accumulate the metrics internally ([#10815](https://github.com/PyTorchLightning/pytorch-lightning/pull/10815))


- Improved exception message if `rich` version is less than `10.2.2` ([#10839](https://github.com/PyTorchLightning/pytorch-lightning/pull/10839))


## [1.5.4] - 2021-11-30

### Fixed
Expand Down
8 changes: 5 additions & 3 deletions pytorch_lightning/callbacks/progress/rich_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from typing import Any, Optional, Union

from pytorch_lightning.callbacks.progress.base import ProgressBarBase
from pytorch_lightning.utilities import _RICH_AVAILABLE
from pytorch_lightning.utilities.exceptions import MisconfigurationException
from pytorch_lightning.utilities.imports import _RICH_AVAILABLE

Task, Style = None, None
if _RICH_AVAILABLE:
Expand Down Expand Up @@ -228,9 +229,10 @@ def __init__(
theme: RichProgressBarTheme = RichProgressBarTheme(),
) -> None:
if not _RICH_AVAILABLE:
raise ModuleNotFoundError(
"`RichProgressBar` requires `rich` to be installed. Install it by running `pip install -U rich`."
raise MisconfigurationException(
"`RichProgressBar` requires `rich` >= 10.2.2. Install it by running `pip install -U rich`."
)

super().__init__()
self._refresh_rate: int = refresh_rate
self._leave: bool = leave
Expand Down
2 changes: 1 addition & 1 deletion tests/callbacks/test_rich_progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def predict_dataloader(self):

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


Expand Down

0 comments on commit ec0fb2f

Please sign in to comment.