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

AttributeError: 'Tqdm' object has no attribute 'sp' #2442

Closed
efiop opened this issue Aug 27, 2019 · 18 comments
Closed

AttributeError: 'Tqdm' object has no attribute 'sp' #2442

efiop opened this issue Aug 27, 2019 · 18 comments
Assignees
Labels
bug Did we break something? p1-important Important, aka current backlog of things to do research

Comments

@efiop
Copy link
Member

efiop commented Aug 27, 2019

From https://travis-ci.com/iterative/dvc/jobs/228530997 #2428

------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/iterative/dvc/dvc/remote/base.py", line 447, in upload
    no_progress_bar=no_progress_bar,
  File "/home/travis/build/iterative/dvc/dvc/remote/oss.py", line 114, in _upload
    to_info.path, from_file, progress_callback=pbar.update_to
  File "/home/travis/virtualenv/python2.7.15/lib/python2.7/site-packages/tqdm/_tqdm.py", line 1015, in __exit__
    self.close()
  File "/home/travis/virtualenv/python2.7.15/lib/python2.7/site-packages/tqdm/_tqdm.py", line 1202, in close
    self._decr_instances(self)
  File "/home/travis/virtualenv/python2.7.15/lib/python2.7/site-packages/tqdm/_tqdm.py", line 536, in _decr_instances
    inst.clear(nolock=True)
  File "/home/travis/virtualenv/python2.7.15/lib/python2.7/site-packages/tqdm/_tqdm.py", line 1240, in clear
    self.sp('')
AttributeError: 'Tqdm' object has no attribute 'sp'
------------------------------------------------------------

@casperdcl Could you please take a look?

@efiop efiop added bug Did we break something? p1-important Important, aka current backlog of things to do labels Aug 27, 2019
@casperdcl casperdcl self-assigned this Aug 27, 2019
@casperdcl
Copy link
Contributor

I think this is an ignorable error caused by the trace's attempt to print a tqdm bar which has been closed. The actual error happens earlier at https://travis-ci.com/iterative/dvc/jobs/228530997#L2853 I think

@efiop
Copy link
Member Author

efiop commented Aug 27, 2019

@casperdcl The line you've linked is a wrapper that collects all the errors that happened in the workers when they are not able to upload/download something, which is a rather frequent occurrence in dvc. Is there any way we could handle that situation gracefully with tqdm? That no attribute seems like a bug.

@casperdcl
Copy link
Contributor

ah the error is https://travis-ci.com/iterative/dvc/jobs/228530997#L2622

Hmm not sure about how to clean this up in tqdm, as sp is an attribute which is definitely created in its __init__. In fact there are also 2 locations in tqdm which raise a warning if sp is not defined.

@efiop
Copy link
Member Author

efiop commented Aug 27, 2019

ah the error is https://travis-ci.com/iterative/dvc/jobs/228530997#L2622

That one is actually unrelated. It is about ssh, while the one we are discussing is about oss.

It seems weird that it throws an attribute error when something unrelated to the progress bar itself fails. It looks like if anything within with Tqdm raises an error, tqdm is not able to handle that gracefully. It should instead clearup the progress bar or something and definitely not throw attribute errors, right?

@casperdcl
Copy link
Contributor

yes I think that's tqdm/tqdm#548 - nobody's posted a solution yet

@efiop
Copy link
Member Author

efiop commented Aug 27, 2019

@casperdcl Some uploads/downloads failing is a normal situation for us (e.g. someone dvc pulling while on unstable network on a train or something), so we'll need to fix that.

@casperdcl
Copy link
Contributor

hmm I've just pushed a commit to tqdm:devel. Does using pip install -e git+https://github.com/tqdm/tqdm.git@devel#egg=tqdm fix this issue?

@casperdcl
Copy link
Contributor

@efiop it would be great if you could post a minimal reproducible example of this. I've tried and can't get the same error.

@efiop
Copy link
Member Author

efiop commented Aug 28, 2019

@casperdcl Not able to reproduce with other remotes or with a minimal example without threads. Probably a race condition or something.

@casperdcl
Copy link
Contributor

@efiop I've tried to reproduce with threads and still couldn't manage.

from __future__ import print_function
from tqdm import tqdm, trange
from concurrent.futures import ThreadPoolExecutor

N = int(1e7)

def fun(N):
    try:
        with trange(N, desc="1", leave=False) as t:
            for i in t:
                if i == N // 10:
                    break
    except:
        with trange(N, desc="2", leave=False) as t:
            for i in t:
                if i == N // 10:
                    raise ValueError("fun times")
    else:
        with trange(N, desc="3", leave=False) as t:
            for i in t:
                if i == N // 10:
                    raise ValueError("fun times")


tqdm.get_lock()
with ThreadPoolExecutor(max_workers=8) as executor:
    executor.map(fun, [N] * 400)

@efiop
Copy link
Member Author

efiop commented Aug 28, 2019

@casperdcl I see, well, races are always hard to reliably reproduce :) The fix from devel branch seems like an acceptable workaround, do you plan on merging it into master? If you do, then we could close this issue as well.

@casperdcl
Copy link
Contributor

casperdcl commented Aug 28, 2019

doesn't have to be perfectly reliable, but at least being able to reproduce once would help.

I'm hesitant to merge that devel commit into master considering nobody else seems to have reported this issue, and it doesn't seem like you've managed to reproduce it either. did it happen more than once on travis?

casperdcl referenced this issue in tqdm/tqdm Aug 28, 2019
@efiop
Copy link
Member Author

efiop commented Aug 28, 2019

@casperdcl True, it was the first and the last time I've seen it so far. It was also on 2.7, which might be related. Alright, let's close this one and if it ever happens again, we could get back to it.

@efiop efiop closed this as completed Aug 28, 2019
@efiop
Copy link
Member Author

efiop commented Nov 16, 2019

Getting it once again on py2 https://travis-ci.com/iterative/dvc/jobs/255935049#L3369

@efiop
Copy link
Member Author

efiop commented Nov 16, 2019

@casperdcl What do you think? If this takes any effort, we can just forget about this, as py2 is almost dead anyways.

@efiop efiop reopened this Nov 16, 2019
@casperdcl
Copy link
Contributor

casperdcl commented Nov 16, 2019

@efiop is this the actual error? https://travis-ci.com/iterative/dvc/jobs/255935049#L2554

Not sure how the trace output is set up. Don't know if for example there's another error but the printing of said error on a killed thread is also causing a different error on L3369...

@efiop
Copy link
Member Author

efiop commented Nov 16, 2019

@casperdcl Not seeing any other error, seems like it is the cause.

@efiop
Copy link
Member Author

efiop commented Dec 29, 2019

Will be fixed by #1818

@efiop efiop closed this as completed Dec 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Did we break something? p1-important Important, aka current backlog of things to do research
Projects
None yet
Development

No branches or pull requests

2 participants