mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-15 09:12:18 +00:00
refactor(proxy): remove dead DynamoDB implementation
This commit is contained in:
parent
add7dea9aa
commit
9dc591fc20
6 changed files with 0 additions and 133 deletions
|
|
@ -1,44 +0,0 @@
|
|||
from typing import Literal
|
||||
|
||||
|
||||
class CustomDB:
|
||||
"""
|
||||
Implements a base class that we expect any custom db implementation (e.g. DynamoDB) to follow
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def get_data(self, key: str, table_name: Literal["user", "key", "config"]):
|
||||
"""
|
||||
Check if key valid
|
||||
"""
|
||||
|
||||
def insert_data(self, value: object, table_name: Literal["user", "key", "config"]):
|
||||
"""
|
||||
For new key / user logic
|
||||
"""
|
||||
|
||||
def update_data(self, key: str, value: object, table_name: Literal["user", "key", "config"]):
|
||||
"""
|
||||
For cost tracking logic
|
||||
"""
|
||||
|
||||
def delete_data(self, keys: list[str], table_name: Literal["user", "key", "config"]):
|
||||
"""
|
||||
For /key/delete endpoint s
|
||||
"""
|
||||
|
||||
def connect(
|
||||
self,
|
||||
):
|
||||
"""
|
||||
For connecting to db and creating / updating any tables
|
||||
"""
|
||||
|
||||
def disconnect(
|
||||
self,
|
||||
):
|
||||
"""
|
||||
For closing connection on server shutdown
|
||||
"""
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
"""
|
||||
Deprecated. Only PostgresSQL is supported.
|
||||
"""
|
||||
|
||||
from typing import Final
|
||||
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.proxy._types import DynamoDBArgs
|
||||
from litellm.proxy.db.base_client import CustomDB
|
||||
|
||||
|
||||
class DynamoDBWrapper(CustomDB):
|
||||
from aiodynamo.credentials import Credentials, StaticCredentials
|
||||
|
||||
credentials: Credentials
|
||||
|
||||
def __init__(self, database_arguments: DynamoDBArgs):
|
||||
from aiodynamo.models import PayPerRequest, Throughput
|
||||
|
||||
self.throughput_type = None
|
||||
if database_arguments.billing_mode == "PAY_PER_REQUEST":
|
||||
self.throughput_type = PayPerRequest()
|
||||
elif database_arguments.billing_mode == "PROVISIONED_THROUGHPUT":
|
||||
if (
|
||||
database_arguments.read_capacity_units is not None
|
||||
and isinstance(database_arguments.read_capacity_units, int)
|
||||
and database_arguments.write_capacity_units is not None
|
||||
and isinstance(database_arguments.write_capacity_units, int)
|
||||
):
|
||||
self.throughput_type = Throughput(
|
||||
read=database_arguments.read_capacity_units,
|
||||
write=database_arguments.write_capacity_units,
|
||||
)
|
||||
else:
|
||||
raise Exception(
|
||||
f"Invalid args passed in. Need to set both read_capacity_units and write_capacity_units. Args passed in - {database_arguments}"
|
||||
)
|
||||
self.database_arguments = database_arguments
|
||||
self.region_name = database_arguments.region_name
|
||||
|
||||
def set_env_vars_based_on_arn(self):
|
||||
if self.database_arguments.aws_role_name is None:
|
||||
return
|
||||
verbose_proxy_logger.debug("DynamoDB: setting env vars based on arn=%s", self.database_arguments.aws_role_name)
|
||||
import os
|
||||
|
||||
import boto3
|
||||
|
||||
sts_client: Final = boto3.client("sts")
|
||||
|
||||
# call 1
|
||||
sts_client.assume_role_with_web_identity(
|
||||
RoleArn=self.database_arguments.aws_role_name,
|
||||
RoleSessionName=self.database_arguments.aws_session_name,
|
||||
WebIdentityToken=self.database_arguments.aws_web_identity_token,
|
||||
)
|
||||
|
||||
# call 2
|
||||
assumed_role: Final = sts_client.assume_role(
|
||||
RoleArn=self.database_arguments.assume_role_aws_role_name,
|
||||
RoleSessionName=self.database_arguments.assume_role_aws_session_name,
|
||||
)
|
||||
|
||||
aws_access_key_id: Final = assumed_role["Credentials"]["AccessKeyId"]
|
||||
aws_secret_access_key: Final = assumed_role["Credentials"]["SecretAccessKey"]
|
||||
aws_session_token: Final = assumed_role["Credentials"]["SessionToken"]
|
||||
|
||||
verbose_proxy_logger.debug("Got STS assumed Role, aws_access_key_id=%s", aws_access_key_id)
|
||||
# set these in the env so aiodynamo can use them
|
||||
os.environ["AWS_ACCESS_KEY_ID"] = aws_access_key_id
|
||||
os.environ["AWS_SECRET_ACCESS_KEY"] = aws_secret_access_key
|
||||
os.environ["AWS_SESSION_TOKEN"] = aws_session_token
|
||||
|
|
@ -288,7 +288,6 @@ ci = [
|
|||
"traceloop-sdk==0.34.0",
|
||||
"detect-secrets==1.5.0",
|
||||
"PyGithub==2.8.1",
|
||||
"aiodynamo==24.7",
|
||||
"argon2-cffi==25.1.0",
|
||||
"assemblyai==0.52.4",
|
||||
"jsonlines==4.0.0",
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ from litellm.types.proxy.management_endpoints.ui_sso import (
|
|||
LiteLLM_UpperboundKeyGenerateParams,
|
||||
)
|
||||
from litellm.proxy._types import (
|
||||
DynamoDBArgs,
|
||||
GenerateKeyRequest,
|
||||
KeyRequest,
|
||||
NewCustomerRequest,
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ from litellm.types.proxy.management_endpoints.ui_sso import (
|
|||
LiteLLM_UpperboundKeyGenerateParams,
|
||||
)
|
||||
from litellm.proxy._types import (
|
||||
DynamoDBArgs,
|
||||
GenerateKeyRequest,
|
||||
KeyRequest,
|
||||
NewCustomerRequest,
|
||||
|
|
|
|||
14
uv.lock
generated
14
uv.lock
generated
|
|
@ -62,18 +62,6 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/d4/ea/3a5b160cfd51c67759b08748051094d9365ceff18127633d0021950c9860/a2a_sdk-1.1.0-py3-none-any.whl", hash = "sha256:d7f5846caf18033d8bf3108b11ec827dd8dd32f867c98848ede0e39474be93be", size = 241886, upload-time = "2026-05-29T09:34:41.484Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aiodynamo"
|
||||
version = "24.7"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "yarl" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/2a/31/c455ae437c1ed5a9e354e5aca2b616599fd0f9c36064529cecb40663a368/aiodynamo-24.7.tar.gz", hash = "sha256:6b34c1505a4aca372d60d140b9cbe7934650d1daa360e55a1e090d86af871dbb", size = 25431, upload-time = "2024-07-13T08:38:40.674Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/35/66/a08e633c33083fb6fe84745f5b3ab9833d356afa702e08a4136c0d615e0d/aiodynamo-24.7-py3-none-any.whl", hash = "sha256:4749855dad14e0fe96b09e2d3604582f4bad156b18da90f9612260fd06523913", size = 28718, upload-time = "2024-07-13T08:38:39.141Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aiofiles"
|
||||
version = "24.1.0"
|
||||
|
|
@ -5115,7 +5103,6 @@ benchmarks = [
|
|||
{ name = "pytest-codspeed" },
|
||||
]
|
||||
ci = [
|
||||
{ name = "aiodynamo" },
|
||||
{ name = "anthropic" },
|
||||
{ name = "argon2-cffi" },
|
||||
{ name = "assemblyai" },
|
||||
|
|
@ -5344,7 +5331,6 @@ benchmarks = [
|
|||
{ name = "pytest-codspeed", specifier = "==4.3.0" },
|
||||
]
|
||||
ci = [
|
||||
{ name = "aiodynamo", specifier = "==24.7" },
|
||||
{ name = "anthropic", specifier = "==0.84.0" },
|
||||
{ name = "argon2-cffi", specifier = "==25.1.0" },
|
||||
{ name = "assemblyai", specifier = "==0.52.4" },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue