mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(router): address greptile review on least-busy tie-breaking
- Remove misleading `in ("1", "2")` assertion in stale-entry test; "2"
can never be returned since "1" is always the unique minimum after
filtering the stale "0" entry
- Replace unreachable `return random.choice(healthy_deployments)` fallback
with explicit ValueError guards; the old fallback was dead code after
the healthy-ID filter ensured min_deployment_ids is always non-empty,
and still raised IndexError on an empty list anyway
Made-with: Cursor
This commit is contained in:
parent
2f2e0cf0a8
commit
7df4a236f4
2 changed files with 8 additions and 7 deletions
|
|
@ -215,13 +215,15 @@ class LeastBusyLoggingHandler(CustomLogger):
|
|||
elif v == min_traffic:
|
||||
min_deployment_ids.append(k)
|
||||
|
||||
if min_deployment_ids:
|
||||
chosen_id = random.choice(min_deployment_ids)
|
||||
for m in healthy_deployments:
|
||||
if m["model_info"]["id"] == chosen_id:
|
||||
return m
|
||||
if not min_deployment_ids:
|
||||
raise ValueError("No healthy deployments available")
|
||||
|
||||
return random.choice(healthy_deployments)
|
||||
chosen_id = random.choice(min_deployment_ids)
|
||||
for m in healthy_deployments:
|
||||
if m["model_info"]["id"] == chosen_id:
|
||||
return m
|
||||
|
||||
raise ValueError(f"Chosen deployment id {chosen_id!r} not found in healthy_deployments")
|
||||
|
||||
def get_available_deployments(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ class TestLeastBusyTieBreaking:
|
|||
healthy_deployments=healthy,
|
||||
all_deployments=dict(counts_with_stale),
|
||||
)
|
||||
assert chosen["model_info"]["id"] in ("1", "2")
|
||||
assert chosen["model_info"]["id"] == "1"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue