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

tqdm ProgressBar implementation #2617

Merged
merged 20 commits into from
Mar 22, 2020
Merged

tqdm ProgressBar implementation #2617

merged 20 commits into from
Mar 22, 2020

Conversation

cbouy
Copy link
Member

@cbouy cbouy commented Mar 12, 2020

Fixes #928
Fixes #2504

Changes made in this Pull Request:

  • Added the ProgressBar class which inherits the tqdm.auto.tqdm object. For now, the disable keyword takes precedence over verbose, i.e. if both are set to True the progress bar won't show. Setting disable=True will disable the progress bar as expected. Setting verbose=False will disable the progress bar.
  • Deprecate ProgressMeter through warning and text
  • Replace ProgressMeter with ProgressBar

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

cbouy added 2 commits March 12, 2020 15:00
If run from a jupyter notebook or jupyter lab, will use the
tqdm.notebook.tqdm class, else (ipython, shell, or anything else)
will use the default tqdm.tqdm class.
@cbouy
Copy link
Member Author

cbouy commented Mar 12, 2020

Now it should be able to automatically detect Jupyter (notebook or lab) versus the rest and use the appropriate tqdm class.
For JupyterLab, it requires a few things beforehand:

conda install -c conda-forge nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager

@codecov
Copy link

codecov bot commented Mar 12, 2020

Codecov Report

Merging #2617 into develop will decrease coverage by 0.01%.
The diff coverage is 53.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #2617      +/-   ##
==========================================
- Coverage    90.71%   90.7%   -0.02%     
==========================================
  Files          174     174              
  Lines        23549   23562      +13     
  Branches      3072    3073       +1     
