mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-27 06:13:07 +00:00
fix(proxy): keep the --enforce_prisma_migration_check notice on --health and --test
This PR moved the deprecation notice after the config is read, so that a
json_logs set only in the config applies to it; --health and --test return
before that point and stopped printing it, a visible change main did not
have. The notice is now also emitted before those two returns, through the
same helper, so a deployment running `litellm --health
--enforce_prisma_migration_check` still learns the flag is dead, as on main.
A normal server start emits it once, after the config, as in the previous
commit.
Red on 2d7a2d6844, green here: tests/unit/proxy/test_proxy_cli.py asserts
the notice on --health and on --test.
This commit is contained in:
parent
2d7a2d6844
commit
f6f5957d16
2 changed files with 28 additions and 5 deletions
|
|
@ -203,6 +203,14 @@ def deprecated_v2_flag_passed_on_cli() -> bool:
|
|||
return ctx.get_parameter_source("use_v2_migration_resolver") is ParameterSource.COMMANDLINE
|
||||
|
||||
|
||||
def _print_enforce_prisma_migration_check_notice() -> None:
|
||||
print_startup_message(
|
||||
"\033[1;33mLiteLLM Proxy: --enforce_prisma_migration_check is "
|
||||
"deprecated and has no effect, because the proxy always exits "
|
||||
"when database setup fails at startup. You can safely remove it.\033[0m",
|
||||
)
|
||||
|
||||
|
||||
class ProxyInitializationHelpers:
|
||||
@staticmethod
|
||||
def echo_litellm_version():
|
||||
|
|
@ -1177,6 +1185,9 @@ def run_server(
|
|||
return
|
||||
if model and "ollama" in model and api_base is None:
|
||||
ProxyInitializationHelpers.run_ollama_serve()
|
||||
if enforce_prisma_migration_check and (health is True or test is True):
|
||||
# --health and --test return before the config is read, where a server start emits the notice
|
||||
_print_enforce_prisma_migration_check_notice()
|
||||
if health is True:
|
||||
ProxyInitializationHelpers.run_health_check(host, port)
|
||||
return
|
||||
|
|
@ -1360,11 +1371,7 @@ def run_server(
|
|||
|
||||
# After the config is read, so a json_logs set only in the config applies to this notice too.
|
||||
if enforce_prisma_migration_check:
|
||||
print_startup_message(
|
||||
"\033[1;33mLiteLLM Proxy: --enforce_prisma_migration_check is "
|
||||
"deprecated and has no effect, because the proxy always exits "
|
||||
"when database setup fails at startup. You can safely remove it.\033[0m",
|
||||
)
|
||||
_print_enforce_prisma_migration_check_notice()
|
||||
# Handle database URL construction when no config file is used
|
||||
if config is None and os.getenv("DATABASE_URL") is None:
|
||||
# Use helper function to construct DATABASE_URL from individual variables
|
||||
|
|
|
|||
|
|
@ -2872,6 +2872,22 @@ class TestRunServerDbSetup:
|
|||
mock_setup_database.assert_called_once_with(use_migrate=True, use_v2_resolver=True)
|
||||
assert ("--enforce_prisma_migration_check is deprecated and has no effect" in capsys.readouterr().out) is warned
|
||||
|
||||
@pytest.mark.parametrize("argument", ("--health", "--test"), ids=("health", "test"))
|
||||
def test_the_retired_enforce_prisma_migration_check_opt_in_warns_on_health_and_test(self, argument, capsys):
|
||||
"""`--health` and `--test` return before the config is read, where a server start emits the
|
||||
deprecation line; they still print it, as they did when the notice came before those returns."""
|
||||
from litellm.proxy.proxy_cli import ProxyInitializationHelpers, run_server
|
||||
|
||||
with (
|
||||
patch.object(ProxyInitializationHelpers, "run_health_check") as mock_health_check,
|
||||
patch.object(ProxyInitializationHelpers, "run_test_chat_completion") as mock_test_chat,
|
||||
):
|
||||
run_server.main([argument, "--enforce_prisma_migration_check"], standalone_mode=False)
|
||||
|
||||
expected_calls = (1, 0) if argument == "--health" else (0, 1)
|
||||
assert (mock_health_check.call_count, mock_test_chat.call_count) == expected_calls
|
||||
assert "--enforce_prisma_migration_check is deprecated and has no effect" in capsys.readouterr().out
|
||||
|
||||
@patch("subprocess.run")
|
||||
@patch("atexit.register")
|
||||
@patch("litellm.proxy.db.prisma_client.PrismaManager.setup_database", return_value=True)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue