fix: Replace Halo with rich for CLI spinner and progress tracking#256
Merged
Conversation
mercuryseries
approved these changes
Jan 27, 2025
mercuryseries
left a comment
Contributor
There was a problem hiding this comment.
Thanks, @jstlaurent, for tackling this over your busy weekend! 😉
I think this is the right call. I looked into this after issue #255 and was leaning towards Rich as well. Added a few minor comments here and there, nothing major!
cwognum
approved these changes
Jan 27, 2025
cwognum
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @jstlaurent !
Could you show a screenshot of what it now looks like?
Co-authored-by: Honoré Hounwanou <mercuryseries@gmail.com>
Co-authored-by: Honoré Hounwanou <mercuryseries@gmail.com>
Collaborator
|
Thanks for the screenshot @jstlaurent ! Looks great to me! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelogs
Adresses issue #255
Preview
Checklist:
Add tests to cover the fixed bug(s) or the newly introduced feature(s) (if appropriate).Update the API documentation if a new function is added, or an existing one is deleted.feature,fix,chore,documentationortest(or ask a maintainer to do it for you).When used in iPython, Halo raises an exception. The bug has been patched in their repo secven months ago, but no new release has been created since. The last release is more than four years old.
In order to fix this, I elected to use rich, a CLI formatting library that has progress trackers. It is up-to-date and well maintained. I replaced the
ProgressIndicatorclass with a context manager function that wraps aProgressobject fromrich. In addition to a spinner, we also get progress bars. By using a ContextVar, we can nest multipletrack_progresscontext manager, to track multiple tasks.In order not to break the visual output in the CLI, I also used the logging handler provided by
rich, replacing the Loguru library we had been using. I also took the opportunity to scope the logging configuration to the Polaris library logging only, to avoid changing any config the user might have set up in their code.