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

[Enhancement] Easy way to update the ETA of Bars #65

Closed
BigBrainAFK opened this issue Mar 31, 2020 · 13 comments
Closed

[Enhancement] Easy way to update the ETA of Bars #65

BigBrainAFK opened this issue Mar 31, 2020 · 13 comments
Labels

Comments

@BigBrainAFK
Copy link

BigBrainAFK commented Mar 31, 2020

I have not found a simple way to update the ETA value of a bar except for doing this

setInterval(() => {
	if (progBar.isActive) progBar.update(progBar.value);
}, 1000);

where progBar is an instance of the SingleBar class.

I have tried using the <Bar>.render() method and <Bar>.update(0) (which just resets the bar every time).

This is only a problem when the script solely relies on <Bar>.increment() and does not count the current value itself. If the script does count the current value itself one can simply use <Bar>.update(value)

@AndiDittrich
Copy link
Member

i don't understand the issue: the ETA value is automatically calculated and cannot be altered. if you want to use a different algorithm please use the payload feature to add custom values

@BigBrainAFK
Copy link
Author

BigBrainAFK commented Apr 7, 2020

the problem i have is that i have no use for a bar that only updates the eta when the bar actually has an increment of at least 1.

the code i posted in the first post basically forces the progressbar to recalculate the eta every second.

example: lets say i have a bar with an end value of 200 and a start value of 0. in the first minute the bar fills up to the value of 199. the eta then says smth like 1second remaining. if the last increment to finish the bar takes 2hours tho (so 199->200) the eta will say 1 second for these 2hours. there is no way to implement a simple way to just do something like progBar.updateETA() and have the ETA update accordingly

@AndiDittrich
Copy link
Member

the eta calculation wont work in case all values are identically (long running processes) - your code above will cause this behaviour vt_rate=0 and therefore the eta will set to INF

@BigBrainAFK
Copy link
Author

so the calculation does work cause its a valid estimate. and its better than being stuck at the last time the value got updated

@AndiDittrich
Copy link
Member

it's only an edge case that it works for you....cli progress eta calculation is not designed for extreme long running processes.

if you like i can add an additional method like updateETA which can be triggered externally

@BigBrainAFK
Copy link
Author

would be practical. and my example was admittedly chosen as an exaggerated edge case but in my use case of a 2minute runnibg process it aso look like the script hangs every now and then due to the eta not refreshing. it would be nice to have a method to uodate the eta

@AndiDittrich
Copy link
Member

i've added two new features to the master branch:

  • method updateETA to force an eta update using the current value
  • option etaAsynchronousUpdate to force an eta update on each asynchronous render call - this is related to the fps settings - therefore the fps rate should be set in conjunction with the eta buffer size:

Example

const _progress = require('./cli-progress');
const _terminal = require('./lib/terminal');

// 50s/2 => new value expected within 25s
const p1 = new _progress.SingleBar({
    fps: 2,
    etaBuffer: 50,
    etaAsynchronousUpdate: true
}, _progress.Presets.shades_classic);

p1.start(100, 50);

@designbyadrian
Copy link

I'd be great if the unit was mentioned in the README. It wasn't until here where I understood that the etaBuffer is in seconds!

@AndiDittrich
Copy link
Member

AndiDittrich commented May 18, 2021

etaBuffer is NOT in seconds, it's just the buffer size N

@designbyadrian
Copy link

N what? Updates? Frames?

@AndiDittrich
Copy link
Member

size of elements within the buffer

@designbyadrian
Copy link

When is a new element added to the buffer?

@AndiDittrich
Copy link
Member

depends on the settings etaAsynchronousUpdate - please take a look into the sources. this thread handles a very specific case of continuous eta updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants