mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
(temp) debug prisma logs
This commit is contained in:
parent
6d1b0162fa
commit
87e69bb6f6
2 changed files with 24 additions and 16 deletions
|
@ -1142,15 +1142,6 @@ async def startup_event():
|
|||
global prisma_client, master_key, use_background_health_checks, llm_router, llm_model_list, general_settings
|
||||
import json
|
||||
|
||||
### LOAD MASTER KEY ###
|
||||
# check if master key set in environment - load from there
|
||||
master_key = litellm.get_secret("LITELLM_MASTER_KEY", None)
|
||||
|
||||
### CONNECT TO DB ###
|
||||
# check if DATABASE_URL in environment - load from there
|
||||
if os.getenv("DATABASE_URL", None) is not None and prisma_client is None:
|
||||
prisma_setup(database_url=os.getenv("DATABASE_URL"))
|
||||
|
||||
### LOAD CONFIG ###
|
||||
worker_config = litellm.get_secret("WORKER_CONFIG")
|
||||
verbose_proxy_logger.debug(f"worker_config: {worker_config}")
|
||||
|
@ -1168,6 +1159,15 @@ async def startup_event():
|
|||
_run_background_health_check()
|
||||
) # start the background health check coroutine.
|
||||
|
||||
### LOAD MASTER KEY ###
|
||||
# check if master key set in environment - load from there
|
||||
master_key = litellm.get_secret("LITELLM_MASTER_KEY", None)
|
||||
|
||||
### CONNECT TO DB ###
|
||||
# check if DATABASE_URL in environment - load from there
|
||||
if os.getenv("DATABASE_URL", None) is not None and prisma_client is None:
|
||||
prisma_setup(database_url=os.getenv("DATABASE_URL"))
|
||||
|
||||
verbose_proxy_logger.debug(f"prisma client - {prisma_client}")
|
||||
if prisma_client:
|
||||
await prisma_client.connect()
|
||||
|
|
|
@ -259,9 +259,11 @@ class PrismaClient:
|
|||
if os.getenv("DATABASE_URL", None) is None: # setup hasn't taken place
|
||||
os.environ["DATABASE_URL"] = database_url
|
||||
|
||||
from prisma import Prisma # type: ignore
|
||||
|
||||
try:
|
||||
print_verbose("about to init prisma")
|
||||
from prisma import Prisma # type: ignore
|
||||
|
||||
print_verbose("imported prisma")
|
||||
self.db = Prisma(
|
||||
http={
|
||||
"limits": httpx.Limits(
|
||||
|
@ -269,7 +271,10 @@ class PrismaClient:
|
|||
)
|
||||
}
|
||||
) # Client to connect to Prisma db
|
||||
print_verbose(self.db)
|
||||
except Exception as e:
|
||||
print_verbose(f"EXCEPTION E {str(e)}")
|
||||
|
||||
# prisma raises - run `prisma generate` before you can use the client.
|
||||
if "run `prisma generate` before you can use the client" in str(e):
|
||||
# Save the current working directory
|
||||
|
@ -280,12 +285,15 @@ class PrismaClient:
|
|||
os.chdir(dname)
|
||||
|
||||
try:
|
||||
if not os.path.exists("prisma"):
|
||||
subprocess.run(["prisma", "generate"])
|
||||
subprocess.run(["prisma", "generate"])
|
||||
|
||||
subprocess.run(
|
||||
["prisma", "db", "push", "--accept-data-loss"]
|
||||
) # this looks like a weird edge case when prisma just wont start on render. we need to have the --accept-data-loss
|
||||
subprocess.run(
|
||||
["prisma", "db", "push", "--accept-data-loss"]
|
||||
) # this looks like a weird edge case when prisma just wont start on render. we need to have the --accept-data-loss
|
||||
except Exception as gen_error:
|
||||
print_verbose(
|
||||
f"EXCEPTION when doing prisma generate E {str(gen_error)}"
|
||||
)
|
||||
finally:
|
||||
os.chdir(original_dir)
|
||||
self.db = Prisma(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue