Skip to content

Commit 3cbe357

Browse files
committed
feat(backcompat): accept legacy pool_threads= kwarg on Pinecone.__init__
## Purpose Legacy callers pass `pool_threads=N` to tune concurrency. The new SDK uses httpx connection pooling and has no thread-pool concept, so the kwarg needs to be silently consumed rather than raising TypeError (BCG-020). ## Solution Added `**kwargs: Any` to `Pinecone.__init__`, popped `pool_threads` before forwarding. Emits a single `logger.debug(...)` when the kwarg is supplied so users with `PINECONE_DEBUG` can confirm it was ignored. All other unknown kwargs still raise `TypeError`. No `DeprecationWarning` per project policy. Updated the existing `test_pool_threads_raises` test in `test_client.py` to reflect the new accepted behavior. Added four new tests in `test_pinecone_class.py`: accepted silently, emits debug log, no DeprecationWarning, unknown kwarg rejected.
1 parent 73d13ad commit 3cbe357

3 files changed

Lines changed: 51 additions & 3 deletions

File tree

‎pinecone/_client.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import logging
56
from dataclasses import replace
67
from typing import TYPE_CHECKING, Any, cast
78

@@ -46,6 +47,8 @@
4647
)
4748
from pinecone.preview import Preview
4849

50+
logger = logging.getLogger(__name__)
51+
4952

5053
class Pinecone:
5154
"""Synchronous Pinecone client for control-plane operations.
@@ -100,7 +103,18 @@ def __init__(
100103
timeout: float = 30.0,
101104
connection_pool_maxsize: int = 0,
102105
retry_config: RetryConfig | None = None,
106+
**kwargs: Any,
103107
) -> None:
108+
legacy_pool_threads = kwargs.pop("pool_threads", None)
109+
if kwargs:
110+
raise TypeError(f"Pinecone() got unexpected keyword arguments: {sorted(kwargs)!r}")
111+
if legacy_pool_threads is not None:
112+
logger.debug(
113+
"Pinecone(pool_threads=%r) is accepted for backcompat but no "
114+
"longer used; the new client uses httpx connection pooling. "
115+
"Tune connection_pool_maxsize= instead.",
116+
legacy_pool_threads,
117+
)
104118
config = PineconeConfig(
105119
api_key=api_key or "",
106120
host=host or "",

‎tests/unit/test_client.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,10 @@ def test_openapi_config_raises(self) -> None:
165165
with pytest.raises(TypeError, match="unexpected keyword argument"):
166166
Pinecone(api_key="test-key", openapi_config="something") # type: ignore[call-arg]
167167

168-
def test_pool_threads_raises(self) -> None:
169-
with pytest.raises(TypeError, match="unexpected keyword argument"):
170-
Pinecone(api_key="test-key", pool_threads=4) # type: ignore[call-arg]
168+
def test_pool_threads_accepted(self) -> None:
169+
# pool_threads= is a backcompat shim (BCG-020); it is silently consumed.
170+
pc = Pinecone(api_key="test-key", pool_threads=4) # type: ignore[call-arg]
171+
assert pc is not None
171172

172173
def test_index_api_raises(self) -> None:
173174
with pytest.raises(TypeError, match="unexpected keyword argument"):

‎tests/unit/test_pinecone_class.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
from __future__ import annotations
44

5+
import logging
6+
import warnings
57
from unittest.mock import MagicMock, patch
68

9+
import pytest
10+
711
from pinecone import Pinecone
812
from pinecone.inference.models.index_embed import IndexEmbed
913
from pinecone.models.enums import CloudProvider
@@ -473,3 +477,32 @@ def test_restore_jobs_cached_on_second_access(self) -> None:
473477
pc = Pinecone(api_key="test-key")
474478
first_access = pc.restore_jobs
475479
assert pc.restore_jobs is first_access
480+
481+
482+
# ---------------------------------------------------------------------------
483+
# pool_threads= backcompat shim (BCG-020)
484+
# ---------------------------------------------------------------------------
485+
486+
487+
class TestPoolThreadsBackcompat:
488+
def test_pool_threads_kwarg_accepted_silently(self) -> None:
489+
pc = Pinecone(api_key="x", pool_threads=4)
490+
assert pc is not None
491+
492+
def test_pool_threads_kwarg_emits_debug_log(self, caplog: pytest.LogCaptureFixture) -> None:
493+
with caplog.at_level(logging.DEBUG, logger="pinecone._client"):
494+
Pinecone(api_key="x", pool_threads=4)
495+
assert any(
496+
"pool_threads" in r.message and "connection_pool_maxsize" in r.message
497+
for r in caplog.records
498+
)
499+
500+
def test_pool_threads_kwarg_does_not_warn(self) -> None:
501+
with warnings.catch_warnings(record=True) as record:
502+
warnings.simplefilter("always")
503+
Pinecone(api_key="x", pool_threads=4)
504+
assert len(record) == 0
505+
506+
def test_unknown_kwarg_still_rejected(self) -> None:
507+
with pytest.raises(TypeError, match="unexpected keyword arguments"):
508+
Pinecone(api_key="x", bogus_kwarg=True)

0 commit comments

Comments
 (0)