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

textbase tqdm bar does not display correctly #15701

Open
ydmykr opened this issue May 21, 2024 · 8 comments
Open

textbase tqdm bar does not display correctly #15701

ydmykr opened this issue May 21, 2024 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug ipywidgets Rendering, loading, saving, anything to do with IPyWidgets upstream-other Cause by some other upstream package/app

Comments

@ydmykr
Copy link

ydmykr commented May 21, 2024

Here's the codes:

from time import sleep
from tqdm import tqdm

for i in tqdm(range(100)):
    for j in tqdm(range(10), leave=False):
        sleep(0.1)

When running in the terminal, it shows correctly. It returns two progress bars, one for theiand one for the j in the loop.

However, when running in the jupyter notebook or Interactive Window, only the outermost i loop is displayed, and the progress bar of the j loop contained therein is not displayed.

@ydmykr ydmykr added the bug Issue identified by VS Code Team member as probable bug label May 21, 2024
@ydmykr
Copy link
Author

ydmykr commented May 21, 2024

@DonJayamanne
Copy link
Contributor

Looks like something broke in tqdm, as this doesn't work properly in Jupyter lab either (though different issues).

Image

@DonJayamanne DonJayamanne added ipywidgets Rendering, loading, saving, anything to do with IPyWidgets upstream-other Cause by some other upstream package/app labels Jul 22, 2024
@DonJayamanne
Copy link
Contributor

DonJayamanne commented Aug 1, 2024

@ydmykr
As a work around, try using from tqdm.notebook import tqdm instead of from tqdm import tqdm

Personal Notes

Python code used

from time import sleep
from tqdm import tqdm
# from tqdm.notebook import tqdm

for i in tqdm(range(2)):
    for j in tqdm(range(5), leave=False):
        sleep(1.1)

This produced the following outputs,
and then when used in VSCode

Tested the following code in vscode to compress the outputs using compressOutputItemStreams
The outputs are as expected.
I.e. compression works correctly.
Also found that while debugging Jupyter extension, when the output is sent out slowly to VS Code,
then we can see the right outputs, i.e. we can see two lines (as expected)

Looks like some race condition in displaying the outputs or the like.

const lines = [
	"\r  0%|          | 0/2 [00:00<?, ?it/s]",
	"\n",
	"\r  0%|          | 0/5 [00:00<?, ?it/s]",
	"\u001b[A",
	"\n",
	"\r 20%|██        | 1/5 [00:00<00:00,  9.59it/s]",
	"\u001b[A",
	"\n",
	"\r 40%|████      | 2/5 [00:00<00:00,  9.48it/s]",
	"\u001b[A",
	"\n",
	"\r 60%|██████    | 3/5 [00:00<00:00,  9.57it/s]",
	"\u001b[A",
	"\n",
	"\r 80%|████████  | 4/5 [00:00<00:00,  9.49it/s]",
	"\u001b[A",
	"\n",
	"\r100%|██████████| 5/5 [00:00<00:00,  9.55it/s]",
	"\u001b[A",
	"\n",
	"\r                                             ",
	"\u001b[A",
	"\r 50%|█████     | 1/2 [00:00<00:00,  1.90it/s]",
	"\n",
	"\r  0%|          | 0/5 [00:00<?, ?it/s]",
	"\u001b[A",
	"\n",
	"\r 20%|██        | 1/5 [00:00<00:00,  9.72it/s]",
	"\u001b[A",
	"\n",
	"\r 40%|████      | 2/5 [00:00<00:00,  9.55it/s]",
	"\u001b[A",
	"\n",
	"\r 60%|██████    | 3/5 [00:00<00:00,  9.39it/s]",
	"\u001b[A",
	"\n",
	"\r 80%|████████  | 4/5 [00:00<00:00,  8.84it/s]",
	"\u001b[A",
	"\n",
	"\r100%|██████████| 5/5 [00:00<00:00,  9.14it/s]",
	// "\u001b[A",
	"\n",
	"\r                                             ",
	"\u001b[A",
	"\r100%|██████████| 2/2 [00:01<00:00,  1.86it/s]",
	"\r100%|██████████| 2/2 [00:01<00:00,  1.86it/s]",
	"\n",

];

let result = valueBytesFromString("");
let value = "";
lines.forEach((line) => {
	result = compressOutputItemStreams([result.buffer, valueBytesFromString(line).buffer]).data;
	value = result.buffer.toString();
	console.log(value);
});
value = result.buffer.toString().toString();

@DonJayamanne DonJayamanne added the papercut 🩸 Something affecting the productivity of the team label Aug 1, 2024
@DonJayamanne
Copy link
Contributor

WORK AROUND

import tqdm.notebook instead of tqdm
I.e.

from time import sleep
from tqdm.notebook import tqdm

for i in tqdm(range(100)):
    for j in tqdm(range(10), leave=False):
        sleep(0.1)

@Jorritboer
Copy link

Thank you for looking into this (minor) issue.
The workaround doesn't seem to work for me either however.

Schermopname.2024-08-02.om.13.30.03.mov

@b-a0
Copy link

b-a0 commented Aug 20, 2024

The workaround works for me in VS Code on Windows:

tqdm

Version info:

vs code:

Version: 1.92.0 (system setup)
Commit: b1c0a14de1414fcdaa400695b4db1c0799bc3124
Date: 2024-07-31T23:26:45.634Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.20348

conda environment:

- python=3.9.19
- ipython=7.33.0
- tqdm=4.66.5

@DonJayamanne DonJayamanne removed the papercut 🩸 Something affecting the productivity of the team label Aug 20, 2024
@DonJayamanne DonJayamanne changed the title tqdm loading bar display lost textbase tqdm bar does not display correctly Aug 20, 2024
@cceyda
Copy link

cceyda commented Sep 5, 2024

tqdm has been really unreliable on vscode notebooks lately, it stops working suddenly, like it will render on previous cell and will stop working at next cell 🤷 not sure if issue with ipywidgets,tqdm or vscode.
For today the issue seems happen while using remote kernels only and I can't get rich progress bar to render either, so not a tqdm issue this time

@DonJayamanne
Copy link
Contributor

For today the issue seems happen while using remote kernels only and I can't get rich progress bar to render either, so not a tqdm issue this time

Sorry you are running into this and thank you for sharing this information.
If you are using the widgets, then please can you file a new issue, as this issue focuses on non-widgtets (text based)
Please do share the information required to repro this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug ipywidgets Rendering, loading, saving, anything to do with IPyWidgets upstream-other Cause by some other upstream package/app
Projects
None yet
Development

No branches or pull requests

5 participants