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
[WIP] Progress Logger #8105
[WIP] Progress Logger #8105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this could be achieved by a custom log handler and structured (e.g. JSON) log messages using the logging module.
iterable : sequence | ||
A python iterable | ||
|
||
label : int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*length
I'm closing this PR since we will need to rethink the API. At the time of speaking, I can think of two ways that could be discuss: via the callback or reusing the |
This makes sense, I'll note that progiter has been put into a separate standalone repo / package: https://github.com/Erotemic/progiter If this feature is desired (and I think it is) it likely makes sense to have some callback that any modern progress manager like tqdm, rich, or progiter can use. |
We indeed leaning towards getting a progress bar monitoring using rich. @Erotemic thank you for the info. |
Reference Issue
This is start of work to address the issues in #78 #7574
What does this implement/fix? Explain your changes.
This adds an initial draft of the ProgIter object. This object
wraps around long-running loops and reports progress in a simple but customization way.
The purpose is meant to simplify writing progress messages and create a construct that can simply be dropped into existing code.
I've added in usage of this object into kmeans++ and MiniBatchKmeans to address my original use case. The case with MiniBatchKmeans requires a bit more customization because other useful messages in the loop. However, the case with kmeans++ where the change is extremely minimal and really demonstrates how this can just be dropped into existing code.
Any other comments?
While this feature does work end-to-end it is not complete.
Because this is a work in progress I have left some debugging code, references to my utility library (utool), and documentation constructs that I use in my coding workflow to quickly test things.
I don't see myself able to work much on this feature in the near future, but I did want to push what I had so far because (a) just to put it out there, (b) so I don't lose it, and (c) in case it is useful to someone else.
Basic usage of the object looks like this:
By default the output is continually updated by clearing the previous line, so at the end only the last progress message shows.
The progiter module itself contains a small demo function to demonstrate how it works. Running the demo results in this output:
An example showing how this works in the context of MiniBatchKMeans is here:
First with verbose=2, which means the ProgIter object will not clear progress lines and always just append the next line to stdout.
Verbosity 2 can be a bit much, so when verbosity=1 a clearline sequence will tell the terminal to delete the previous verbosity line before it prints the next one. This has a nice where you see a single line in the terminal update every once in awhile. Obviously I can't show updates in static text, but at the end of the script it looks like this: