Tqdm: Nested progress bars not functioning with jupyter

Created on 18 Mar 2016  路  5Comments  路  Source: tqdm/tqdm

Hi everyone,

I love tqdm. I really like the idea of nested progress bars. I tried the example from the documentation in jupyter and it prints a new progressbar for each iteration of the inner most loop.

from tqdm import trange
from time import sleep

for i in trange(10, desc='1st loop', leave=True):
    for j in trange(5, desc='2nd loop', leave=True, nested=True):
        for k in trange(100, desc='3nd loop', leave=True, nested=True):
            sleep(0.01)

I have the following workaround when there are only two loops but it doesn't generalise.

from tqdm import trange
from time import sleep
from IPython.display import clear_output

for j in trange(5, desc='2nd loop', leave=True, nested=True):
    for k in trange(100, desc='3nd loop', leave=True, nested=True):
        sleep(0.01)
    clear_output()

Most helpful comment

Indeed the text-based nested progress bars do not work in IPython/Jupyter because Jupyter's console wrapper is limited and does not accept the positioning characters.

Anyway there is an almost finished PR to include a tqdm-notebook extension, and this one allows for nested progress bars. In fact, this was one of the main reason this PR was started.

I will try to finish it by the end of the next week, but you can already try it here:
https://github.com/tqdm/tqdm/tree/ipython-notebook2

All 5 comments

Indeed the text-based nested progress bars do not work in IPython/Jupyter because Jupyter's console wrapper is limited and does not accept the positioning characters.

Anyway there is an almost finished PR to include a tqdm-notebook extension, and this one allows for nested progress bars. In fact, this was one of the main reason this PR was started.

I will try to finish it by the end of the next week, but you can already try it here:
https://github.com/tqdm/tqdm/tree/ipython-notebook2

And don't worry, the API won't change, the only remaining changes to do are cosmetic (change bar's color if error or done, etc.).

Will be fixed by #92.

But your clear_output() idea is very interesting. We should bookmark it, maybe it can be useful later.

Merged #92. And a method refresh() similar to clear_output() was implemented in #150 and #152.

Was this page helpful?
0 / 5 - 0 ratings