==========================================
+ Hits         21363   21372       +9     
- Misses        1565    1570       +5     
+ Partials       621     620       -1
Impacted Files Coverage Δ
package/MDAnalysis/lib/log.py 92% <53.84%> (-5.71%) ⬇️
package/MDAnalysis/analysis/hole2/hole.py 82.71% <0%> (+0.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53ccf6d...6299b90. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 12, 2020

Codecov Report

Merging #2617 into develop will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2617   +/-   ##
========================================
  Coverage    91.00%   91.01%           
========================================
  Files          174      174           
  Lines        23550    23595   +45     
  Branches      3083     3082    -1     
========================================
+ Hits         21431    21474   +43     
- Misses        1497     1498    +1     
- Partials       622      623    +1     
Impacted Files Coverage Δ
package/MDAnalysis/analysis/rms.py 93.54% <ø> (-0.13%) ⬇️
package/MDAnalysis/analysis/base.py 100.00% <100.00%> (ø)
package/MDAnalysis/analysis/density.py 89.06% <100.00%> (-0.04%) ⬇️
...ckage/MDAnalysis/analysis/hbonds/hbond_analysis.py 81.49% <100.00%> (-0.11%) ⬇️
...age/MDAnalysis/analysis/hbonds/hbond_autocorrel.py 87.34% <100.00%> (-0.16%) ⬇️
package/MDAnalysis/analysis/helanal.py 87.93% <100.00%> (-0.07%) ⬇️
package/MDAnalysis/analysis/pca.py 95.29% <100.00%> (-0.27%) ⬇️
package/MDAnalysis/analysis/waterdynamics.py 90.51% <100.00%> (-0.14%) ⬇️
package/MDAnalysis/core/universe.py 96.33% <100.00%> (-0.03%) ⬇️
package/MDAnalysis/lib/log.py 95.78% <100.00%> (-1.92%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4102481...ce5051c. Read the comment docs.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your new code.

But there's more to be done: The goal of #928 is to replace ProgressMeter with your new ProgressBar everywhere and eventually get rid of our own implementation:

  1. Deprecate ProgressMeter in 1.0 and schedule for removal in 2.0.
    • deprecation warning
    • deprecation text
  2. Replace all uses of ProgressMeter inside MDAnalysis with equivalent uses of ProgressBar (as much as possible).
  3. Add test for ProgressMeter (testing in ipython/Jupyter is probably not feasible but doing a mock for get_ipython() to show that different backends can be selected should be easy)

.appveyor.yml Show resolved Hide resolved
.appveyor.yml Outdated Show resolved Hide resolved
package/MDAnalysis/lib/log.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/log.py Outdated Show resolved Hide resolved
package/MDAnalysis/lib/log.py Outdated Show resolved Hide resolved
@orbeckst
Copy link
Member

@jbarnoud I am adding you to this issue as the original driving force behind #928

Fixed errors when calculating RMSD
Modified the test of the progress bar in TestRMSD
Cleanup of useless n_frames and enumerate
@orbeckst
Copy link
Member

The Python 2.7 version of the test is failing https://travis-ci.com/github/MDAnalysis/mdanalysis/jobs/298190141, perhaps something with comparing utf-8 strings.

@cbouy cbouy requested a review from orbeckst March 15, 2020 15:05
Copy link
Contributor

@jbarnoud jbarnoud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a very quick look on my phone, the only thing I am missing is a test assessing that the deprecation warning is issued. Good work here 👍

@cbouy
Copy link
Member Author

cbouy commented Mar 15, 2020

@jbarnoud should I make a proper test module for the ProgressBar and ProgressMeter then ? I find it counter-intuitive to have the test for the ProgressMeter alongside the tests for the RMSD

@jbarnoud
Copy link
Contributor

jbarnoud commented Mar 15, 2020 via email

@cbouy
Copy link
Member Author

cbouy commented Mar 16, 2020

I don't understand the report from codecov, could someone explain what's missing ? I've added a new class, a test for this new class, I moved a test from test_rms.py to test_log.py and created a new test for the deprecation. There should be an increase in coverage or am I getting this wrong ?

@orbeckst
Copy link
Member

Codecov can be mysterious...

Sorry for the long silence. Will have a look now.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really awesome. I love how much code you deleted! The tests are nice, too.

I have one blocking comment/question. Please have a look. Otherwise this is pretty much ready to go. Nice work!

package/MDAnalysis/analysis/hbonds/hbond_autocorrel.py Outdated Show resolved Hide resolved
package/MDAnalysis/analysis/hbonds/hbond_autocorrel.py Outdated Show resolved Hide resolved
@orbeckst
Copy link
Member

Codecov can be mysterious...

The above was a bit flippant but what I wanted to say is that it's not always clear that codecov is showing us what we expect to see and although we like to see everything green in the CI, we do overrule Codecov once we are happy.

@lilyminium lilyminium mentioned this pull request Mar 20, 2020
4 tasks
@jbarnoud
Copy link
Contributor

@lilyminium noticed in #2631 (comment) that the API changes. It probably should not.

@lilyminium
Copy link
Member

#2631 (comment) was phrased poorly -- as far as I can tell this does not change the API, except that AnalysisBase._pm no longer exists. #2631 did alter the arguments given to _setup_frames. This PR also fixes #2504.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor CHANGELOG comment and then I will approve and merge.

package/CHANGELOG Show resolved Hide resolved
@orbeckst
Copy link
Member

@lilyminium @jbarnoud thanks for pointing out that this PR fixes #2504, too #2631 (comment).

@cbouy
Copy link
Member Author

cbouy commented Mar 21, 2020

Thank you @orbeckst @jbarnoud @richardjgowers for your help ! And thanks @lilyminium for mentioning the other issue !

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

Just waiting for CI to come back green to do the squash&merge.

@orbeckst
Copy link
Member

One of the macOS jobs failed right at the start. I restarted https://travis-ci.com/github/MDAnalysis/mdanalysis/jobs/300680256 – hopefully this will all look good in an hour.

@orbeckst orbeckst merged commit 5f51383 into MDAnalysis:develop Mar 22, 2020
@orbeckst
Copy link
Member

@cbouy very nice contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

verbose not set in analysis.AnalysisBase.run replace custom ProgressMeter with tqdm
6 participants