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

[BUG] progress bar: bogus estimations #378

Closed
nschloe opened this issue Oct 12, 2020 · 8 comments
Closed

[BUG] progress bar: bogus estimations #378

nschloe opened this issue Oct 12, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@nschloe
Copy link

nschloe commented Oct 12, 2020

The computation of the remaining time often produces bogus results for me. Here, when nesting two progress bars, I'm even getting negative times. MWE:

from rich.progress import Progress
import time

m = 10
n = 5

with Progress() as progress:
    task1 = progress.add_task("Overall", total=m)
    task2 = progress.add_task("Kernels", total=n)

    for _ in range(m):
        progress.update(task2, completed=0)
        for j in range(n):
            time.sleep(2 ** j)
            progress.update(task2, advance=1)
        progress.update(task1, advance=1)

screenshot

@willmcgugan
Copy link
Collaborator

Are you adjusting the total after the task is started?

I'll need to see code to diagnose this.

@willmcgugan willmcgugan added Can't reproduce Issue could not be reproduced and removed Needs triage labels Oct 15, 2020
@nschloe
Copy link
Author

nschloe commented Oct 21, 2020

@willmcgugan Added MWE to the original post.

@willmcgugan
Copy link
Collaborator

Can you try with the latest version please.

@nschloe
Copy link
Author

nschloe commented Oct 21, 2020

This is with

python3 -c 'from importlib import metadata; print(metadata.version("rich"))'
9.0.1

Or do you mean master?

@willmcgugan
Copy link
Collaborator

It's because completed is going backwards. Replace progress.update(task2, completed=0) with progress.reset(task2).

I'll look in to doing an automatic reset when the value completed goes backwards.

@nschloe
Copy link
Author

nschloe commented Oct 21, 2020

That fixes it, thanks. Should I leave this open?

@willmcgugan
Copy link
Collaborator

Great. Yes, leave it open for now.

@willmcgugan willmcgugan added bug Something isn't working and removed Can't reproduce Issue could not be reproduced labels Oct 21, 2020
@willmcgugan
Copy link
Collaborator

Fixed in 9.1.0. Progress.reset is still the recommended way though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants