Skip to content

Commit ba9e11d

Browse files
committed
refactor(Rich): Centralize _RICH_AVAILABLE and version check
Addresses a PR comment by bhimrazy regarding inconsistent _RICH_AVAILABLE checks. This commit: 1. Defines _RICH_MIN_VERSION = "10.2.2" in utilities/imports.py. 2. Updates _RICH_AVAILABLE in utilities/imports.py to use this minimum version. 3. Modifies callbacks/progress/rich_progress.py to import and use the centralized _RICH_AVAILABLE from utilities/imports.py, removing its local definition. This ensures a single source of truth for rich package availability and version checking.
1 parent d95affd commit ba9e11d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/lightning/pytorch/callbacks/progress/rich_progress.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
from typing import Any, Optional, Union, cast
1919

2020
import torch
21-
from lightning_utilities.core.imports import RequirementCache
2221
from typing_extensions import override
2322

2423
import lightning.pytorch as pl
2524
from lightning.pytorch.callbacks.progress.progress_bar import ProgressBar
25+
from lightning.pytorch.utilities.imports import _RICH_AVAILABLE
2626
from lightning.pytorch.utilities.types import STEP_OUTPUT
2727

28-
_RICH_AVAILABLE = RequirementCache("rich>=10.2.2")
29-
3028
if _RICH_AVAILABLE:
3129
from rich import get_console, reconfigure
3230
from rich.console import Console, RenderableType

src/lightning/pytorch/utilities/imports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
_OMEGACONF_AVAILABLE = package_available("omegaconf")
3030
_TORCHVISION_AVAILABLE = RequirementCache("torchvision")
31-
_RICH_AVAILABLE = RequirementCache("rich")
31+
_RICH_MIN_VERSION = "10.2.2"
32+
_RICH_AVAILABLE = RequirementCache(f"rich>={_RICH_MIN_VERSION}")
3233

3334

3435
@functools.lru_cache(maxsize=128)

0 commit comments

Comments
 (0)