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

tqdm.write not working as expected #683

Open
demiangomez opened this issue Feb 27, 2019 · 3 comments
Open

tqdm.write not working as expected #683

demiangomez opened this issue Feb 27, 2019 · 3 comments
Assignees
Labels
p2-bug-warning ⚠ Visual output bad question/docs ‽ Documentation clarification candidate to-fix ⌛ In progress

Comments

@demiangomez
Copy link

Both on Debian and Ubuntu, tqdm.write() is not working as expected.

Messages are written but the progress bar behaves as if I would be using print. This used to work correctly with a previous version of tqdm (4.19.4) but after installing a new server and using version 4.31.1 it now behaves like this:

-- sir.uylp -> no data for requested time window
-- sir.uyni -> no data for requested time window
-- sir.uypt -> no data for requested time window
-- sir.uyri -> no data for requested time window
99%|██████████████████████████████████████▊| 1120/1127 [01:16<00:00, 20.45it/s] -- sir.uyrv -> no data for requested time window
-- sir.uysj -> no data for requested time window
-- sir.uyta -> no data for requested time window
-- sir.valp -> no data for requested time window
100%|██████████████████████████████████████▉| 1124/1127 [01:16<00:00, 22.86it/s] -- sir.varg -> no data for requested time window
-- sir.vesl -> adding...
-- sir.vico -> no data for requested time window
100%|███████████████████████████████████████| 1127/1127 [01:18<00:00, 14.41it/s]

Note that the text starts at the end of the progress bar. I've searched the issues page but could not find anything similar. Not sure if it is relevant, but I'm running the program over ssh. Again, this work fine with the previous version I had. The code is very simple:

`for Stn in tqdm(sorted(stations), ncols=80):

    NetworkCode = Stn['NetworkCode']
    StationCode = Stn['StationCode']

    rs = cnn.query(
        'SELECT * FROM rinex_proc WHERE "NetworkCode" = \'%s\' AND "StationCode" = \'%s\' AND '
        '"ObservationSTime" >= \'%s\' AND "ObservationETime" <= \'%s\''
        % (NetworkCode, StationCode, (dates[0] - 1).first_epoch(), (dates[1] + 1).last_epoch()))

    if rs.ntuples() > 0:

        tqdm.write(' -- %s.%s -> adding...' % (NetworkCode, StationCode))
        try:
            stn_obj.append(Station(cnn, NetworkCode, StationCode, dates))

        except pyETMException:
            tqdm.write('    %s.%s -> station exists, but there was a problem initializing ETM.'
                       % (NetworkCode, StationCode))
    else:
        tqdm.write(' -- %s.%s -> no data for requested time window' % (NetworkCode, StationCode))`
@casperdcl
Copy link
Sponsor Member

is this code running in django or similar? And does downgrading just tqdm to 4.19.4 fix it?

@casperdcl casperdcl self-assigned this Mar 4, 2019
@casperdcl casperdcl added the question/docs ‽ Documentation clarification candidate label Mar 4, 2019
@demiangomez
Copy link
Author

No, I'm not using django. I can confirm that after removing version 4.31.1 and installing 4.19.4 the problem is gone.

@jccurtis
Copy link

jccurtis commented Apr 29, 2019

I can confirm a similar issue with tqdm.write on Ubuntu 18.04 and tqdm==4.31.1 duplicating the progress bar. It appears to be time dependent in python2 and not python3:

simple loop with no sleep

from tqdm import tqdm

for i in tqdm(range(5)):
    tqdm.write('Here: {}'.format(i))

python2.7

  0%|          | 0/5 [00:00<?, ?it/s]Here: 0
Here: 1
Here: 2
Here: 3
Here: 4
100%|██████████| 5/5 [00:00<00:00, 4725.44it/s]

python3.6 👍

Here: 0                                               
Here: 1                                               
Here: 2                                               
Here: 3                                               
Here: 4                                               
100%|████████████████| 5/5 [00:00<00:00, 17303.23it/s]

1 sec sleep

import time
from tqdm import tqdm

for i in tqdm(range(5)):
    tqdm.write('Here: {}'.format(i))
    time.sleep(1)

python2.7

  0%|          | 0/5 [00:00<?, ?it/s]Here: 0
 20%|██        | 1/5 [00:01<00:04,  1.00s/it]Here: 1
 40%|████      | 2/5 [00:02<00:03,  1.00s/it]Here: 2
 60%|██████    | 3/5 [00:03<00:02,  1.00s/it]Here: 3
 80%|████████  | 4/5 [00:04<00:01,  1.00s/it]Here: 4
100%|██████████| 5/5 [00:05<00:00,  1.00s/it]

python3.6 👍

Here: 0                                               
Here: 1                                               
Here: 2                                               
Here: 3                                               
Here: 4                                               
100%|███████████████████| 5/5 [00:05<00:00,  1.00s/it]

Downgrading to tqdm==4.30.0 fixes this ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-bug-warning ⚠ Visual output bad question/docs ‽ Documentation clarification candidate to-fix ⌛ In progress
Projects
None yet
Development

No branches or pull requests

3 participants