mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
refactor(proxy): make the deprecation loop entrypoint public and drop a dead None check
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
a0a536216f
commit
816fa50394
4 changed files with 9 additions and 9 deletions
|
|
@ -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"""
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
return
|
||||
|
||||
try:
|
||||
|
|
@ -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 = True
|
||||
|
||||
def update_values(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -136,13 +136,13 @@ async def test_startup_event_schedules_deprecation_check_before_its_alert_type_i
|
|||
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.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_l
|
|||
proxy_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):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue