mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(proxy): name litellm_settings in the CLI boot error for a non-mapping value
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Has been cancelled
LiteLLM Rust DB / db-queries (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Has been cancelled
LiteLLM Rust DB / db-queries (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
This commit is contained in:
parent
4a9cb81563
commit
2dbbf01a7d
2 changed files with 23 additions and 4 deletions
|
|
@ -242,10 +242,12 @@ class _ConfigStartupOutputSettings(TypedDict, total=False):
|
|||
litellm_settings: ReadOnly[Annotated[StartupOutputSettings | None, BeforeValidator(_empty_as_none)]]
|
||||
|
||||
|
||||
class _ConfigLitellmSettings(TypedDict, total=False):
|
||||
litellm_settings: ReadOnly[Annotated[Mapping[str, object] | None, BeforeValidator(_empty_as_none)]]
|
||||
|
||||
|
||||
_CONFIG_STARTUP_OUTPUT_SETTINGS: Final = TypeAdapter(_ConfigStartupOutputSettings)
|
||||
_LITELLM_SETTINGS: Final[TypeAdapter[Mapping[str, object] | None]] = TypeAdapter(
|
||||
Annotated[Mapping[str, object] | None, BeforeValidator(_empty_as_none)]
|
||||
)
|
||||
_CONFIG_LITELLM_SETTINGS: Final = TypeAdapter(_ConfigLitellmSettings)
|
||||
|
||||
|
||||
def _apply_config_suppress_startup_output(litellm_settings: StartupOutputSettings | None) -> None:
|
||||
|
|
@ -1557,7 +1559,7 @@ def run_server(
|
|||
_config: Final = asyncio.run(proxy_config.get_config(config_file_path=config))
|
||||
|
||||
### LITELLM SETTINGS ###
|
||||
litellm_settings = _LITELLM_SETTINGS.validate_python(_config.get("litellm_settings"))
|
||||
litellm_settings = _CONFIG_LITELLM_SETTINGS.validate_python(_config).get("litellm_settings")
|
||||
_apply_config_logging_settings(
|
||||
_CONFIG_STARTUP_OUTPUT_SETTINGS.validate_python(_config).get("litellm_settings")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import uvicorn
|
|||
import yaml
|
||||
from click.testing import CliRunner
|
||||
from gunicorn.config import Config as GunicornConfig
|
||||
from pydantic import ValidationError
|
||||
from uvicorn.config import LOOP_FACTORIES
|
||||
from uvicorn.importer import import_from_string
|
||||
|
||||
|
|
@ -4294,6 +4295,22 @@ def test_an_empty_litellm_settings_boots_two_workers_from_a_cli_config(
|
|||
assert uvicorn_run.call_args.kwargs["workers"] == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("litellm_settings", ["callbacks", [{"callbacks": ["prometheus"]}]])
|
||||
def test_a_non_mapping_litellm_settings_fails_the_cli_boot_naming_the_key(
|
||||
tmp_path: Path, litellm_settings: object
|
||||
) -> None:
|
||||
config_file: Final = tmp_path / "config.yaml"
|
||||
config_file.write_text(yaml.dump({"model_list": [], "litellm_settings": litellm_settings}))
|
||||
unset: Final = frozenset(("DATABASE_URL", "DIRECT_URL", "CONFIG_FILE_PATH"))
|
||||
env: Final = {k: v for k, v in os.environ.items() if k not in unset}
|
||||
with patch.dict(os.environ, env, clear=True), patch("uvicorn.run") as uvicorn_run:
|
||||
result: Final = CliRunner().invoke(run_server, ["--config", str(config_file), "--num_workers", "2"])
|
||||
|
||||
assert isinstance(result.exception, ValidationError)
|
||||
assert "litellm_settings" in str(result.exception)
|
||||
uvicorn_run.assert_not_called()
|
||||
|
||||
|
||||
class TestEnforcePrismaMigrationCheckNoticeAroundTheConfigRead:
|
||||
"""With a config file, the `--enforce_prisma_migration_check` deprecation notice waits until the config
|
||||
is read, so a `json_logs: true` set only there makes it a JSON record, while `suppress_startup_output: true`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue