Skip to content
Merged
2 changes: 1 addition & 1 deletion requirements/pytorch/extra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ matplotlib>3.1, <3.10.0
omegaconf >=2.2.3, <2.4.0
hydra-core >=1.2.0, <1.4.0
jsonargparse[signatures,jsonnet] >=4.39.0, <4.41.0
rich >=12.3.0, <14.1.0
rich >=12.3.0, <14.2.0
tensorboardX >=2.2, <2.7.0 # min version is set by torch.onnx missing attribute
bitsandbytes >=0.45.2,<0.47.0; platform_system != "Darwin"
2 changes: 1 addition & 1 deletion src/lightning/pytorch/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Fixed

-
- fix progress bar console clearing for Rich `14.1+` ([#21016](https://github.com/Lightning-AI/pytorch-lightning/pull/21016))


---
Expand Down
14 changes: 13 additions & 1 deletion src/lightning/pytorch/callbacks/progress/rich_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,19 @@ def _init_progress(self, trainer: "pl.Trainer") -> None:
self._reset_progress_bar_ids()
reconfigure(**self._console_kwargs)
self._console = get_console()
self._console.clear_live()

# Compatibility shim for Rich >= 14.1.0:
if hasattr(self._console, "_live_stack"):
# In recent Rich releases, the internal `_live` variable was replaced with `_live_stack` (a list)
# to support nested Live displays. This broke our original call to `clear_live()`,
# because it now only pops one Live instance instead of clearing them all.
# We check for `_live_stack` and clear it manually for compatibility across
# both old and new Rich versions.
if len(self._console._live_stack) > 0:
self._console.clear_live()
else:
self._console.clear_live()

self._metric_component = MetricsTextColumn(
trainer,
self.theme.metrics,
Expand Down
Loading