(test) test reading configs on proxy

This commit is contained in:
ishaan-jaff 2024-01-05 13:37:31 +05:30
parent aeee8fd3da
commit 13201edc4b

View file

@ -285,40 +285,50 @@ from litellm.proxy.proxy_server import ProxyConfig
def test_load_router_config(): def test_load_router_config():
try: try:
import asyncio
print("testing reading config") print("testing reading config")
# this is a basic config.yaml with only a model # this is a basic config.yaml with only a model
filepath = os.path.dirname(os.path.abspath(__file__)) filepath = os.path.dirname(os.path.abspath(__file__))
proxy_config = ProxyConfig() proxy_config = ProxyConfig()
result = proxy_config.load_config( result = asyncio.run(
proxy_config.load_config(
router=None, router=None,
config_file_path=f"{filepath}/example_config_yaml/simple_config.yaml", config_file_path=f"{filepath}/example_config_yaml/simple_config.yaml",
) )
)
print(result) print(result)
assert len(result[1]) == 1 assert len(result[1]) == 1
# this is a load balancing config yaml # this is a load balancing config yaml
result = load_router_config( result = asyncio.run(
proxy_config.load_config(
router=None, router=None,
config_file_path=f"{filepath}/example_config_yaml/azure_config.yaml", config_file_path=f"{filepath}/example_config_yaml/azure_config.yaml",
) )
)
print(result) print(result)
assert len(result[1]) == 2 assert len(result[1]) == 2
# config with general settings - custom callbacks # config with general settings - custom callbacks
result = load_router_config( result = asyncio.run(
proxy_config.load_config(
router=None, router=None,
config_file_path=f"{filepath}/example_config_yaml/azure_config.yaml", config_file_path=f"{filepath}/example_config_yaml/azure_config.yaml",
) )
)
print(result) print(result)
assert len(result[1]) == 2 assert len(result[1]) == 2
# tests for litellm.cache set from config # tests for litellm.cache set from config
print("testing reading proxy config for cache") print("testing reading proxy config for cache")
litellm.cache = None litellm.cache = None
load_router_config( asyncio.run(
proxy_config.load_config(
router=None, router=None,
config_file_path=f"{filepath}/example_config_yaml/cache_no_params.yaml", config_file_path=f"{filepath}/example_config_yaml/cache_no_params.yaml",
) )
)
assert litellm.cache is not None assert litellm.cache is not None
assert "redis_client" in vars( assert "redis_client" in vars(
litellm.cache.cache litellm.cache.cache
@ -330,11 +340,15 @@ def test_load_router_config():
"aembedding", "aembedding",
] # init with all call types ] # init with all call types
litellm.disable_cache()
print("testing reading proxy config for cache with params") print("testing reading proxy config for cache with params")
load_router_config( asyncio.run(
proxy_config.load_config(
router=None, router=None,
config_file_path=f"{filepath}/example_config_yaml/cache_with_params.yaml", config_file_path=f"{filepath}/example_config_yaml/cache_with_params.yaml",
) )
)
assert litellm.cache is not None assert litellm.cache is not None
print(litellm.cache) print(litellm.cache)
print(litellm.cache.supported_call_types) print(litellm.cache.supported_call_types)