mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(proxy): only schedule the deprecation loop when alerting is configured
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
25f343a547
commit
2fe152a1d2
2 changed files with 20 additions and 1 deletions
|
|
@ -482,7 +482,11 @@ class ProxyLogging:
|
|||
) # RUN HANGING REQUEST CHECK (if user wants to alert on hanging requests)
|
||||
self.hanging_requests_check_started = True
|
||||
|
||||
if self.slack_alerting_instance is not None and not self.deprecation_check_started:
|
||||
if (
|
||||
self.alerting is not None
|
||||
and self.slack_alerting_instance is not None
|
||||
and not self.deprecation_check_started
|
||||
):
|
||||
asyncio.create_task(self.slack_alerting_instance._run_scheduled_deprecation_check())
|
||||
self.deprecation_check_started = True
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,21 @@ def test_startup_event_initializes_slack_and_callbacks(proxy_logging):
|
|||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_startup_event_schedules_deprecation_check_before_its_alert_type_is_on(proxy_logging):
|
||||
"""Alerting config can enable the deprecation alert after startup, so the loop must already be running"""
|
||||
proxy_logging.alerting = ["slack"]
|
||||
proxy_logging.slack_alerting_instance = MagicMock()
|
||||
proxy_logging.slack_alerting_instance.alert_types = []
|
||||
proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check = AsyncMock()
|
||||
proxy_logging._init_litellm_callbacks = MagicMock()
|
||||
|
||||
proxy_logging.startup_event(llm_router=None, redis_usage_cache=None)
|
||||
|
||||
assert proxy_logging.deprecation_check_started is True
|
||||
proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check.assert_called_once_with()
|
||||
|
||||
|
||||
def test_startup_event_propagates_init_callbacks_failure_raises(proxy_logging):
|
||||
proxy_logging.slack_alerting_instance = MagicMock()
|
||||
proxy_logging.slack_alerting_instance.alert_types = []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue