mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
Fix CI lint and test failures
- Remove unused imports (datetime, timezone, ModelResponse) flagged by ruff. - Update test_cost_tracking_adds_two_callbacks_when_prisma_set to expect 2 callbacks on litellm.callbacks (not 1): ShadowEvalLogger now registers alongside _ProxyDBLogger in cost_tracking(). Test name already said 'two', now it actually tests for the correct count. - Format ShadowEvalSection.tsx/.test.tsx per prettier. Tests: 94/94 passing (lifecycle, shadow-eval, auto-router endpoints). Lint: ruff + prettier all clean. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
05aa3d4f36
commit
aba922ff40
4 changed files with 14 additions and 16 deletions
|
|
@ -25,7 +25,6 @@ import json
|
|||
import random
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
from datetime import datetime, timezone
|
||||
from typing import TYPE_CHECKING, Any, Final, Optional, cast
|
||||
|
||||
import litellm
|
||||
|
|
@ -35,7 +34,7 @@ from litellm.integrations.custom_logger import CustomLogger
|
|||
if TYPE_CHECKING:
|
||||
from litellm.proxy.utils import PrismaClient
|
||||
from litellm.router import Router
|
||||
from litellm.types.utils import ModelResponse, StandardLoggingPayload
|
||||
from litellm.types.utils import StandardLoggingPayload
|
||||
|
||||
_JSON_FENCE_RE: Final = re.compile(r"```(?:json)?\s*(.*?)\s*```", re.DOTALL | re.IGNORECASE)
|
||||
|
||||
|
|
|
|||
|
|
@ -485,6 +485,8 @@ def test_load_from_azure_key_vault_missing_uri_failure_is_swallowed(monkeypatch)
|
|||
|
||||
|
||||
def test_cost_tracking_adds_two_callbacks_when_prisma_set(monkeypatch):
|
||||
"""_ProxyDBLogger and ShadowEvalLogger both register on litellm.callbacks;
|
||||
only _ProxyDBLogger also registers on _async_success_callback."""
|
||||
import litellm
|
||||
|
||||
fake_prisma = MagicMock()
|
||||
|
|
@ -503,7 +505,7 @@ def test_cost_tracking_adds_two_callbacks_when_prisma_set(monkeypatch):
|
|||
"prisma_was_set": True,
|
||||
}
|
||||
assert normalize(observed) == {
|
||||
"added_to_callbacks": 1,
|
||||
"added_to_callbacks": 2,
|
||||
"added_to_async_success": 1,
|
||||
"prisma_was_set": True,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,20 +55,16 @@ const job = (overrides: Partial<ShadowEvalJob> = {}): ShadowEvalJob => ({
|
|||
...overrides,
|
||||
});
|
||||
|
||||
const mockHooks = ({
|
||||
jobs = [],
|
||||
detail = undefined,
|
||||
}: {
|
||||
jobs?: ShadowEvalJob[];
|
||||
detail?: ShadowEvalJob;
|
||||
}) => {
|
||||
const mockHooks = ({ jobs = [], detail = undefined }: { jobs?: ShadowEvalJob[]; detail?: ShadowEvalJob }) => {
|
||||
vi.mocked(useShadowEvalJobs).mockReturnValue({ data: jobs, error: null } as unknown as ReturnType<
|
||||
typeof useShadowEvalJobs
|
||||
>);
|
||||
vi.mocked(useShadowEvalJob).mockReturnValue({ data: detail } as unknown as ReturnType<typeof useShadowEvalJob>);
|
||||
vi.mocked(useStartShadowEval).mockReturnValue({ mutate: vi.fn(), isPending: false, error: null } as unknown as ReturnType<
|
||||
typeof useStartShadowEval
|
||||
>);
|
||||
vi.mocked(useStartShadowEval).mockReturnValue({
|
||||
mutate: vi.fn(),
|
||||
isPending: false,
|
||||
error: null,
|
||||
} as unknown as ReturnType<typeof useStartShadowEval>);
|
||||
vi.mocked(useStopShadowEval).mockReturnValue({ mutate: vi.fn(), isPending: false } as unknown as ReturnType<
|
||||
typeof useStopShadowEval
|
||||
>);
|
||||
|
|
|
|||
|
|
@ -140,15 +140,16 @@ const StartForm: React.FC<{ accessToken: string | null }> = ({ accessToken }) =>
|
|||
const start = useStartShadowEval();
|
||||
|
||||
const parsedPct = Number.parseFloat(percentage);
|
||||
const valid = Boolean(accessToken) && apiKeyId.trim() !== "" && routerName.trim() !== "" && parsedPct > 0 && parsedPct <= 100;
|
||||
const valid =
|
||||
Boolean(accessToken) && apiKeyId.trim() !== "" && routerName.trim() !== "" && parsedPct > 0 && parsedPct <= 100;
|
||||
|
||||
return (
|
||||
<Card size="sm">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-sm font-medium text-foreground">Start a shadow eval</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Duplicates a sampled slice of the key's traffic through the auto-router and has an LLM judge compare
|
||||
both answers blind. The router's answers are never served to users. Judge calls bill to the proxy — an
|
||||
Duplicates a sampled slice of the key's traffic through the auto-router and has an LLM judge compare both
|
||||
answers blind. The router's answers are never served to users. Judge calls bill to the proxy — an
|
||||
estimate is shown before anything runs.
|
||||
</p>
|
||||
</CardHeader>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue