dvc: AttributeError: 'Tqdm' object has no attribute 'sp'

From https://travis-ci.com/iterative/dvc/jobs/228530997 https://github.com/iterative/dvc/pull/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?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (18 by maintainers)

Commits related to this issue

Most upvoted comments

@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)

Will be fixed by #1818

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.