build(pyproject.toml): add new dev dependencies - for type checking (#9631)

* build(pyproject.toml): add new dev dependencies - for type checking

* build: reformat files to fit black

* ci: reformat to fit black

* ci(test-litellm.yml): make tests run clear

* build(pyproject.toml): add ruff

* fix: fix ruff checks

* build(mypy/): fix mypy linting errors

* fix(hashicorp_secret_manager.py): fix passing cert for tls auth

* build(mypy/): resolve all mypy errors

* test: update test

* fix: fix black formatting

* build(pre-commit-config.yaml): use poetry run black

* fix(proxy_server.py): fix linting error

* fix: fix ruff safe representation error
This commit is contained in:
Krish Dholakia 2025-03-29 11:02:13 -07:00 committed by GitHub
parent 72198737f8
commit d7b294dd0a
214 changed files with 1553 additions and 1433 deletions

View file

@ -9,8 +9,8 @@ import time
sys.path.insert(
0, os.path.abspath("./")
) # Adds the parent directory to the system path
from litellm.secret_managers.aws_secret_manager import decrypt_env_var
from litellm._logging import verbose_proxy_logger
from litellm.secret_managers.aws_secret_manager import decrypt_env_var
if os.getenv("USE_AWS_KMS", None) is not None and os.getenv("USE_AWS_KMS") == "True":
## V2 IMPLEMENTATION OF AWS KMS - USER WANTS TO DECRYPT MULTIPLE KEYS IN THEIR ENV
@ -39,7 +39,9 @@ if not database_url:
)
exit(1)
else:
verbose_proxy_logger.info("Using existing DATABASE_URL environment variable") # Log existing DATABASE_URL
verbose_proxy_logger.info(
"Using existing DATABASE_URL environment variable"
) # Log existing DATABASE_URL
# Set DIRECT_URL to the value of DATABASE_URL if it is not set, required for migrations
direct_url = os.getenv("DIRECT_URL")
@ -63,12 +65,18 @@ while retry_count < max_retries and exit_code != 0:
# run prisma generate
verbose_proxy_logger.info("Running 'prisma generate'...")
result = subprocess.run(["prisma", "generate"], capture_output=True, text=True)
verbose_proxy_logger.info(f"'prisma generate' stdout: {result.stdout}") # Log stdout
verbose_proxy_logger.info(
f"'prisma generate' stdout: {result.stdout}"
) # Log stdout
exit_code = result.returncode
if exit_code != 0:
verbose_proxy_logger.info(f"'prisma generate' failed with exit code {exit_code}.")
verbose_proxy_logger.error(f"'prisma generate' stderr: {result.stderr}") # Log stderr
verbose_proxy_logger.info(
f"'prisma generate' failed with exit code {exit_code}."
)
verbose_proxy_logger.error(
f"'prisma generate' stderr: {result.stderr}"
) # Log stderr
# Run the Prisma db push command
verbose_proxy_logger.info("Running 'prisma db push --accept-data-loss'...")
@ -79,14 +87,20 @@ while retry_count < max_retries and exit_code != 0:
exit_code = result.returncode
if exit_code != 0:
verbose_proxy_logger.info(f"'prisma db push' stderr: {result.stderr}") # Log stderr
verbose_proxy_logger.error(f"'prisma db push' failed with exit code {exit_code}.")
verbose_proxy_logger.info(
f"'prisma db push' stderr: {result.stderr}"
) # Log stderr
verbose_proxy_logger.error(
f"'prisma db push' failed with exit code {exit_code}."
)
if retry_count < max_retries:
verbose_proxy_logger.info("Retrying in 10 seconds...")
time.sleep(10)
if retry_count == max_retries and exit_code != 0:
verbose_proxy_logger.error(f"Unable to push database changes after {max_retries} retries.")
verbose_proxy_logger.error(
f"Unable to push database changes after {max_retries} retries."
)
exit(1)
verbose_proxy_logger.info("Database push successful!")