Helium icon indicating copy to clipboard operation
Helium copied to clipboard

[Bug] Problem with tqdm

Open AlexPublicProfile opened this issue 4 years ago • 6 comments

One of the most important packages for Jupyter does not work correctly in Helium. Each update of the progress bar is drawn on a new line. This is due to incorrect processing of the CR character.

AlexPublicProfile avatar Oct 08 '21 21:10 AlexPublicProfile

If you give me a MWE (or not working in this case), I can look into it.

cgahr avatar Oct 09 '21 07:10 cgahr

tqdm home: https://github.com/tqdm/tqdm MWE:

from tqdm import tqdm
for i in tqdm(range(1000000)): pass

This works correctly in any normal console. But with Helium we get:

(stderr):
<CR>  0%|          | 0/1000000 [00:00<?, ?it/s]
(stderr):
<CR> 41%|████▏     | 412639/1000000 [00:00<00:00, 4126157.83it/s]
(stderr):
<CR> 92%|█████████▏| 916578/1000000 [00:00<00:00, 4663179.90it/s]
(stderr):
<CR>100%|██████████| 1000000/1000000 [00:00<00:00, 4629367.31it/s]
(stderr):

AlexPublicProfile avatar Oct 10 '21 04:10 AlexPublicProfile

But you can consider a simpler example. This code:

print('1\r2')

should print 2 rather than 1<CR>2

AlexPublicProfile avatar Oct 10 '21 04:10 AlexPublicProfile

Thanks. If you also send me your Helium config file, I can look into it.

cgahr avatar Oct 10 '21 18:10 cgahr

There is nothing interesting there:

{
	"complete": false,
	"output_code": true,
	"jupyter_path": "C:/SDK/Python/share/jupyter"
}

AlexPublicProfile avatar Oct 10 '21 19:10 AlexPublicProfile

A similar bug is described in https://github.com/nteract/hydrogen/issues/466.

The main problem right now is that we don't handle text streams in a way that supports overwriting the previous line as is done by tqdm. While this is definitely a bug, right now I don't have the time to fix it, since this would most likely include a partial rewrite of the code displaying and printing outputs. Since something like this is planned anyways, this will not be fixed right now.

Sorry!

cgahr avatar Oct 12 '21 08:10 cgahr