mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
test(proxy): regression test that load_config forwards callback_specific_params
This commit is contained in:
parent
b2798fd234
commit
26273eff1d
1 changed files with 50 additions and 0 deletions
|
|
@ -601,6 +601,56 @@ async def test_ProxyConfig_load_config_missing_file_raises(monkeypatch):
|
|||
await pc.load_config(router=None, config_file_path="/no/file.yaml")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ProxyConfig_load_config_forwards_callback_specific_params(
|
||||
tmp_path, monkeypatch
|
||||
):
|
||||
"""Regression: callback_settings from config must be forwarded to
|
||||
initialize_callbacks_on_proxy as callback_specific_params.
|
||||
|
||||
Callbacks like DatadogCostManagementLogger read their init params (e.g.
|
||||
cost_tag_keys) from callback_specific_params[<callback_name>]. If the
|
||||
argument is dropped at the call site, they silently initialize with empty
|
||||
params and the configured allowlist never takes effect.
|
||||
"""
|
||||
f = tmp_path / "c.yaml"
|
||||
f.write_text(
|
||||
"model_list: []\n"
|
||||
"general_settings: {}\n"
|
||||
"callback_settings:\n"
|
||||
" datadog_cost_management:\n"
|
||||
" cost_tag_keys:\n"
|
||||
" - capability\n"
|
||||
" - platform\n"
|
||||
" - ai_product\n"
|
||||
'litellm_settings:\n'
|
||||
' callbacks: ["datadog_cost_management"]\n'
|
||||
)
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", None)
|
||||
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", False)
|
||||
monkeypatch.delenv("LITELLM_CONFIG_BUCKET_NAME", raising=False)
|
||||
|
||||
captured = {}
|
||||
|
||||
def _fake_initialize_callbacks_on_proxy(**kwargs):
|
||||
captured.update(kwargs)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"litellm.proxy.proxy_server.initialize_callbacks_on_proxy",
|
||||
_fake_initialize_callbacks_on_proxy,
|
||||
)
|
||||
|
||||
pc = ProxyConfig()
|
||||
await pc.load_config(router=None, config_file_path=str(f))
|
||||
|
||||
# The callbacks branch must forward the loaded callback_settings.
|
||||
assert captured.get("callback_specific_params") == {
|
||||
"datadog_cost_management": {
|
||||
"cost_tag_keys": ["capability", "platform", "ai_product"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# ProxyConfig._init_non_llm_configs
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue