From d9bf6a8c53db9480ab33b00a7578535554681afb Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 24 Sep 2025 21:34:42 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"Fix:=20make=20`pondpond`=20as=20optio?= =?UTF-8?q?nal=20dependency=20for=20`proxy`=20extras,=20disab=E2=80=A6"=20?= =?UTF-8?q?(#14880)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e75d8b711e156d1528d560a53263288238cdba99. --- litellm/litellm_core_utils/object_pooling.py | 38 +++---------------- poetry.lock | 10 ++--- pyproject.toml | 3 +- .../test_object_pooling.py | 3 +- 4 files changed, 11 insertions(+), 43 deletions(-) diff --git a/litellm/litellm_core_utils/object_pooling.py b/litellm/litellm_core_utils/object_pooling.py index 81c3ec2e13..846e6536f8 100644 --- a/litellm/litellm_core_utils/object_pooling.py +++ b/litellm/litellm_core_utils/object_pooling.py @@ -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 \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 87599768db..a8ef9ee79d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -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" diff --git a/pyproject.toml b/pyproject.toml index 4113714415..b11b1a1c2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ diff --git a/tests/litellm_utils_tests/test_object_pooling.py b/tests/litellm_utils_tests/test_object_pooling.py index 8d0272e92b..5cdc38ee45 100644 --- a/tests/litellm_utils_tests/test_object_pooling.py +++ b/tests/litellm_utils_tests/test_object_pooling.py @@ -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__]) \ No newline at end of file