-
Notifications
You must be signed in to change notification settings - Fork 663
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
Comments
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). |
Have a look in the code of pyprind. I use the package to have long verbose views and it has a good ETC estimate. |
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
Perhaps we can simply derive our own class from tqdm.tqdm with our default settings, like 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 |
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. |
* 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
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.The text was updated successfully, but these errors were encountered: