Skip to content

Commit a9deb30

Browse files
committed
Review and update Pinecone class docstrings
1 parent 8f9f55d commit a9deb30

File tree

8 files changed

+1010
-953
lines changed

8 files changed

+1010
-953
lines changed

pinecone/__init__.pyi

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,59 @@ from pinecone.db_control.models import (
7979
ServerlessSpecDefinition,
8080
PodSpec,
8181
PodSpecDefinition,
82+
ByocSpec,
83+
BackupModel,
84+
BackupList,
85+
RestoreJobModel,
86+
RestoreJobList,
8287
)
88+
from pinecone.db_control.models.serverless_spec import (
89+
ScalingConfigManualDict,
90+
ReadCapacityDedicatedConfigDict,
91+
ReadCapacityOnDemandDict,
92+
ReadCapacityDedicatedDict,
93+
ReadCapacityDict,
94+
MetadataSchemaFieldConfig,
95+
)
96+
from pinecone.db_data.filter_builder import FilterBuilder
8397
from pinecone.db_control.types import ConfigureIndexEmbed, CreateIndexForModelEmbedTypedDict
8498
from pinecone.pinecone import Pinecone
8599
from pinecone.pinecone_asyncio import PineconeAsyncio
100+
from pinecone.admin import Admin
101+
from pinecone.utils import __version__
102+
103+
# Deprecated top-level functions
104+
def init(*args: object, **kwargs: object) -> None: ...
105+
def create_index(*args: object, **kwargs: object) -> None: ...
106+
def delete_index(*args: object, **kwargs: object) -> None: ...
107+
def list_indexes(*args: object, **kwargs: object) -> None: ...
108+
def describe_index(*args: object, **kwargs: object) -> None: ...
109+
def configure_index(*args: object, **kwargs: object) -> None: ...
110+
def scale_index(*args: object, **kwargs: object) -> None: ...
111+
def create_collection(*args: object, **kwargs: object) -> None: ...
112+
def delete_collection(*args: object, **kwargs: object) -> None: ...
113+
def describe_collection(*args: object, **kwargs: object) -> None: ...
114+
def list_collections(*args: object, **kwargs: object) -> None: ...
86115

87116
# Re-export all the types
88117
__all__ = [
118+
"__version__",
119+
# Deprecated top-level functions
120+
"init",
121+
"create_index",
122+
"delete_index",
123+
"list_indexes",
124+
"describe_index",
125+
"configure_index",
126+
"scale_index",
127+
"create_collection",
128+
"delete_collection",
129+
"describe_collection",
130+
"list_collections",
89131
# Primary client classes
90132
"Pinecone",
91133
"PineconeAsyncio",
134+
"Admin",
92135
# Config classes
93136
"Config",
94137
"ConfigBuilder",
@@ -139,6 +182,7 @@ __all__ = [
139182
"UpdateRequest",
140183
"NamespaceDescription",
141184
"ImportErrorMode",
185+
"FilterBuilder",
142186
# Error classes
143187
"VectorDictionaryMissingKeysError",
144188
"VectorDictionaryExcessKeysError",
@@ -166,7 +210,18 @@ __all__ = [
166210
"ServerlessSpecDefinition",
167211
"PodSpec",
168212
"PodSpecDefinition",
213+
"ByocSpec",
214+
"BackupModel",
215+
"BackupList",
216+
"RestoreJobModel",
217+
"RestoreJobList",
169218
# Control plane types
170219
"ConfigureIndexEmbed",
171220
"CreateIndexForModelEmbedTypedDict",
221+
"ScalingConfigManualDict",
222+
"ReadCapacityDedicatedConfigDict",
223+
"ReadCapacityOnDemandDict",
224+
"ReadCapacityDedicatedDict",
225+
"ReadCapacityDict",
226+
"MetadataSchemaFieldConfig",
172227
]

pinecone/db_data/index.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ class UpsertResponseTransformer:
107107
while delegating other methods to the underlying ApplyResult.
108108
"""
109109

110-
def __init__(self, apply_result: ApplyResult):
110+
_apply_result: ApplyResult
111+
""" :meta private: """
112+
113+
def __init__(self, apply_result: ApplyResult) -> None:
111114
self._apply_result = apply_result
112115

113-
def get(self, timeout=None):
116+
def get(self, timeout: float | None = None) -> UpsertResponse:
114117
openapi_response = self._apply_result.get(timeout)
115118
from pinecone.utils.response_info import extract_response_info
116119

@@ -123,7 +126,7 @@ def get(self, timeout=None):
123126
upserted_count=openapi_response.upserted_count, _response_info=response_info
124127
)
125128

126-
def __getattr__(self, name):
129+
def __getattr__(self, name: str) -> Any:
127130
# Delegate other methods to the underlying ApplyResult
128131
return getattr(self._apply_result, name)
129132

@@ -134,6 +137,21 @@ class Index(PluginAware, IndexInterface):
134137
For improved performance, use the Pinecone GRPC index client.
135138
"""
136139

140+
_config: "Config"
141+
""" :meta private: """
142+
143+
_openapi_config: "OpenApiConfiguration"
144+
""" :meta private: """
145+
146+
_pool_threads: int
147+
""" :meta private: """
148+
149+
_vector_api: VectorOperationsApi
150+
""" :meta private: """
151+
152+
_api_client: ApiClient
153+
""" :meta private: """
154+
137155
_bulk_import_resource: "BulkImportResource" | None
138156
""" :meta private: """
139157

pinecone/db_data/index_asyncio.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
from .query_results_aggregator import QueryNamespacesResults
6666

6767
if TYPE_CHECKING:
68+
from pinecone.config import Config, OpenApiConfiguration
6869
from .resources.asyncio.bulk_import_asyncio import BulkImportResourceAsyncio
6970
from .resources.asyncio.namespace_asyncio import NamespaceResourceAsyncio
7071

@@ -168,6 +169,18 @@ async def main():
168169
Failing to do this may result in error messages appearing from the underlyling aiohttp library.
169170
"""
170171

172+
config: "Config"
173+
""" :meta private: """
174+
175+
_openapi_config: "OpenApiConfiguration"
176+
""" :meta private: """
177+
178+
_vector_api: AsyncioVectorOperationsApi
179+
""" :meta private: """
180+
181+
_api_client: AsyncioApiClient
182+
""" :meta private: """
183+
171184
_bulk_import_resource: "BulkImportResourceAsyncio" | None
172185
""" :meta private: """
173186

pinecone/db_data/interfaces.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,38 @@ def upsert_from_dataframe(
244244
):
245245
"""Upserts a dataframe into the index.
246246
247-
Args:
248-
df: A pandas dataframe with the following columns: id, values, sparse_values, and metadata.
249-
namespace: The namespace to upsert into.
250-
batch_size: The number of rows to upsert in a single batch.
251-
show_progress: Whether to show a progress bar.
247+
:param df: A pandas dataframe with the following columns: id, values, sparse_values, and metadata.
248+
:type df: pandas.DataFrame
249+
:param namespace: The namespace to upsert into.
250+
:type namespace: str, optional
251+
:param batch_size: The number of rows to upsert in a single batch.
252+
:type batch_size: int, optional
253+
:param show_progress: Whether to show a progress bar.
254+
:type show_progress: bool, optional
255+
256+
.. code-block:: python
257+
258+
import pandas as pd
259+
from pinecone import Pinecone
260+
261+
pc = Pinecone()
262+
idx = pc.Index(host="your-index-host")
263+
264+
# Create a dataframe with vector data
265+
df = pd.DataFrame({
266+
'id': ['id1', 'id2', 'id3'],
267+
'values': [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]],
268+
'metadata': [{'key': 'value1'}, {'key': 'value2'}, {'key': 'value3'}]
269+
})
270+
271+
# Upsert the dataframe
272+
idx.upsert_from_dataframe(
273+
df=df,
274+
namespace="my-namespace",
275+
batch_size=100,
276+
show_progress=True
277+
)
278+
252279
"""
253280
pass
254281

@@ -276,7 +303,7 @@ def upsert_records(self, namespace: str, records: list[dict]) -> UpsertResponse:
276303
Pinecone,
277304
CloudProvider,
278305
AwsRegion,
279-
EmbedModel
306+
EmbedModel,
280307
IndexEmbed
281308
)
282309
@@ -382,7 +409,7 @@ def search(
382409
Pinecone,
383410
CloudProvider,
384411
AwsRegion,
385-
EmbedModel
412+
EmbedModel,
386413
IndexEmbed
387414
)
388415

0 commit comments

Comments
 (0)