Closed adrn closed 4 years ago
Should this use if progressbar
instead of if progressbar is not False
so that we support things like None
?
I did that because the progress bar object is an iterable, so I don't think it can be coerced into a bool:
It's actually not quite because it's an iterable:
import tqdm
bar = tqdm.tqdm(total=10)
if bar: # works!
...
bar = tqdm.tqdm(range(50))
if bar: # works!
...
bar = tqdm.tqdm()
if bar: # TypeError
...
How about:
has_progress_bar = (
hasattr(bar, "set_postfix")
and hasattr(bar, "update")
and hasattr(bar, "close")
)
instead?
I forgot to respond: I updated with your suggestion!
Awesome! I'm re-running the Windows test. It's not your fault, it just fails sometimes... 🤷
@adrn: one (or two, related) issues with this:
tqdm.auto
doesn't play nice with nbconvert (see here for example). It prints the following instead of a progress bar:HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))
jupyterlab
and it seems like auto
doesn't play nice with jupterlab in general either.I'm inclined to roll back some of this (allow users to provide a progress_bar
but don't default to auto), but I'm interested in your thoughts.
Interesting! BTW, it looks like pymc3 switched to this progress bar.
Sounds like rolling back the tqdm.auto
change, but keeping the option to pass in a progress_bar
is the way to go...
The fastprogressbar won't work for us because it looks like it doesn't support bars without a known number of total steps.
I fixed this on jupyterlab using:
python -m pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
jupyter labextension install @jupyter-widgets/jupyterlab-manager
and I think that nbconvert should be able to do the right thing if we have ipywidgets installed when running so I'm going to try that.
This allows passing in a progress bar instance, disabling the progress bar, or (by default) using
tqdm.auto.tqdm
(as described in #85).