litellm-proxy-extras 0.1.4__py3-none-any.whl → 0.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of litellm-proxy-extras might be problematic. Click here for more details.
- litellm_proxy_extras/migrations/20250412081753_team_member_permissions/migration.sql +3 -0
- litellm_proxy_extras/schema.prisma +1 -0
- litellm_proxy_extras/utils.py +101 -3
- {litellm_proxy_extras-0.1.4.dist-info → litellm_proxy_extras-0.1.7.dist-info}/METADATA +1 -1
- {litellm_proxy_extras-0.1.4.dist-info → litellm_proxy_extras-0.1.7.dist-info}/RECORD +7 -6
- {litellm_proxy_extras-0.1.4.dist-info → litellm_proxy_extras-0.1.7.dist-info}/LICENSE +0 -0
- {litellm_proxy_extras-0.1.4.dist-info → litellm_proxy_extras-0.1.7.dist-info}/WHEEL +0 -0
|
@@ -106,6 +106,7 @@ model LiteLLM_TeamTable {
|
|
|
106
106
|
updated_at DateTime @default(now()) @updatedAt @map("updated_at")
|
|
107
107
|
model_spend Json @default("{}")
|
|
108
108
|
model_max_budget Json @default("{}")
|
|
109
|
+
team_member_permissions String[] @default([])
|
|
109
110
|
model_id Int? @unique // id for LiteLLM_ModelTable -> stores team-level model aliases
|
|
110
111
|
litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
|
|
111
112
|
litellm_model_table LiteLLM_ModelTable? @relation(fields: [model_id], references: [id])
|
litellm_proxy_extras/utils.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import glob
|
|
1
2
|
import os
|
|
2
3
|
import random
|
|
3
4
|
import subprocess
|
|
4
5
|
import time
|
|
6
|
+
from pathlib import Path
|
|
5
7
|
from typing import Optional
|
|
6
8
|
|
|
7
9
|
from litellm_proxy_extras._logging import logger
|
|
@@ -14,6 +16,94 @@ def str_to_bool(value: Optional[str]) -> bool:
|
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
class ProxyExtrasDBManager:
|
|
19
|
+
@staticmethod
|
|
20
|
+
def _get_prisma_dir() -> str:
|
|
21
|
+
"""Get the path to the migrations directory"""
|
|
22
|
+
migrations_dir = os.path.dirname(__file__)
|
|
23
|
+
return migrations_dir
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def _create_baseline_migration(schema_path: str) -> bool:
|
|
27
|
+
"""Create a baseline migration for an existing database"""
|
|
28
|
+
prisma_dir = ProxyExtrasDBManager._get_prisma_dir()
|
|
29
|
+
prisma_dir_path = Path(prisma_dir)
|
|
30
|
+
init_dir = prisma_dir_path / "migrations" / "0_init"
|
|
31
|
+
|
|
32
|
+
# Create migrations/0_init directory
|
|
33
|
+
init_dir.mkdir(parents=True, exist_ok=True)
|
|
34
|
+
|
|
35
|
+
# Generate migration SQL file
|
|
36
|
+
migration_file = init_dir / "migration.sql"
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
# Generate migration diff with increased timeout
|
|
40
|
+
subprocess.run(
|
|
41
|
+
[
|
|
42
|
+
"prisma",
|
|
43
|
+
"migrate",
|
|
44
|
+
"diff",
|
|
45
|
+
"--from-empty",
|
|
46
|
+
"--to-schema-datamodel",
|
|
47
|
+
str(schema_path),
|
|
48
|
+
"--script",
|
|
49
|
+
],
|
|
50
|
+
stdout=open(migration_file, "w"),
|
|
51
|
+
check=True,
|
|
52
|
+
timeout=30,
|
|
53
|
+
) # 30 second timeout
|
|
54
|
+
|
|
55
|
+
# Mark migration as applied with increased timeout
|
|
56
|
+
subprocess.run(
|
|
57
|
+
[
|
|
58
|
+
"prisma",
|
|
59
|
+
"migrate",
|
|
60
|
+
"resolve",
|
|
61
|
+
"--applied",
|
|
62
|
+
"0_init",
|
|
63
|
+
],
|
|
64
|
+
check=True,
|
|
65
|
+
timeout=30,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return True
|
|
69
|
+
except subprocess.TimeoutExpired:
|
|
70
|
+
logger.warning(
|
|
71
|
+
"Migration timed out - the database might be under heavy load."
|
|
72
|
+
)
|
|
73
|
+
return False
|
|
74
|
+
except subprocess.CalledProcessError as e:
|
|
75
|
+
logger.warning(f"Error creating baseline migration: {e}")
|
|
76
|
+
return False
|
|
77
|
+
|
|
78
|
+
@staticmethod
|
|
79
|
+
def _get_migration_names(migrations_dir: str) -> list:
|
|
80
|
+
"""Get all migration directory names from the migrations folder"""
|
|
81
|
+
migration_paths = glob.glob(f"{migrations_dir}/migrations/*/migration.sql")
|
|
82
|
+
logger.info(f"Found {len(migration_paths)} migrations at {migrations_dir}")
|
|
83
|
+
return [Path(p).parent.name for p in migration_paths]
|
|
84
|
+
|
|
85
|
+
@staticmethod
|
|
86
|
+
def _resolve_all_migrations(migrations_dir: str):
|
|
87
|
+
"""Mark all existing migrations as applied"""
|
|
88
|
+
migration_names = ProxyExtrasDBManager._get_migration_names(migrations_dir)
|
|
89
|
+
logger.info(f"Resolving {len(migration_names)} migrations")
|
|
90
|
+
for migration_name in migration_names:
|
|
91
|
+
try:
|
|
92
|
+
logger.info(f"Resolving migration: {migration_name}")
|
|
93
|
+
subprocess.run(
|
|
94
|
+
["prisma", "migrate", "resolve", "--applied", migration_name],
|
|
95
|
+
timeout=60,
|
|
96
|
+
check=True,
|
|
97
|
+
capture_output=True,
|
|
98
|
+
text=True,
|
|
99
|
+
)
|
|
100
|
+
logger.debug(f"Resolved migration: {migration_name}")
|
|
101
|
+
except subprocess.CalledProcessError as e:
|
|
102
|
+
if "is already recorded as applied in the database." not in e.stderr:
|
|
103
|
+
logger.warning(
|
|
104
|
+
f"Failed to resolve migration {migration_name}: {e.stderr}"
|
|
105
|
+
)
|
|
106
|
+
|
|
17
107
|
@staticmethod
|
|
18
108
|
def setup_database(schema_path: str, use_migrate: bool = False) -> bool:
|
|
19
109
|
"""
|
|
@@ -30,7 +120,7 @@ class ProxyExtrasDBManager:
|
|
|
30
120
|
use_migrate = str_to_bool(os.getenv("USE_PRISMA_MIGRATE")) or use_migrate
|
|
31
121
|
for attempt in range(4):
|
|
32
122
|
original_dir = os.getcwd()
|
|
33
|
-
migrations_dir =
|
|
123
|
+
migrations_dir = ProxyExtrasDBManager._get_prisma_dir()
|
|
34
124
|
os.chdir(migrations_dir)
|
|
35
125
|
|
|
36
126
|
try:
|
|
@@ -55,8 +145,16 @@ class ProxyExtrasDBManager:
|
|
|
55
145
|
"P3005" in e.stderr
|
|
56
146
|
and "database schema is not empty" in e.stderr
|
|
57
147
|
):
|
|
58
|
-
logger.info(
|
|
59
|
-
|
|
148
|
+
logger.info(
|
|
149
|
+
"Database schema is not empty, creating baseline migration"
|
|
150
|
+
)
|
|
151
|
+
ProxyExtrasDBManager._create_baseline_migration(schema_path)
|
|
152
|
+
logger.info(
|
|
153
|
+
"Baseline migration created, resolving all migrations"
|
|
154
|
+
)
|
|
155
|
+
ProxyExtrasDBManager._resolve_all_migrations(migrations_dir)
|
|
156
|
+
logger.info("✅ All migrations resolved.")
|
|
157
|
+
return True
|
|
60
158
|
else:
|
|
61
159
|
# Use prisma db push with increased timeout
|
|
62
160
|
subprocess.run(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: litellm-proxy-extras
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package.
|
|
5
5
|
Author: BerriAI
|
|
6
6
|
Requires-Python: >=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
|
|
@@ -6,10 +6,11 @@ litellm_proxy_extras/migrations/20250327180120_add_api_requests_to_daily_user_ta
|
|
|
6
6
|
litellm_proxy_extras/migrations/20250329084805_new_cron_job_table/migration.sql,sha256=eZNDwrzKtWFXkTqOKb9JS4hzum1dI-VTXvMqzhryfxc,404
|
|
7
7
|
litellm_proxy_extras/migrations/20250331215456_track_success_and_failed_requests_daily_agg_table/migration.sql,sha256=tyeLY6u8KFyw71osCBM-sdjhIgvHoFCK88cIx8dExNY,178
|
|
8
8
|
litellm_proxy_extras/migrations/20250411215431_add_managed_file_table/migration.sql,sha256=Yu2K37Q90LDhxsFo_64sH0PXdSQ3sHs45Lqzxv2t_20,625
|
|
9
|
+
litellm_proxy_extras/migrations/20250412081753_team_member_permissions/migration.sql,sha256=v3vDx5lb6SLCzXCe_A2NZj7zzmucRXM08aQun_G_MkE,120
|
|
9
10
|
litellm_proxy_extras/migrations/migration_lock.toml,sha256=HbF6jQUaoTYRBzZ1LF4fi37ZK26o6AMRL7viSXBHwhA,24
|
|
10
|
-
litellm_proxy_extras/schema.prisma,sha256=
|
|
11
|
-
litellm_proxy_extras/utils.py,sha256=
|
|
12
|
-
litellm_proxy_extras-0.1.
|
|
13
|
-
litellm_proxy_extras-0.1.
|
|
14
|
-
litellm_proxy_extras-0.1.
|
|
15
|
-
litellm_proxy_extras-0.1.
|
|
11
|
+
litellm_proxy_extras/schema.prisma,sha256=AJs-oTl488I539rej87DQw73l2x28IhLNGw2gZ6T8AA,14579
|
|
12
|
+
litellm_proxy_extras/utils.py,sha256=2CQEBosLTjXpGEBwx3sGYglSD4QNy609iV4Ppo9AJdo,7087
|
|
13
|
+
litellm_proxy_extras-0.1.7.dist-info/LICENSE,sha256=sXDWv46INd01fgEWgdsCj01R4vsOqJIFj1bgH7ObgnM,1419
|
|
14
|
+
litellm_proxy_extras-0.1.7.dist-info/METADATA,sha256=OEh02aKnCi3sXljyI2d8IrzEH0IFyTBUrSHOgSE-ECM,1267
|
|
15
|
+
litellm_proxy_extras-0.1.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
16
|
+
litellm_proxy_extras-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|