Replies: 2 comments 2 replies
-
from rich.progress import Progress
with Progress() as pb:
t1 = pb.add_task('inner', total=10)
t2 = pb.add_task('outer', total=100)
for i in range(100):
for j in range(10):
print(f"Verbose info! {i, j}")
sleep(0.1)
pb.update(task_id=t1, advance1)
pb.update(task_id=t2, advance=1) Something like this? |
Beta Was this translation helpful? Give feedback.
1 reply
-
#!/usr/bin/env python3
from rich.progress import Progress
from time import sleep
with Progress() as pb:
t1 = pb.add_task('inner', total=10)
t2 = pb.add_task('outer', total=100)
for i in range(100):
for j in range(10):
print(f"Verbose info! {i, j}")
sleep(0.1)
pb.update(task_id=t1, completed=j + 1)
pb.update(task_id=t2, completed=i + 1) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi - I'd love to switch from using
tqdm
for tracking progress to usingrich
.Is there a simple recipe for tracking progress over several nested iterables?
I frequently have several nested loops going, and I'd like to keep their progress bars at the bottom while also printing verbose debug info above. It seems that this layout is definitely a good use case for rich.
Here's the typical code I use for
tqdm
:If no printing occurs, this works great and makes it possible to track progress of nested tasks without any development overhead. However, if you uncomment the print statement, you can see that this makes the output very ugly.
As a newbie to rich, I would have naively loved to simply do:
This or a similar recipe would totally serve my use case (tracking nested progress, code is still simple), but
rich.progress.track
currently cannot be nested.I found this example from the docs that demonstrates having multiple bars, but I can't quite see how to adapt this to my situation without adding substantially more code, and I'm wondering if there is a simpler approach.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions