Skip to content

Conversation

deependujha
Copy link
Collaborator

@deependujha deependujha commented Jul 30, 2025

What does this PR do?

closes #21009

Recent Rich versions replaced the internal _live attribute with _live_stack (a list) to support nested Live displays.
This change broke our existing call to self._console.clear_live(), which now only pops one Live instance instead of fully clearing.

This PR updates the clearing logic to:

  • Detect whether _live_stack exists (new Rich) and clear it directly.
  • Fall back to clear_live() for older Rich versions.

Ensures compatibility across both old and new Rich versions, restoring correct progress bar clearing behavior in CI and live runs.

https://github.com/Textualize/rich/pull/3768/files#diff-8f507d88f3d034716fad069c6a73da25e2915a216a2bdda6db2e8d0c13a0020a

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--21016.org.readthedocs.build/en/21016/

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Jul 30, 2025
@deependujha deependujha changed the title fix: progress bar console clearing for latest Rich release fix ci: progress bar console clearing for latest Rich release Jul 30, 2025
@deependujha
Copy link
Collaborator Author

@Borda Could you please review this PR?
It addresses the main branch CI failures, and merging it should restore CI to green.

@deependujha
Copy link
Collaborator Author

deependujha commented Aug 3, 2025

This PR is dependent on Textualize/rich#3811.

  • If that PR is merged first, this PR can be closed, as its primary goal is to handle the breaking change.
  • If not, the changes introduced here can be removed after Textualize/rich#3811 is merged.

@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Aug 4, 2025
@deependujha
Copy link
Collaborator Author

deependujha commented Aug 4, 2025

this is the current code:

if len(getattr(self._console, "_live_stack", [])) > 0:
    self._console.clear_live()
else:
    self._console.clear_live()

so basically calling clear_live irrespective of condition.


the logic was:

  • if no attribute _live_stack: means, using earlier version, then call clear_live() always as before.
  • else, means, latest breaking version, so only call clear_live() if len > 0. Else, pop from empty array will raise error.

cc: @Borda @bhimrazy

@Borda Borda requested a review from bhimrazy August 4, 2025 11:07
@deependujha deependujha merged commit 9e6b3d6 into Lightning-AI:master Aug 4, 2025
101 of 102 checks passed
@deependujha deependujha deleted the fix/ci-rich-progress-bar branch August 4, 2025 13:36
Borda pushed a commit that referenced this pull request Aug 13, 2025
* fix ci test failures due to rich progress bar

* update

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

Co-authored-by: Jirka Borovec <[email protected]>

* update

* Apply suggestions from code review

* bump rich

* Apply suggestions from code review

Co-authored-by: Deependu <[email protected]>

* update

* Apply suggestions from code review

* rev

* chlog

---------

Co-authored-by: Jirka Borovec <[email protected]>
Co-authored-by: Jirka B <[email protected]>

(cherry picked from commit 9e6b3d6)
Borda pushed a commit that referenced this pull request Aug 13, 2025
* fix ci test failures due to rich progress bar

* update

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

Co-authored-by: Jirka Borovec <[email protected]>

* update

* Apply suggestions from code review

* bump rich

* Apply suggestions from code review

Co-authored-by: Deependu <[email protected]>

* update

* Apply suggestions from code review

* rev

* chlog

---------

Co-authored-by: Jirka Borovec <[email protected]>
Co-authored-by: Jirka B <[email protected]>

(cherry picked from commit 9e6b3d6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file pl Generic label for PyTorch Lightning package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants