hyperdash-sdk-py icon indicating copy to clipboard operation
hyperdash-sdk-py copied to clipboard

tqdm progress bar does not show up

Open miguelvr opened this issue 7 years ago • 8 comments

information outputted by TQDM is not outputted when the script is run together with hyperdash.

miguelvr avatar Aug 09 '17 13:08 miguelvr

Could you provide a little more feedback here and maybe a sample script?

This script works for me:

import time

from tqdm import *
from hyperdash import monitor


@monitor("test tqdm")
def main():
    for i in tqdm(range(1000)):
        time.sleep(0.01)
main()

richardartoul avatar Aug 10 '17 00:08 richardartoul

Running this with hyperdash prevents the progress bar to appear. It appears in the app, after the script finishes, but not in the terminal. It should be related to the output of the progress bar being sent to stderr.

The ideal behaviour would be to allow the pbar to be printed in the terminal, and visualize the same thing in the app. And if the progress bar flushes in the terminal, the app should do too, otherwise the log will get clogged really quickly.

from tqdm import tqdm
import time

for i in xrange(5):
    for j in tqdm(xrange(10), leave=False):
        time.sleep(0.5)

    print i

miguelvr avatar Aug 10 '17 09:08 miguelvr

Ok I've isolated the issue. The feature works fine if you're using the @monitor decorator, but it doesn't work as expected when using hyperdash run let me investigate that

richardartoul avatar Aug 10 '17 23:08 richardartoul

@miguelvr Sorry I closed this issue slightly prematurely.

#67 Should have resolved this issue. Do you mind upgrading hyperdash and trying it out?

pip install --upgrade hyperdash should do it otherwise

pip uninstall hyperdash
pip install hyperdash --no-cache-dir

Also note the solution I came up with isn't 100% perfect. There is still buffering on the CLI side so if you have a TQDM bar that updates super rapidly the buffering from the CLI will make it look like its updating less frequently (I.E the progress bar fills less smoothly).

I also found an edge case where if the TQDM bar updates thousands of times per second you can generates logs large enough to crash the mobile app really quickly. This is an issue on our mobile app that we need to fix, but I think its an unlikely edgecase as you'd have to set the tqdm mininterval to a really really low value to trigger it.

Let me know if it works for you!

richardartoul avatar Aug 12 '17 22:08 richardartoul

The regular prints of my code now are different (not in a good way):

1 . The look of the progressbar changed 2. Random integers appear as the bar moves 3. I'm using the option to flush the bar and it doesn't anymore and therefore the prints after are also messed up.

Plus, I think your app should keep up with the terminal flushing behaviour. Using a progress bar just clogs the screen. It would be nice to see the pbar as it evolves but having it disappear from the log just as it happens in the terminal.

miguelvr avatar Aug 14 '17 09:08 miguelvr

Hey @miguelvr

There's not much I can do about the look of the progressbar / random integers appearing. The TQDM library detects that its hooked up to a pipe instead of a TTY and changes its behavior. I could probably dig into that more but it seems like a lower priority task right now.

When you say flush, do you mean the "leave" keyword arg? I notice as well that this has slightly weird behavior when using Hyperdash, but I'm not 100% certain why.

Regarding the app behaving similar to a terminal, we agree and we have an issue tracking that here: https://github.com/hyperdashio/hyperdash-sdk-py/issues/53

richardartoul avatar Aug 15 '17 06:08 richardartoul

I am using tqdm_notebook, i not getting any progress bar, but instead getting

HBox(children=(IntProgress(value=0, max=3), HTML(value='')))

Dont know what's the reason?

lumliolum avatar Aug 15 '18 06:08 lumliolum

I am using tqdm_notebook, i not getting any progress bar, but instead getting

HBox(children=(IntProgress(value=0, max=3), HTML(value='')))

Dont know what's the reason?

Same thing here, using Jupyterlab. No idea how to make it work. tqdm 4.28.1, jupyterlab 0.7.1

CarloNicolini avatar Dec 07 '18 11:12 CarloNicolini