litellm-proxy-extras 0.1.1__tar.gz → 0.1.2__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: litellm-proxy-extras
3
- Version: 0.1.1
3
+ Version: 0.1.2
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.*
@@ -0,0 +1,12 @@
1
+ import logging
2
+
3
+ # Set up package logger
4
+ logger = logging.getLogger("litellm_proxy_extras")
5
+ if not logger.handlers: # Only add handler if none exists
6
+ handler = logging.StreamHandler()
7
+ formatter = logging.Formatter(
8
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
9
+ )
10
+ handler.setFormatter(formatter)
11
+ logger.addHandler(handler)
12
+ logger.setLevel(logging.INFO)
@@ -0,0 +1,4 @@
1
+ -- AlterTable
2
+ ALTER TABLE "LiteLLM_DailyUserSpend" ADD COLUMN "failed_requests" INTEGER NOT NULL DEFAULT 0,
3
+ ADD COLUMN "successful_requests" INTEGER NOT NULL DEFAULT 0;
4
+
@@ -0,0 +1,80 @@
1
+ import os
2
+ import random
3
+ import subprocess
4
+ import time
5
+ from typing import Optional
6
+
7
+ from litellm_proxy_extras._logging import logger
8
+
9
+
10
+ def str_to_bool(value: Optional[str]) -> bool:
11
+ if value is None:
12
+ return False
13
+ return value.lower() in ("true", "1", "t", "y", "yes")
14
+
15
+
16
+ class ProxyExtrasDBManager:
17
+ @staticmethod
18
+ def setup_database(schema_path: str, use_migrate: bool = False) -> bool:
19
+ """
20
+ Set up the database using either prisma migrate or prisma db push
21
+ Uses migrations from litellm-proxy-extras package
22
+
23
+ Args:
24
+ schema_path (str): Path to the Prisma schema file
25
+ use_migrate (bool): Whether to use prisma migrate instead of db push
26
+
27
+ Returns:
28
+ bool: True if setup was successful, False otherwise
29
+ """
30
+ use_migrate = str_to_bool(os.getenv("USE_PRISMA_MIGRATE")) or use_migrate
31
+ for attempt in range(4):
32
+ original_dir = os.getcwd()
33
+ schema_dir = os.path.dirname(schema_path)
34
+ os.chdir(schema_dir)
35
+
36
+ try:
37
+ if use_migrate:
38
+ logger.info("Running prisma migrate deploy")
39
+ try:
40
+ # Set migrations directory for Prisma
41
+ subprocess.run(
42
+ ["prisma", "migrate", "deploy"],
43
+ timeout=60,
44
+ check=True,
45
+ capture_output=True,
46
+ text=True,
47
+ )
48
+ logger.info("prisma migrate deploy completed")
49
+ return True
50
+ except subprocess.CalledProcessError as e:
51
+ logger.info(f"prisma db error: {e.stderr}, e: {e.stdout}")
52
+ if (
53
+ "P3005" in e.stderr
54
+ and "database schema is not empty" in e.stderr
55
+ ):
56
+ logger.info("Error: Database schema is not empty")
57
+ return False
58
+ else:
59
+ # Use prisma db push with increased timeout
60
+ subprocess.run(
61
+ ["prisma", "db", "push", "--accept-data-loss"],
62
+ timeout=60,
63
+ check=True,
64
+ )
65
+ return True
66
+ except subprocess.TimeoutExpired:
67
+ logger.info(f"Attempt {attempt + 1} timed out")
68
+ time.sleep(random.randrange(5, 15))
69
+ except subprocess.CalledProcessError as e:
70
+ attempts_left = 3 - attempt
71
+ retry_msg = (
72
+ f" Retrying... ({attempts_left} attempts left)"
73
+ if attempts_left > 0
74
+ else ""
75
+ )
76
+ logger.info(f"The process failed to execute. Details: {e}.{retry_msg}")
77
+ time.sleep(random.randrange(5, 15))
78
+ finally:
79
+ os.chdir(original_dir)
80
+ return False
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "litellm-proxy-extras"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package."
5
5
  authors = ["BerriAI"]
6
6
  readme = "README.md"
@@ -22,7 +22,9 @@ requires = ["poetry-core"]
22
22
  build-backend = "poetry.core.masonry.api"
23
23
 
24
24
  [tool.commitizen]
25
- version = "0.1.1"
25
+ version = "0.1.2"
26
26
  version_files = [
27
- "pyproject.toml:^version"
27
+ "pyproject.toml:version",
28
+ "../requirements.txt:litellm-proxy-extras==",
29
+ "../pyproject.toml:litellm-proxy-extras = {version = \""
28
30
  ]