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.__repr__() crashes when disable=True #624
Comments
I don't think this is probably too important/helpful, but for reference the line that caused me to notice this is https://github.com/diana-hep/pyhf/blob/fdcfb976dc5287590279b0ece7fc700b8208a337/pyhf/readxml.py#L149 though strangely enough this doesn't fail right away (c.f. cell 4 of our example Jupyter notebook which runs in Binder at the moment) — I only found this behavior when breaking |
Something similar happens when calling
|
Critical bug, for two years not fixed, hm ... We did a private monkey-patch fix, wich helped us for a while: # check and fix for <https://github.com/tqdm/tqdm/issues/624>
if not hasattr(self.t, '_time') or getattr(self.t, '_time') is None:
setattr(self.t, '_time', time) However a commit on 2020-12-24 introduced another AttributeError: ~/projects/sandbox> python3
Python 3.9.1 (default, Jan 8 2021, 17:17:43)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tqdm
>>> from time import time
>>> print(tqdm.__version__)
4.56.0
>>> t = tqdm.tqdm(disable=True)
>>> if not hasattr(t, '_time') or getattr(t, '_time') is None:
... setattr(t, '_time', time)
...
>>> t.reset()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/tqdm/std.py", line 1349, in reset
self._ema_dn = EMA(self.smoothing)
AttributeError: 'tqdm' object has no attribute 'smoothing' The last tagged version before this regression is: 4.54.1 |
* Update tqdm to require tqdm v4.56 as minimum to get tqdm.__repr__() crash fix - c.f. tqdm/tqdm#624 - Fix was released in tqdm v4.5.6.1, but minimum of v4.56 will pick this up
read the known issues
environment, where applicable:
Why does this occur? If disabled, then this block is evaluated during initialization (https://github.com/tqdm/tqdm/blob/master/tqdm/_tqdm.py#L763-L770) which immediately returns and therefore skips the "store the arguments" portion: https://github.com/tqdm/tqdm/blob/master/tqdm/_tqdm.py#L819-L841.
Not clear to me how this should be handled or if this is expected.
hat-tip to @matthewfeickert for finding this bug.
The text was updated successfully, but these errors were encountered: