ProgressMeter.jl icon indicating copy to clipboard operation
ProgressMeter.jl copied to clipboard

Add support for multiple simultaneous progress bars

Open jishnub opened this issue 5 years ago • 5 comments

Sometimes I would like to track two tasks simultaneously. Something like this doesn't work

julia> using ProgressMeter

julia> p1 = Progress(10,1,"a");

julia> p2 = Progress(10,1,"b");

julia> for i = 1:2
       next!(p1)
       next!(p2)
       end
b 10%|██████████▍                   |  ETA: 0:00:42

In this case the second bar overwrites the first. Would it be possible to create a container of bars that automatically sets the cursor location given which one is being updated, so that all are visible?

jishnub avatar May 10 '20 13:05 jishnub

it is not documented by I found this feature by chance: you can add the argument offset:

julia> p1 = Progress(10,1,"a"; offset=2);

julia> p2 = Progress(10,1,"b"; offset=1);

julia> for i = 1:10
           next!(p1)
           sleep(0.1)
           next!(p2)
           sleep(0.1)
       end

this works but will cause problems if p1 and p2 try to update at the same time

I worked on a workaround, that works with multiple workers, which I will clean and make a PR

MarcMush avatar May 22 '20 14:05 MarcMush

@MarcMush is this still active? I have some projects that would profit a lot from multiple progress bars (nested algorithms).

oschulz avatar Apr 09 '22 18:04 oschulz

it has been in progress for a long time, but not very active, see #157 if you want to use what I wrote so far (it should be working fine), you can do

] add ProgressMeter#a5c5b2c

BUT, if you "just" need nested progress bars, that are working on a single core, you can use the offset keyword like I did in the above post

MarcMush avatar Apr 09 '22 19:04 MarcMush

Thanks - yes, all progress reporting would be collected and ProgressMeter called from a single core. I haven't managed to get the offset-"trick" working with Jupyter, though.

oschulz avatar Apr 10 '22 01:04 oschulz

It looks like it's not working with IJulia, which means my PR shouldn't work either

https://user-images.githubusercontent.com/35898736/165163043-8dde54b2-afa1-46a4-a846-571620ab08f7.mp4

you can probably open a new issue for that

MarcMush avatar Apr 25 '22 19:04 MarcMush