mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-11 02:22:48 +00:00
Revert "Fix: make pondpond as optional dependency for proxy extras, disab…" (#14880)
This reverts commit e75d8b711e.
This commit is contained in:
@@ -16,35 +16,11 @@ Memory Management Strategy:
|
||||
|
||||
from typing import Any, Callable, Optional, Type, TypeVar
|
||||
|
||||
try:
|
||||
from pond import Pond, PooledObject, PooledObjectFactory # type: ignore
|
||||
POND_AVAILABLE = True
|
||||
except ImportError: # pragma: no cover
|
||||
POND_AVAILABLE = False
|
||||
class Pond: # type: ignore
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
def register(self, *args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
def borrow(self, *args: Any, **kwargs: Any) -> Any:
|
||||
pass
|
||||
|
||||
def recycle(self, *args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
|
||||
class PooledObject: # type: ignore
|
||||
def __init__(self, keeped_object: Any = None) -> None:
|
||||
self.keeped_object = keeped_object
|
||||
|
||||
class PooledObjectFactory: # type: ignore
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
pass
|
||||
from pond import Pond, PooledObject, PooledObjectFactory
|
||||
|
||||
T = TypeVar('T')
|
||||
|
||||
class GenericPooledObjectFactory(PooledObjectFactory): # type: ignore[misc]
|
||||
class GenericPooledObjectFactory(PooledObjectFactory):
|
||||
"""Generic factory class for creating pooled objects of any type."""
|
||||
|
||||
def __init__(
|
||||
@@ -103,7 +79,7 @@ def get_object_pool(
|
||||
time_between_eviction_runs: int = 300, # Less frequent eviction to maintain high reuse ratio
|
||||
eviction_weight: float = 0.3, # Less aggressive eviction for better reuse
|
||||
prewarm_count: int = 5 # Lower pre-warm count to reduce initial memory usage
|
||||
) -> Pond | None:
|
||||
) -> Pond:
|
||||
"""Get or create a global object pool instance with balanced eviction-based memory control.
|
||||
|
||||
Memory is controlled through moderate eviction to balance reuse ratio and memory usage:
|
||||
@@ -122,13 +98,9 @@ def get_object_pool(
|
||||
prewarm_count: Number of objects to pre-warm the pool with (default: 5)
|
||||
|
||||
Returns:
|
||||
Pond instance for the specified object type or None if pond is not available
|
||||
Pond instance for the specified object type
|
||||
"""
|
||||
|
||||
# If pond is not available, disable pooling gracefully
|
||||
if not POND_AVAILABLE:
|
||||
return None
|
||||
|
||||
if pool_name in _pools:
|
||||
return _pools[pool_name]
|
||||
|
||||
@@ -162,4 +134,4 @@ def _prewarm_pool(pond: Pond, pool_name: str, prewarm_count: int = 20) -> None:
|
||||
pond.recycle(pooled_obj, name=f"{pool_name}Factory")
|
||||
except Exception:
|
||||
# If pre-warming fails, just continue
|
||||
break
|
||||
break
|
||||
Generated
+4
-6
@@ -2730,10 +2730,9 @@ files = [
|
||||
name = "madoka"
|
||||
version = "0.7.1"
|
||||
description = "Memory-efficient CountMin Sketch key-value structure (based on Madoka C++ library)"
|
||||
optional = true
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
markers = "extra == \"proxy\""
|
||||
files = [
|
||||
{file = "madoka-0.7.1-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:7521eee9ace30b376bb54fdcb2cb42bf6b7a0346b0d0b612f25f3299aa4a95af"},
|
||||
{file = "madoka-0.7.1.tar.gz", hash = "sha256:e258baa84fc0a3764365993b8bf5e1b065383a6ca8c9f862fb3e3e709843fae7"},
|
||||
@@ -4045,10 +4044,9 @@ xlsxwriter = ["xlsxwriter"]
|
||||
name = "pondpond"
|
||||
version = "1.4.1"
|
||||
description = "Pond is a high performance object-pooling library for Python."
|
||||
optional = true
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
markers = "extra == \"proxy\""
|
||||
files = [
|
||||
{file = "pondpond-1.4.1-py3-none-any.whl", hash = "sha256:641028ead4e8018ca6de1220c660ddd6d6fbf62a60e72f410655dd0451d82880"},
|
||||
{file = "pondpond-1.4.1.tar.gz", hash = "sha256:8afa34b869d1434d21dd2ec12644abc3b1733fcda8fcf355300338a13a79bb7b"},
|
||||
@@ -6749,11 +6747,11 @@ type = ["pytest-mypy"]
|
||||
caching = ["diskcache"]
|
||||
extra-proxy = ["azure-identity", "azure-keyvault-secrets", "google-cloud-iam", "google-cloud-kms", "prisma", "redisvl", "resend"]
|
||||
mlflow = ["mlflow"]
|
||||
proxy = ["PyJWT", "apscheduler", "azure-identity", "azure-storage-blob", "backoff", "boto3", "cryptography", "fastapi", "fastapi-sso", "fastuuid", "gunicorn", "litellm-enterprise", "litellm-proxy-extras", "mcp", "orjson", "polars", "pondpond", "pynacl", "python-multipart", "pyyaml", "rich", "rq", "uvicorn", "uvloop", "websockets"]
|
||||
proxy = ["PyJWT", "apscheduler", "azure-identity", "azure-storage-blob", "backoff", "boto3", "cryptography", "fastapi", "fastapi-sso", "fastuuid", "gunicorn", "litellm-enterprise", "litellm-proxy-extras", "mcp", "orjson", "polars", "pynacl", "python-multipart", "pyyaml", "rich", "rq", "uvicorn", "uvloop", "websockets"]
|
||||
semantic-router = ["semantic-router"]
|
||||
utils = ["numpydoc"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.8.1,<4.0, !=3.9.7"
|
||||
content-hash = "16fdc1044b4bb316803cbf1825bc970895526949a8bef93eab741777b7210ca8"
|
||||
content-hash = "75004c6a23b70be86622fa417fd0d62fa3843e6e61c8dff8507ae5c967b7205d"
|
||||
|
||||
+1
-2
@@ -31,7 +31,7 @@ jinja2 = "^3.1.2"
|
||||
aiohttp = ">=3.10"
|
||||
pydantic = "^2.5.0"
|
||||
jsonschema = "^4.22.0"
|
||||
pondpond = {version = "^1.4.1", optional = true}
|
||||
pondpond = "^1.4.1"
|
||||
numpydoc = {version = "*", optional = true} # used in utils.py
|
||||
fastuuid = {version = ">=0.12.0", optional = true}
|
||||
|
||||
@@ -94,7 +94,6 @@ proxy = [
|
||||
"rich",
|
||||
"polars",
|
||||
"fastuuid",
|
||||
"pondpond",
|
||||
]
|
||||
|
||||
extra_proxy = [
|
||||
|
||||
@@ -3,7 +3,6 @@ Simplified tests for object pooling utilities in litellm.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
pytest.importorskip("pond")
|
||||
|
||||
from litellm.litellm_core_utils.object_pooling import (
|
||||
get_object_pool,
|
||||
@@ -104,4 +103,4 @@ class TestObjectPooling:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__])
|
||||
pytest.main([__file__])
|
||||
Reference in New Issue
Block a user