Skip to content

Commit

Permalink
(fix) undo changes that led were trying to control prisma connections
Browse files Browse the repository at this point in the history
ishaan-jaff committed Jan 6, 2024
1 parent 04c04d6 commit 6011c5c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions litellm/proxy/proxy_server.py
Original file line number Diff line number Diff line change
@@ -307,11 +307,10 @@ async def user_api_key_auth(
)


async def prisma_setup(database_url: Optional[str]):
def prisma_setup(database_url: Optional[str]):
global prisma_client, proxy_logging_obj, user_api_key_cache
if (
database_url is not None and prisma_client is None
): # don't re-initialize prisma client after initial init

if database_url is not None:
try:
prisma_client = PrismaClient(
database_url=database_url, proxy_logging_obj=proxy_logging_obj
@@ -320,8 +319,6 @@ async def prisma_setup(database_url: Optional[str]):
print_verbose(
f"Error when initializing prisma, Ensure you run pip install prisma {str(e)}"
)
if prisma_client is not None and prisma_client.db.is_connected() == False:
await prisma_client.connect()


def load_from_azure_key_vault(use_azure_key_vault: bool = False):
@@ -535,7 +532,7 @@ async def get_config(self, config_file_path: Optional[str] = None) -> dict:
prisma_client is not None
and litellm.get_secret("SAVE_CONFIG_TO_DB", False) == True
):
await prisma_setup(database_url=None) # in case it's not been connected yet
prisma_setup(database_url=None) # in case it's not been connected yet
_tasks = []
keys = [
"model_list",
@@ -765,7 +762,7 @@ async def load_config(
print_verbose(f"GOING INTO LITELLM.GET_SECRET!")
database_url = litellm.get_secret(database_url)
print_verbose(f"RETRIEVED DB URL: {database_url}")
await prisma_setup(database_url=database_url)
prisma_setup(database_url=database_url)
## COST TRACKING ##
cost_tracking()
### MASTER KEY ###
@@ -1118,6 +1115,10 @@ async def startup_event():
_run_background_health_check()
) # start the background health check coroutine.

print_verbose(f"prisma client - {prisma_client}")
if prisma_client:
await prisma_client.connect()

if prisma_client is not None and master_key is not None:
# add master key to db
await generate_key_helper_fn(

0 comments on commit 6011c5c

Please sign in to comment.