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

replace custom ProgressMeter with tqdm #928

Closed
jbarnoud opened this issue Aug 4, 2016 · 4 comments · Fixed by #2617
Closed

replace custom ProgressMeter with tqdm #928

jbarnoud opened this issue Aug 4, 2016 · 4 comments · Fixed by #2617

Comments

@jbarnoud
Copy link
Contributor

jbarnoud commented Aug 4, 2016

EDIT (@orbeckst): Based on the discussion in this issue we decided to replace our lib.util.ProgressMeter with tqdm. Use this issue for discussion to refine this idea.


The progress bar could give an estimate of when the calculation is going to be done. This is reassuring for the end user, and allows to plan other things during long calculation (or to know when to come back from a coffee break).

This is easily achievable by keeping track of the time elapsed between two calls of the update method as we know how many frames remain to be analyzed.

It can be misleading for analyses that need to iterate several time through the trajectory, or that have a very long _conclude method. But the current progress bar is misleading already.

@jbarnoud jbarnoud self-assigned this Aug 4, 2016
@orbeckst
Copy link
Member

orbeckst commented Aug 7, 2016

Instead of calculating time between two calls I would keep track of the time since the start because that should improve your estimate for the average time per iteration and thus improve your extrapolated ETC (estimated time to completion).

@kain88-de
Copy link
Member

kain88-de commented Aug 7, 2016

Have a look in the code of pyprind. I use the package to have long verbose views and it has a good ETC estimate.

@orbeckst
Copy link
Member

orbeckst commented Jun 3, 2019

As discussed in PR #960 (#960 (comment) and following comments) we want to transition to using tqdm.

There are some caveats regarding use in Jupyter notebooks (#960 (comment)) but overall everyone is happy with the provided functionality and we would be ok adding it as a core dependency.

Note that we need to

  • deprecate lib.log.ProgressMeter (for anyone who has been using it in their own code) and remove in 1.0
  • replace internal use of ProgressMeter with a new version based on tqdm.tqdm().

Perhaps we can simply derive our own class from tqdm.tqdm with our default settings, like lib.log.ProgressReporter or ProgressBar

import tqdm
class ProgressBar(tqdm.tqdm):
   def __init__(self, *args, **kwargs):
          verbose = kwargs.pop('verbose', True)
          # disable: Whether to disable the entire progressbar wrapper [default: False]. 
          # If set to None, disable on non-TTY.
          kwargs['disable'] = None if verbose else True
          super(ProgressBar, self).__init__(*args, **kwargs)

and then use as

from ..lib.log import ProgressBar

for ts in ProgressBar(u.trajectory[start:stop:step], verbose=verbose):
      analyze(ts)

It should cut down on code because we don't need manual status updates such as the pm.echo().

@orbeckst
Copy link
Member

orbeckst commented Jun 3, 2019

There is probably a way to switch to the fancy GUI versions tqdm.tqdm_gui or tqdm.tqdm_notebook for notebooks but I haven't looked into this at all.

@orbeckst orbeckst changed the title Progress bar could give a time estimate replace custom ProgressMeter with tqdm Mar 5, 2020
orbeckst pushed a commit that referenced this issue Mar 22, 2020
* Fixes #928
* Fixes #2504
* 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.
  - Automatically detect which version of tqdm to use (console or notebook):
     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
* add tqdm to dependencies
* Deprecate ProgressMeter through warning and text
* Replace ProgressMeter with ProgressBar everywhere in MDAnalysis
* add tests (for #928 and #2504)
* update CHANGELOG and AUTHORS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants