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

to not increment when call bar(0) #264

Open
luewh opened this issue Jan 27, 2024 · 5 comments
Open

to not increment when call bar(0) #264

luewh opened this issue Jan 27, 2024 · 5 comments
Labels
improvement It does work, but there's this little thing
Milestone

Comments

@luewh
Copy link

luewh commented Jan 27, 2024

I have to check the progress each periode of time then update the bar with pregression difference, but this value could be 0, so it updated 1 while it doesn't need.
I can add a condition to check if it is 0 but it would be logical to not increment when call bar(0).

@rsalmei
Copy link
Owner

rsalmei commented Jan 28, 2024

Yes, it makes sense. Also, it would be on par with the manual mode bar, which does accept 0. (float) as input.
I'll do it on the next release.

@rsalmei rsalmei added this to the 3.2 milestone Jan 28, 2024
@rsalmei rsalmei added the improvement It does work, but there's this little thing label Jan 28, 2024
@chet-manley
Copy link

chet-manley commented Sep 19, 2024

I have a similar request, but using a negative integer instead of 0. Manual mode does not fit my needs, because I know the total, but I see you use run.count += max(1, int(count)) when updating using bar(int) (which is what causes OP's issue).

My use case is simple. I'm downloading hundreds of thousands/millions of logs from OpenSearch, 10k at a time, and I know the total I will be receiving. Occasionally, a request fails, and I need to re-download some number of logs. I need to set the progress back to the last known good state and re-process the logs during redownload. If bar(-int) were accepted, this would be an easy task, but as far as I can tell, there is no way to reverse the progress without manual mode, where I would lose automatic percentage calculation, ETA, etc.

@rsalmei
Copy link
Owner

rsalmei commented Sep 20, 2024

Humm, shouldn't you wait to forward the progress until you've successfully received the logs? It would work better because the user should see what is actually accomplished at each given moment.
Anyway, with manual mode you can do this since you send the absolute percentage each time. You can make abrupt jumps, go backward, etc.

@chet-manley
Copy link

chet-manley commented Sep 20, 2024

For a bit more context, the logs are downloaded in 24hr batches. So let's say you have a single batch of ~373k logs out of ~1.7m total, and for each 10k that is processed (transformed to JSON and written to file), the progress moves forward 10k. 220k logs into the operation, a request fails, so the file is unlinked and the batch restarts from the beginning. Or perhaps the batch completes, but received too few logs due to a concurrent re-index that started during the operation. The progress bar now needs to be reduced to the count after the previous batch to properly indicate the current state of the operation, and I would like to keep the automatic percentage calculation, ETA, etc afforded by not using manual mode.

I originally tried to use two progress bars, one for the aggregate total, updated when each batch completed, and one for each batch total, but realized two bars cannot be run at the same time. Perhaps each bar could run in its own thread with its own state? I haven't had time to look through the code thoroughly to see if this is feasible or not.

@rsalmei
Copy link
Owner

rsalmei commented Sep 20, 2024

Yep, I see. Thanks for the thorough explanation.
I reckon I could indeed make the two modes operate with similar flexibility, i.e. since manual mode can go backward (by receiving a smaller absolute percentage), the auto mode could also go (but by receiving a negative relative count).
I'll make it happen 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement It does work, but there's this little thing
Projects
None yet
Development

No branches or pull requests

3 participants