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

Use standard tqdm if import ipywidgets fails in notebook #1218

Closed

Conversation

thomasaarholt
Copy link

Using tqdm imported from tqdm.auto in jupyter notebook will fail if ipywidgets is not available.
The current behaviour means that a user with a minimum install of jupyter notebook will not be able to use packages that "naively" utilize tqdm.auto but do not rely on ipywidgets.

This PR lets tqdm.auto revert to using the standard tqdm progress bar if the HTML one is unavailable.

Fixes #1082, #1072.

Test by creating an environment without ipywidgets (ie. conda create -n test notebook and calling the code below:

from tqdm.auto import tqdm as tqdm_auto
for i in tqdm_auto(range(10)):
    pass

I ran into this issue coming from using the Dask tqdm Callback: #1217.

tqdm/autonotebook.py Outdated Show resolved Hide resolved
Co-authored-by: Bradley Dice <bdice@bradleydice.com>
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 11, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.32%.

Quality metrics Before After Change
Complexity 4.00 ⭐ 4.00 ⭐ 0.00
Method Length 57.00 ⭐ 59.00 ⭐ 2.00 👎
Working memory 6.00 ⭐ 6.00 ⭐ 0.00
Quality 80.48% 80.16% -0.32% 👎
Other metrics Before After Change
Lines 28 29 1
Changed files Quality Before Quality After Quality Change
tqdm/autonotebook.py 80.48% ⭐ 80.16% ⭐ -0.32% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@bdice
Copy link

bdice commented Jan 12, 2022

@casperdcl Hi! Do you know why this PR's CI appears stuck? (edit: It looks like a maintainer needs to approve it to run.) I'm interested in seeing a solution to issue #1082 and this PR seems like a viable route towards resolving it.

@casperdcl casperdcl self-assigned this Feb 27, 2022
@casperdcl casperdcl added c1-quick 🕐 Complexity low p0-bug-critical ☢ Exception rasing question/docs ‽ Documentation clarification candidate submodule-notebook 📓 Much web such IDE to-review 🔍 Awaiting final confirmation labels Feb 27, 2022
@casperdcl casperdcl added this to Next Release in Casper Feb 27, 2022
casperdcl added a commit that referenced this pull request Feb 27, 2022
@casperdcl casperdcl mentioned this pull request Feb 27, 2022
casperdcl added a commit that referenced this pull request Feb 27, 2022
Casper automation moved this from Next Release to Done Feb 28, 2022
@casperdcl
Copy link
Sponsor Member

casperdcl commented Feb 28, 2022

Sorry for the massive delay in reviewing. Addressed in v4.63.0 :)

@bdice
Copy link

bdice commented Feb 28, 2022

@casperdcl Thank you very much! 👍 tqdm is a lovely package. It brings me joy every time I wrap an iterable in tqdm(...). 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c1-quick 🕐 Complexity low p0-bug-critical ☢ Exception rasing question/docs ‽ Documentation clarification candidate submodule-notebook 📓 Much web such IDE to-review 🔍 Awaiting final confirmation
Projects
Casper
  
Done
Development

Successfully merging this pull request may close these issues.

tqdm.auto errors in notebooks if ipywidgets is not installed
3 participants