rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.45k stars 205 forks source link

How to suppress repeated progress updates? #221

Closed dudekahedronOP closed 1 year ago

dudekahedronOP commented 1 year ago

Hi, I've started using alive_bar for some routines that take a long time to complete. I use Jupyter for everything, and it keeps 'saving' statuses every few seconds?

Truth be told, I've been using python for a few years, but I don't consider myself an expert!

The output

|███████████████████████████████▋ | 147974/187405 [79%] in 11:24 (~3:02, 216.5/s) /s) 1870/187405 [1%] in 8s (~12:50, 241.2/s) 5019/187405 [3%] in 20s (~12:23, 245.4/s) 5554/187405 [3%] in 23s (~12:20, 245.9/s) 6576/187405 [4%] in 27s (~12:14, 246.5/s) 8314/187405 [4%] in 34s (~12:06, 246.8/s) (~11:57, 246.7/s) (~11:52, 246.5/s) 12882/187405 [7%] in 52s (~11:48, 246.5/s) 13065/187405 [7%] in 53s (~11:48, 246.4/s) 13677/187405 [7%] in 56s (~11:45, 246.3/s) 17364/187405 [9%] in 1:10 (~11:31, 246.3/s) (~11:17, 246.5/s) 22451/187405 [12%] in 1:31 (~11:09, 246.7/s) (~11:02, 246.5/s) 24382/187405 [13%] in 1:39 (~11:01, 246.5/s) [...etc, its a couple pages long]

Any idea what I'm doing wrong?

Thanks!

rsalmei commented 1 year ago

Hi dude, Jupyter has a few limitations that I reverse-engineered myself to make alive-progress work. One of them is: it does not return the number of columns available, so I used 120 as default. Another is: it does not support ANSI Escape Codes to be able to clear the line, it just handles \r, which makes the cursor return to the first column... So, to clear a line in Jupyter, I have to 1. return the cursor, 2. print 120 spaces, and 3. return the cursor again. I think you get the point. This means that it may indeed fail on different conditions that I've tested at the time... So can you help me? Please try to identify how many letters you can print on a single line. If it happens to be much different, I can try this again or even make it configurable.

dudekahedronOP commented 1 year ago

Hi rsalmei,

Sorry my delayed reply. At least in my case, there are 125 characters in a jupyter line (copied a line into a spreadsheet and got it's length). I definitely don't understand how Jupyter works or alive-progress, haha, but if you are just bumping the cursor back and overwriting (and not backing the cursor back enough 120 spaces instead of 125) wouldn't we see the output 'interrupt itself'?

From my print out above (and a few others like it in my notebook, it looks more like its appending a snapshot of progress; 1870/187405 [1%] in 8s (~12:50, 241.2/s) 5019/187405 [3% in 20s (~12.23, 245.4/s) 5554/187405 [3%] in 23s (~12:20, 245.9/s).... etc.

rsalmei commented 1 year ago

Can you write a minimal example that reproduces it for you? Then I could test it here.

rsalmei commented 1 year ago

Closing this one as stale. Please reply if anything new arises.