rich icon indicating copy to clipboard operation
rich copied to clipboard

[REQUEST] Progress bars with undetermined 'total'

Open azmeuk opened this issue 4 years ago • 8 comments

Hi. The documentation describes the usage of indeterminate progress bars that displays a waiting animation during the time the number of steps is computed.

indeterminate state

However, sometimes you never know how many steps you except (when reading a stream for instance), but this is something rich does not accept: https://github.com/willmcgugan/rich/blob/1c1d72ccad965a41500253680c73e6606924cd13/rich/progress.py#L667-L673

I suggest in those cases to display a waiting animation instead.

Of course in this case the percentage and the ETA would not be very usable, but the bar could display the number of items processed (this is what tqdm does).

What do you think?

azmeuk avatar Feb 24 '21 16:02 azmeuk

Would a status not be more appropriate for that?

willmcgugan avatar Feb 28 '21 11:02 willmcgugan

Status can do the job if you know the thing you iterate on has always an undetermined size. Sometimes you may want to use a progress bar without knowing in advance if the total size could be determined.

azmeuk avatar Mar 01 '21 08:03 azmeuk

Just to note a few things that you'd need to do manually with a status that could perhaps be done more cleanly with a progress bar: elapsed time so far, number of units complete so far and the rate of units. TQDM is a nice example of this, if you just leave out a total (really enjoying rich so far btw - really lovely library 😄 )

geoffsmith avatar Mar 11 '21 21:03 geoffsmith

I'm unlikely to get to this any time soon. Opening it up for contributions.

willmcgugan avatar Jul 27 '21 18:07 willmcgugan

I will help on this one. Since it is the same as #1528, I guess will take both.

I will look at their override and see if anything is salvageable. @willmcgugan Do you have any comment on their solution or preference on how to proceed (e.g. the use of float("inf") vs None as a value for total)?

mrvkino avatar Sep 29 '21 02:09 mrvkino

elapsed time so far

Elapsed time would be very nice, particularly when the progress bar hits 100%, it should at least show that instead of time remaining, which is 00:00:00. I suspect some would like elapsed time during run for long jobs, but not as critical for my needs. Perhaps this should be a separate issue?

astrochun avatar Apr 20 '22 13:04 astrochun

Have a look at TimeRemainingColumn. You can set elapsed_when_finished=True which displays the elapsed time when it reaches 100%.

The TimeElapsedColumn will display just the elapsed time.

willmcgugan avatar Apr 20 '22 14:04 willmcgugan

Have a look at TimeRemainingColumn. You can set elapsed_when_finished=True which displays the elapsed time when it reaches 100%.

The TimeElapsedColumn will display just the elapsed time.

Thanks! I've only touch on track() and not Progress. Guess I'm now in the advanced settings :-)

astrochun avatar Apr 20 '22 15:04 astrochun

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

github-actions[bot] avatar Sep 20 '22 10:09 github-actions[bot]