-
Notifications
You must be signed in to change notification settings - Fork 129
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
Callback system v0 #278
Callback system v0 #278
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #278 +/- ##
===================================
Coverage 95% 95%
===================================
Files 14 18 +4
Lines 1076 1173 +97
===================================
+ Hits 1019 1114 +95
- Misses 57 59 +2 |
for the hook names for the litapi, remove the litapi words: LitAPIGOODon_setup_start BADon_litapi_setup_start LitServerFor the litserver, what do these 2 do?
|
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.
Looks great @aniketmaurya
Before submitting
Allow users to trigger arbitrary functions via a callback system. This enables to inject useful functionalities like logging inference time, metrics collection, etc.
What does this PR do?
Implements a callback system with certain hooks that get triggered on events.
A caveat of this implementation would be that even though the callbacks are classes, it might not be straightforward to save state between to hooks like
on_litapi_predict_end
andon_server_setup_start
because they run in different process and once the callback object is pickled then we don't sync the state.I think this is okay, considering that when in same context (
on_litapi_predict_start
andon_litapi_predict_end
)on_litapi_*_*
we will have the state in same process.As a result of this PR, we will be able to refactor the monitoring metrics PR as a callback.
TODO
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