Open jaivardhankapoor opened 4 months ago
Hey! Thanks for the suggestions, I was planning on adding context manager support and enabling a decorator is not far off so I've created #3. I'll merge it soon.
That said, I don't plan to add more fancy stuff, ideally this is very simple single function library, if you want more feature feel free to fork :)
Description:
The current library provides a
stop_iter
function, which is a great start for creating interruptible operations. However, to enhance the library considering common ML usecases, I'm proposing expanding the library with more variants of interruptible operators.Proposed New Features:
Interruptible Context Manager:
A context manager that allows for easy creation of interruptible code blocks. Example usage:
Interruptible Decorator:
A decorator to make entire functions interruptible. Example usage:
Interruptible Iterator Class:
An iterator class with its own interruptible context. Not sure if the current
stop_iter
allows nesting. This ensures nesting is handled. Example usage:Progress Bar Integration:
Integration with tqdm to provide interruptible progress bars. Example usage:
I can start a pull request these features if you think it's a good idea. The code will remain clean and in a single-file.