Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Colab (& Jupyter Lab) bug: nested bars duplicated at each iteration #625

Closed
artemisart opened this issue Oct 9, 2018 · 6 comments
Assignees
Labels
duplicate 🗐 Seen it before

Comments

@artemisart
Copy link

artemisart commented Oct 9, 2018

The output of google colab is a bit strange and it duplicate nested bars for each iteration:

from time import sleep
from tqdm import tqdm
for j in tqdm(range(3), desc='main',position=0):
    for i in tqdm(range(3), desc='inner', position=1):  # it's exactly the same output if I omit the position args
        sleep(0.1)
main:   0%|          | 0/3 [00:00<?, ?it/s]
inner:   0%|          | 0/3 [00:00<?, ?it/s]
inner:  33%|███▎      | 1/3 [00:00<00:00,  9.98it/s]
inner:  67%|██████▋   | 2/3 [00:00<00:00,  9.84it/s]
inner: 100%|██████████| 3/3 [00:00<00:00,  9.74it/s]
main:  33%|███▎      | 1/3 [00:00<00:00,  3.05it/s]
inner:   0%|          | 0/3 [00:00<?, ?it/s]
inner:  33%|███▎      | 1/3 [00:00<00:00,  9.98it/s]
inner:  67%|██████▋   | 2/3 [00:00<00:00,  9.86it/s]
inner: 100%|██████████| 3/3 [00:00<00:00,  9.69it/s]
main:  67%|██████▋   | 2/3 [00:00<00:00,  3.03it/s]
inner:   0%|          | 0/3 [00:00<?, ?it/s]
inner:  33%|███▎      | 1/3 [00:00<00:00,  9.98it/s]
inner:  67%|██████▋   | 2/3 [00:00<00:00,  9.85it/s]
inner: 100%|██████████| 3/3 [00:00<00:00,  9.77it/s]
main: 100%|██████████| 3/3 [00:00<00:00,  3.02it/s]

However forcing the position of the nested bars to 0 seem to solve the issue:

from time import sleep
from tqdm import tqdm
for j in tqdm(range(3), desc='main'):
    for i in tqdm(range(3), desc='inner', position=0):
        sleep(0.1)
inner: 100%|██████████| 3/3 [00:00<00:00,  9.89it/s]
inner: 100%|██████████| 3/3 [00:00<00:00,  9.90it/s]
inner: 100%|██████████| 3/3 [00:00<00:00,  9.90it/s]
main: 100%|██████████| 3/3 [00:00<00:00,  3.25it/s]

Version

> import tqdm, sys
> print(tqdm.__version__, sys.version, sys.platform)
4.26.0 3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0] linux

So is this the expected behaviour ? Could the position be automatically forced to 0 if the env is a notebook ?
For long iterations it can crash the browser tab (both Firefox and Chrome) because the bar is duplicated thousands of times and google colab output display must not be that optimized.

EDIT: in fact the issue is not only on google colab, I am able to reproduce the same outputs in jupyter lab & notebook.

@artemisart artemisart changed the title Google Colab (& Jupyter Lab): bug nested bars duplicated at each iteration Google Colab (& Jupyter Lab) bug: nested bars duplicated at each iteration Oct 9, 2018
@casperdcl casperdcl self-assigned this Oct 13, 2018
@casperdcl casperdcl added the duplicate 🗐 Seen it before label Oct 13, 2018
@casperdcl
Copy link
Sponsor Member

duplicate of #558

@artemisart
Copy link
Author

This is clearly not a duplicate as #558 is about tqdm_notebook with js widgets and the bug I encounter is about text (stdout) tqdm. And yes I searched for similar issues before posting this but I found nothing related to my problem.

@casperdcl
Copy link
Sponsor Member

Ah I see this is more like #428

@casperdcl
Copy link
Sponsor Member

@artemisart
Copy link
Author

Indeed, but #428 doesn't provide an output example so I cannot really compare.
So is the problem "expected" for text output in notebooks ? Could tqdm detects that the output is a cell in a notebook and force position=0 ?

@casperdcl
Copy link
Sponsor Member

forcing position=0 would overwrite bars on top of each other, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate 🗐 Seen it before
Projects
None yet
Development

No branches or pull requests

2 participants