-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixed issue #8246 #8250
base: main
Are you sure you want to change the base?
Fixed issue #8246 #8250
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -573,6 +573,20 @@ def __init__( # noqa: PLR0915 | |||
litellm.amoderation, call_type="moderation" | |||
) | |||
|
|||
def discard(self): |
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.
@@ -85,6 +85,21 @@ def add_litellm_async_failure_callback( | |||
callback=callback, parent_list=litellm._async_failure_callback | |||
) | |||
|
|||
def remove_callback_from_list_by_object( |
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.
needs a unit test maybe here - https://github.com/BerriAI/litellm/blob/main/tests/logging_callback_tests/test_unit_tests_init_callbacks.py
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.
Looking at the existing tests, I believe a more suitable location for the unit test for remove_callback_from_list_by_object
is https://github.com/BerriAI/litellm/blob/main/tests/litellm_utils_tests/test_logging_callback_manager.py
Hi @erezh16 thank you for your work here - if you can share a screenshot of this passing your unit testing, that would be great! |
The unit tests are ready, but I'm having issues running tests in general. Is there an updated document on testing LiteLLM? For example, pytest claims it does not recognize |
@krrishdholakia I managed to execute both unit tests as specific tests and they both pass. Is this sufficient? As I commented earlier, running all tests following the README.md documentation does not work. |
@krrishdholakia if you tell me how to do full testing, I will do it. The documentation on that is broken, and the command from the CircleCI setup is not working either. |
Specific unit test is fine - i can take care of the rest - we can do a better job here with contribution guides / testing. Thanks for the feedback |
Title
Added cleanup of callbacks for ad-hoc router created for requests with
user_config
Relevant issues
Fixes #8246
Type
🐛 Bug Fix
Changes
remove_callback_from_list_by_object()
method to theLoggingCallbackManager
class inlogging_callback_manager.py
. This function removes all methods of a given object from a given callback list.discard()
method for theRouter
class inrouter.py
. This is a pseudo-destructor that currently handles only cleaning up and methods of the router object from the global callback lists, e.g.,litellm._async_success_callback
. The method implementation is using theremove_callback_from_list_by_object()
method mentioned above.route_llm_request.py
I changed the code for handlinguser_config
starting in line 59 to call the newdiscard()
method (mentioned above) of theuser_router
to do proper cleanup prior to returning the request result.[REQUIRED] Testing - Attach a screenshot of any new tests passing locally
It's a bit hard to create a test for messages that are logged. I verified that the temp router callbacks are properly disposed of at the end of a request using a debugger. See Test procedure below.
If UI changes, send a screenshot/GIF of working UI fixes
python -m pdb proxy_cli.py
b proxy_server.py:3546
c
user_config
. I attach a sample Python script below but masking away the keys.p litellm._async_success_callback