-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Replace fastprogress progress bars with rich #7233
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
Still some testing to do, but they appear to play nicely with Jupyter. |
I'm sure someone like @zaxtax could be fancier with the progress bar styling. Feel free to embellish! |
Also, making the progress bars work involved changing how parallel processing works in SMC sampling. Please have a close look. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7233 +/- ##
==========================================
- Coverage 92.30% 92.29% -0.02%
==========================================
Files 100 101 +1
Lines 16895 16891 -4
==========================================
- Hits 15595 15589 -6
- Misses 1300 1302 +2
|
Can we haz screenshot plz? |
I love so much of this! Looking forward to reviewing
…On Tue, 2 Apr 2024, 01:16 Chris Fonnesbeck, ***@***.***> wrote:
For SMC, since the number of iterations is not fixed I use a spinner for
each chain:
image.png (view on web)
<https://github.com/pymc-devs/pymc/assets/81476/8a7e49fa-5784-4bcb-b624-475df12d4a9a>
—
Reply to this email directly, view it on GitHub
<#7233 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACCUOSNG7AR2VGWAIJAPDY3HTCZAVCNFSM6AAAAABFPRMAVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZQG43TCMBWGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Would having a way for people to theme their progress bars be in scope? If
so I can offer some suggestions.
…On Tue, 2 Apr 2024, 01:18 Rob Zinkov, ***@***.***> wrote:
I love so much of this! Looking forward to reviewing
On Tue, 2 Apr 2024, 01:16 Chris Fonnesbeck, ***@***.***>
wrote:
> For SMC, since the number of iterations is not fixed I use a spinner for
> each chain:
>
> image.png (view on web)
> <https://github.com/pymc-devs/pymc/assets/81476/8a7e49fa-5784-4bcb-b624-475df12d4a9a>
>
> —
> Reply to this email directly, view it on GitHub
> <#7233 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAACCUOSNG7AR2VGWAIJAPDY3HTCZAVCNFSM6AAAAABFPRMAVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZQG43TCMBWGA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Yes! Feel free to point me toward relevant examples/resources. |
So there are two ways to style. For simple stuff, you can just pass in a styles to track: import time
from rich.progress import track
for i in track(range(20), description="Processing...", complete_style="rgb(83,145,210)"):
time.sleep(1) But for theming it's probably easiest to take a theme or console object and pass it to from rich.theme import Theme
custom_theme = Theme({
"bar.complete": "rgb(83,145,210)",
})
from rich.progress import Progress
from rich.console import Console
import time
with Progress(console=Console(theme=custom_theme)) as progress:
task1 = progress.add_task("[red]Downloading...", total=100)
task2 = progress.add_task("[green]Processing...", total=100)
task3 = progress.add_task("[cyan]Cooking...", total=100)
while not progress.finished:
progress.update(task1, advance=0.5)
progress.update(task2, advance=0.3)
progress.update(task3, advance=0.9)
time.sleep(0.02) The style page (https://rich.readthedocs.io/en/latest/style.html) is the best resource for styling. |
Stylistically, I associate red with error. I prefer blue to indicate normal operation, green for completion, and red for some error state. |
Can now pass custom progressbar themes to samplers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel confident in reviewing the sampling.parallel code, but otherwise looks good!
PR looks good to me. Was there any open / known issue with the old library? |
Bad at displaying more than one progress bar
AnswerDotAI/fastprogress#39
…On Wed, 3 Apr 2024, 15:12 Ricardo Vieira, ***@***.***> wrote:
PR looks good to me. Was there any open / known issue with the old library?
—
Reply to this email directly, view it on GitHub
<#7233 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACCUO3EHEQE56EALF7Y6LY3P52JAVCNFSM6AAAAABFPRMAVKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZUGU3DSMRRGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
These should be more robust progress bars by virtue of being rich text-based. Also the |
mypy is not happy |
mypy seems to be complaining about things that have nothing to do with this PR |
It looks like
|
I just say this is a fantastic addition 🙌 ! Thanks! |
Adding my thanks here!! 👏 👏 👏 🙌 |
Thanks! I'm sure they can be improved, so feel free to suggest additional changes. |
I've spotted a bug with the progressbar when PyMC is called from R via Reticulate, and have opened a bug report at both Reticulate and Rich. Mentioned them below in case you want to follow what resolution there might be:
Thanks for the extra option |
I have found the root cause for this problem with progress bars! Rstudio Console does not support cursor motion ANSI control sequences. I have opened a feature request upstream in rstudio/rstudio#14942 , as well as an associated bug report rstudio/rstudio#14941 . Meanwhile, is there a way to have some basic SMC progress bars working without cursor motion control sequences, even if in a much simpler capacity? Basically just printing out the current version of Beta and a timestamp? |
Description
This PR aims to improve the robustness of PyMC's progress bars by implementing them with the
rich
library in place offastprogress
Checklist
Type of change
📚 Documentation preview 📚: https://pymc--7233.org.readthedocs.build/en/7233/