mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
Address review comments
This commit is contained in:
parent
a2ef07642e
commit
c39d3f7ad3
2 changed files with 3 additions and 34 deletions
|
|
@ -89,10 +89,6 @@ def _get_redis_cluster_kwargs(client=None):
|
|||
"gcp_service_account",
|
||||
"gcp_ssl_ca_certs",
|
||||
"max_connections",
|
||||
"socket_timeout",
|
||||
"socket_connect_timeout",
|
||||
"socket_keepalive",
|
||||
"socket_keepalive_options",
|
||||
}
|
||||
|
||||
return available_args
|
||||
|
|
@ -309,7 +305,7 @@ def init_redis_cluster(redis_kwargs) -> redis.RedisCluster:
|
|||
|
||||
def _get_redis_sentinel_connection_kwargs(redis_kwargs: dict) -> dict:
|
||||
connection_kwargs = {}
|
||||
args = _get_redis_cluster_kwargs()
|
||||
args = _get_redis_kwargs()
|
||||
for arg in redis_kwargs:
|
||||
if arg in args:
|
||||
connection_kwargs[arg] = redis_kwargs[arg]
|
||||
|
|
@ -322,9 +318,8 @@ def _init_redis_sentinel(redis_kwargs) -> redis.Redis:
|
|||
sentinel_password = redis_kwargs.get("sentinel_password")
|
||||
service_name = redis_kwargs.get("service_name")
|
||||
connection_kwargs = _get_redis_sentinel_connection_kwargs(redis_kwargs)
|
||||
sentinel_kwargs = dict(connection_kwargs)
|
||||
connection_kwargs.setdefault("socket_timeout", REDIS_SOCKET_TIMEOUT)
|
||||
sentinel_kwargs.setdefault("socket_timeout", connection_kwargs["socket_timeout"])
|
||||
sentinel_kwargs = dict(connection_kwargs)
|
||||
sentinel_kwargs["password"] = sentinel_password
|
||||
|
||||
if not sentinel_nodes or not service_name:
|
||||
|
|
@ -350,9 +345,8 @@ def _init_async_redis_sentinel(redis_kwargs) -> async_redis.Redis:
|
|||
sentinel_password = redis_kwargs.get("sentinel_password")
|
||||
service_name = redis_kwargs.get("service_name")
|
||||
connection_kwargs = _get_redis_sentinel_connection_kwargs(redis_kwargs)
|
||||
sentinel_kwargs = dict(connection_kwargs)
|
||||
connection_kwargs.setdefault("socket_timeout", REDIS_SOCKET_TIMEOUT)
|
||||
sentinel_kwargs.setdefault("socket_timeout", connection_kwargs["socket_timeout"])
|
||||
sentinel_kwargs = dict(connection_kwargs)
|
||||
sentinel_kwargs["password"] = sentinel_password
|
||||
|
||||
if not sentinel_nodes or not service_name:
|
||||
|
|
|
|||
|
|
@ -410,31 +410,6 @@ def test_sync_sentinel_uses_sentinel_password_and_master_password(mock_sentinel_
|
|||
)
|
||||
|
||||
|
||||
def test_sync_sentinel_socket_timeout_in_connection_kwargs_no_longer_raises():
|
||||
"""socket_timeout should be applied through master_for without duplicating constructor kwargs."""
|
||||
mock_sentinel = MagicMock()
|
||||
with patch(
|
||||
"litellm._redis._get_redis_sentinel_connection_kwargs",
|
||||
return_value={"password": "redis-secret", "socket_timeout": 5},
|
||||
), patch("litellm._redis.redis.Sentinel", return_value=mock_sentinel) as mock_cls:
|
||||
get_redis_client(
|
||||
sentinel_nodes=[("sentinel-1", 26379)],
|
||||
sentinel_password="sentinel-secret",
|
||||
service_name="mymaster",
|
||||
)
|
||||
|
||||
sentinel_call_kwargs = mock_cls.call_args[1]
|
||||
assert "socket_timeout" not in sentinel_call_kwargs
|
||||
assert sentinel_call_kwargs["sentinel_kwargs"] == {
|
||||
"password": "sentinel-secret",
|
||||
"socket_timeout": 5,
|
||||
}
|
||||
assert "password" not in sentinel_call_kwargs
|
||||
mock_sentinel.master_for.assert_called_once_with(
|
||||
"mymaster", password="redis-secret", socket_timeout=5
|
||||
)
|
||||
|
||||
|
||||
@patch("litellm._redis.async_redis.Sentinel")
|
||||
def test_async_sentinel_uses_sentinel_password_and_master_password(
|
||||
mock_sentinel_cls,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue