The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(proxy): make the deprecation loop entrypoint public and drop a dead None check
mateo816fa5039435
diff --git a/litellm/integrations/SlackAlerting/slack_alerting.py b/litellm/integrations/SlackAlerting/slack_alerting.pyindex a6d86f73479..9f9c26ae15c 100644--- a/litellm/integrations/SlackAlerting/slack_alerting.py+++ b/litellm/integrations/SlackAlerting/slack_alerting.py@@ -1087,7 +1087,7 @@ Model Info:)return True- async def _run_scheduled_deprecation_check(+ async def run_scheduled_deprecation_check(self, get_llm_router: Callable[[], Router | None] = _proxy_llm_router) -> None:"""Alert once the router is loaded and the alert is on, then daily, re-reading both each pass"""diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.pyindex 3a40d688883..bc73e4d3e5b 100644--- a/litellm/proxy/utils.py+++ b/litellm/proxy/utils.py@@ -495,7 +495,7 @@ class ProxyLogging:def _ensure_deprecation_check_scheduled(self) -> None:"""Alerting can be configured at startup or by a later config reload, so schedule from either path"""- if self.alerting is None or self.slack_alerting_instance is None or self.deprecation_check_started:+ if self.alerting is None or self.deprecation_check_started:returntry:@@ -503,7 +503,7 @@ class ProxyLogging:except RuntimeError:return- asyncio.create_task(self.slack_alerting_instance._run_scheduled_deprecation_check())+ asyncio.create_task(self.slack_alerting_instance.run_scheduled_deprecation_check())self.deprecation_check_started = Truedef update_values(diff --git a/tests/test_litellm/integrations/SlackAlerting/test_model_deprecation_alert.py b/tests/test_litellm/integrations/SlackAlerting/test_model_deprecation_alert.pyindex 6dfdf831fa7..f475a6d454e 100644--- a/tests/test_litellm/integrations/SlackAlerting/test_model_deprecation_alert.py+++ b/tests/test_litellm/integrations/SlackAlerting/test_model_deprecation_alert.py@@ -146,7 +146,7 @@ async def test_should_alert_once_the_alert_type_and_router_arrive_after_startup(),pytest.raises(asyncio.CancelledError),):- await alerting._run_scheduled_deprecation_check(get_llm_router=lambda: router)+ await alerting.run_scheduled_deprecation_check(get_llm_router=lambda: router)assert slept == [DEPRECATION_IDLE_POLL_SECONDS,@@ -193,7 +193,7 @@ async def test_should_wait_for_the_router_instead_of_sleeping_a_full_day(monkeyp),pytest.raises(asyncio.CancelledError),):- await alerting._run_scheduled_deprecation_check(+ await alerting.run_scheduled_deprecation_check(get_llm_router=lambda: next(routers))diff --git a/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.py b/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.pyindex 5382f367f42..e45345877f3 100644--- a/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.py+++ b/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.py@@ -136,13 +136,13 @@ async def test_startup_event_schedules_deprecation_check_before_its_alert_type_iproxy_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.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()+ proxy_logging.slack_alerting_instance.run_scheduled_deprecation_check.assert_called_once_with()@pytest.mark.asyncio@@ -150,7 +150,7 @@ async def test_update_values_schedules_deprecation_check_when_alerting_arrives_l"""A proxy that boots without alerting still needs the loop once a config reload turns it on"""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.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)@@ -159,7 +159,7 @@ async def test_update_values_schedules_deprecation_check_when_alerting_arrives_lproxy_logging.update_values(alerting=["slack"])assert proxy_logging.deprecation_check_started is True- proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check.assert_called_once_with()+ proxy_logging.slack_alerting_instance.run_scheduled_deprecation_check.assert_called_once_with()def test_startup_event_propagates_init_callbacks_failure_raises(proxy_logging):