mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
fix: lint paths outside the repo root, sort imports
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
fcf2bbb376
commit
baade2ec8c
3 changed files with 15 additions and 8 deletions
|
|
@ -17,6 +17,7 @@ from litellm_proxy_extras import prisma_toolchain
|
|||
from litellm_proxy_extras._logging import logger
|
||||
from litellm_proxy_extras._redaction import _redact_credentials
|
||||
from litellm_proxy_extras.migration_lock import held_migration_lock
|
||||
from litellm_proxy_extras.migration_sources import materialize_prisma_dir
|
||||
from litellm_proxy_extras.prisma_toolchain import (
|
||||
PRISMA_COMMAND_TIMEOUT_ENV_VAR,
|
||||
PRISMA_MIGRATE_DEPLOY_TIMEOUT_ENV_VAR,
|
||||
|
|
@ -28,8 +29,10 @@ from litellm_proxy_extras.replica_identity import (
|
|||
REPLICA_IDENTITY_FULL_ENV_VAR,
|
||||
apply_replica_identity_full,
|
||||
)
|
||||
from litellm_proxy_extras.migration_sources import materialize_prisma_dir
|
||||
from litellm_proxy_extras.spend_logs.request_log_indexes import ensure_request_log_indexes, filter_request_log_index_diff
|
||||
from litellm_proxy_extras.spend_logs.request_log_indexes import (
|
||||
ensure_request_log_indexes,
|
||||
filter_request_log_index_diff,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import psycopg
|
||||
|
|
@ -721,7 +724,7 @@ class ProxyExtrasDBManager:
|
|||
def _prisma_schema_param(url: str) -> Optional[str]:
|
||||
"""The `schema` query param Prisma uses to pick its target schema,
|
||||
or None when the URL does not set one."""
|
||||
from urllib.parse import urlparse, parse_qsl
|
||||
from urllib.parse import parse_qsl, urlparse
|
||||
|
||||
return next(
|
||||
(v for k, v in parse_qsl(urlparse(url).query) if k == "schema"),
|
||||
|
|
|
|||
|
|
@ -22,11 +22,15 @@ TABLE_RE: Final = re.compile(r"\bLiteLLM_SpendLogs\b", re.IGNORECASE)
|
|||
MODEL_BLOCK_RE: Final = re.compile(r"^model LiteLLM_SpendLogs \{\n.*?^\}\n", re.MULTILINE | re.DOTALL)
|
||||
|
||||
|
||||
def _shown(path: Path) -> Path:
|
||||
return path.relative_to(REPO_ROOT) if path.is_relative_to(REPO_ROOT) else path
|
||||
|
||||
|
||||
def misplaced_migrations(shared_migrations: Path) -> tuple[str, ...]:
|
||||
scripts: Final = sorted(shared_migrations.glob("*/migration.sql"))
|
||||
return tuple(
|
||||
f"{script.parent.name}/migration.sql mentions LiteLLM_SpendLogs; move the migration to "
|
||||
f"{SPEND_LOGS_DIR.relative_to(REPO_ROOT)}/migrations/"
|
||||
f"{_shown(SPEND_LOGS_DIR)}/migrations/"
|
||||
for script in scripts
|
||||
if TABLE_RE.search(script.read_text(encoding="utf-8"))
|
||||
)
|
||||
|
|
@ -36,11 +40,10 @@ def schema_copy_drift(schema: Path, spend_logs_dir: Path) -> tuple[str, ...]:
|
|||
block: Final = MODEL_BLOCK_RE.search(schema.read_text(encoding="utf-8"))
|
||||
copy: Final = spend_logs_dir / "LiteLLM_SpendLogs.prisma"
|
||||
if block is None:
|
||||
return (f"{schema.relative_to(REPO_ROOT)} has no `model LiteLLM_SpendLogs` block",)
|
||||
return (f"{_shown(schema)} has no `model LiteLLM_SpendLogs` block",)
|
||||
if not copy.is_file() or copy.read_text(encoding="utf-8") != block.group():
|
||||
return (
|
||||
f"{copy.relative_to(REPO_ROOT)} must equal the `model LiteLLM_SpendLogs` block in "
|
||||
f"{schema.relative_to(REPO_ROOT)}; copy the block over",
|
||||
f"{_shown(copy)} must equal the `model LiteLLM_SpendLogs` block in {_shown(schema)}; copy the block over",
|
||||
)
|
||||
return ()
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ class TestSchemaCopy:
|
|||
(tmp_path / "schema.prisma").write_text("model LiteLLM_Other {\n id String @id\n}\n", encoding="utf-8")
|
||||
(tmp_path / "spend_logs").mkdir()
|
||||
found: Final = checker.schema_copy_drift(tmp_path / "schema.prisma", tmp_path / "spend_logs")
|
||||
assert found == ("schema.prisma has no `model LiteLLM_SpendLogs` block",) or "no `model LiteLLM_SpendLogs`" in found[0]
|
||||
assert len(found) == 1
|
||||
assert "no `model LiteLLM_SpendLogs` block" in found[0]
|
||||
|
||||
|
||||
class TestExitCode:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue