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

[Data] Make sure progress bars always finish at 100% #36679

Merged
merged 5 commits into from
Jun 23, 2023

Conversation

raulchen
Copy link
Contributor

Why are these changes needed?

Today the progress bar's total progress is defined by the number of estimated blocks. If the estimation is not correct, the progress bar may go over 100% or finishes half way. This PR make sure the progress bar always finishes at 100%.

Related issue number

#36490

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Hao Chen <chenh1024@gmail.com>
@raulchen raulchen changed the title [Data] Make sure progress bars always finishes at 100% [Data] Make sure progress bars always finish at 100% Jun 21, 2023
Copy link
Contributor

@c21 c21 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -105,11 +107,17 @@ def set_description(self, name: str) -> None:
self._bar.set_description(self._desc)

def update(self, i: int) -> None:
# Make sure the progress bar doesn't go over 100%.
i = min(i, self._total - self._position)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do want to show it going over 100%, otherwise it will look "stuck" at 100%, right? Maybe in that case we should change the total to be higher?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah right, I think we could change self._total to reflect the progress.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you might have to also update self._bar's total somehow. I'm not sure about the tqdm API here, might need to try it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

If not possible, going over 100% is OK in tqdm as well, it just goes from a progress bar to a plain meter when you exceed 100.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find an API, but this seems to work well: bar.total = new_total; bar.refresh().
However, even if we update the total, the bar will still stuck at 100%, right? The only benefit is the progress value will change.
Do you guys prefer this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, do you know what is the simplest way to reproduce the over 100% case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I end up updating the total. I think this is useful, as we can see the actual number of blocks from here.

raulchen added 2 commits June 22, 2023 15:13
Signed-off-by: Hao Chen <chenh1024@gmail.com>
Signed-off-by: Hao Chen <chenh1024@gmail.com>
@pcmoritz
Copy link
Contributor

Merging in master where a couple of the test failures have been resolved :)

@pcmoritz pcmoritz merged commit 25e477c into ray-project:master Jun 23, 2023
@raulchen raulchen deleted the progress-bar branch June 23, 2023 21:37
raulchen added a commit that referenced this pull request Jun 28, 2023
This is a bug introduced by #36679.
I thought `position` was the bar position (initial progress). But it is actually the line position to print the bar. Rename the variable to "progress", and default initial value to 0.

Signed-off-by: Hao Chen <chenh1024@gmail.com>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
Today the progress bar's total progress is defined by the number of estimated blocks. If the estimation is not correct, the progress bar may go over 100% or finishes half way.  This PR make sure the progress bar always finishes at 100%.

Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
arvind-chandra pushed a commit to lmco/ray that referenced this pull request Aug 31, 2023
This is a bug introduced by ray-project#36679.
I thought `position` was the bar position (initial progress). But it is actually the line position to print the bar. Rename the variable to "progress", and default initial value to 0.

Signed-off-by: Hao Chen <chenh1024@gmail.com>
Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants