mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
Merge a95a166633 into 3930c5bab6
This commit is contained in:
commit
3b9b112be4
2 changed files with 46 additions and 2 deletions
|
|
@ -8571,8 +8571,10 @@ class Router:
|
|||
_, _all_deployments = self._common_checks_available_deployment(
|
||||
model=model,
|
||||
)
|
||||
# Deployment-id lookup returns a single dict; wrap it so cooldown
|
||||
# filtering still runs instead of reporting zero healthy copies.
|
||||
if isinstance(_all_deployments, dict):
|
||||
return []
|
||||
_all_deployments = [_all_deployments]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
@ -8599,8 +8601,10 @@ class Router:
|
|||
_, _all_deployments = self._common_checks_available_deployment(
|
||||
model=model,
|
||||
)
|
||||
# Deployment-id lookup returns a single dict; wrap it so cooldown
|
||||
# filtering still runs instead of reporting zero healthy copies.
|
||||
if isinstance(_all_deployments, dict):
|
||||
return [], _all_deployments
|
||||
_all_deployments = [_all_deployments]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -721,6 +721,46 @@ def test_get_healthy_deployments(model_list):
|
|||
)
|
||||
assert len(deployments) > 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_healthy_deployments_by_deployment_id():
|
||||
"""Routing by model_info.id must still return that deployment as healthy."""
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
router = Router(
|
||||
model_list=[
|
||||
{
|
||||
"model_name": "chat",
|
||||
"litellm_params": {"model": "openai/gpt-4o-mini", "api_key": "sk-test"},
|
||||
"model_info": {"id": "deploy-1"},
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
with patch(
|
||||
"litellm.router._get_cooldown_deployments",
|
||||
return_value=[],
|
||||
), patch(
|
||||
"litellm.router._async_get_cooldown_deployments",
|
||||
new_callable=AsyncMock,
|
||||
return_value=[],
|
||||
):
|
||||
sync_healthy, sync_all = router._get_healthy_deployments(
|
||||
model="deploy-1", parent_otel_span=None
|
||||
)
|
||||
async_healthy, async_all = await router._async_get_healthy_deployments(
|
||||
model="deploy-1", parent_otel_span=None
|
||||
)
|
||||
|
||||
assert len(sync_healthy) == 1
|
||||
assert sync_healthy[0]["model_info"]["id"] == "deploy-1"
|
||||
assert isinstance(sync_all, list) and len(sync_all) == 1
|
||||
|
||||
assert len(async_healthy) == 1
|
||||
assert async_healthy[0]["model_info"]["id"] == "deploy-1"
|
||||
assert isinstance(async_all, list) and len(async_all) == 1
|
||||
|
||||
|
||||
|
||||
|
||||
@pytest.mark.parametrize("sync_mode", [True, False])
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue