diff --git a/pinecone/__init__.pyi b/pinecone/__init__.pyi index bb67f201f..45ca8caf3 100644 --- a/pinecone/__init__.pyi +++ b/pinecone/__init__.pyi @@ -79,16 +79,59 @@ from pinecone.db_control.models import ( ServerlessSpecDefinition, PodSpec, PodSpecDefinition, + ByocSpec, + BackupModel, + BackupList, + RestoreJobModel, + RestoreJobList, ) +from pinecone.db_control.models.serverless_spec import ( + ScalingConfigManualDict, + ReadCapacityDedicatedConfigDict, + ReadCapacityOnDemandDict, + ReadCapacityDedicatedDict, + ReadCapacityDict, + MetadataSchemaFieldConfig, +) +from pinecone.db_data.filter_builder import FilterBuilder from pinecone.db_control.types import ConfigureIndexEmbed, CreateIndexForModelEmbedTypedDict from pinecone.pinecone import Pinecone from pinecone.pinecone_asyncio import PineconeAsyncio +from pinecone.admin import Admin +from pinecone.utils import __version__ + +# Deprecated top-level functions +def init(*args: object, **kwargs: object) -> None: ... +def create_index(*args: object, **kwargs: object) -> None: ... +def delete_index(*args: object, **kwargs: object) -> None: ... +def list_indexes(*args: object, **kwargs: object) -> None: ... +def describe_index(*args: object, **kwargs: object) -> None: ... +def configure_index(*args: object, **kwargs: object) -> None: ... +def scale_index(*args: object, **kwargs: object) -> None: ... +def create_collection(*args: object, **kwargs: object) -> None: ... +def delete_collection(*args: object, **kwargs: object) -> None: ... +def describe_collection(*args: object, **kwargs: object) -> None: ... +def list_collections(*args: object, **kwargs: object) -> None: ... # Re-export all the types __all__ = [ + "__version__", + # Deprecated top-level functions + "init", + "create_index", + "delete_index", + "list_indexes", + "describe_index", + "configure_index", + "scale_index", + "create_collection", + "delete_collection", + "describe_collection", + "list_collections", # Primary client classes "Pinecone", "PineconeAsyncio", + "Admin", # Config classes "Config", "ConfigBuilder", @@ -139,6 +182,7 @@ __all__ = [ "UpdateRequest", "NamespaceDescription", "ImportErrorMode", + "FilterBuilder", # Error classes "VectorDictionaryMissingKeysError", "VectorDictionaryExcessKeysError", @@ -166,7 +210,18 @@ __all__ = [ "ServerlessSpecDefinition", "PodSpec", "PodSpecDefinition", + "ByocSpec", + "BackupModel", + "BackupList", + "RestoreJobModel", + "RestoreJobList", # Control plane types "ConfigureIndexEmbed", "CreateIndexForModelEmbedTypedDict", + "ScalingConfigManualDict", + "ReadCapacityDedicatedConfigDict", + "ReadCapacityOnDemandDict", + "ReadCapacityDedicatedDict", + "ReadCapacityDict", + "MetadataSchemaFieldConfig", ] diff --git a/pinecone/db_data/index.py b/pinecone/db_data/index.py index d8a992e7a..4c6b35382 100644 --- a/pinecone/db_data/index.py +++ b/pinecone/db_data/index.py @@ -107,10 +107,13 @@ class UpsertResponseTransformer: while delegating other methods to the underlying ApplyResult. """ - def __init__(self, apply_result: ApplyResult): + _apply_result: ApplyResult + """ :meta private: """ + + def __init__(self, apply_result: ApplyResult) -> None: self._apply_result = apply_result - def get(self, timeout=None): + def get(self, timeout: float | None = None) -> UpsertResponse: openapi_response = self._apply_result.get(timeout) from pinecone.utils.response_info import extract_response_info @@ -123,7 +126,7 @@ def get(self, timeout=None): upserted_count=openapi_response.upserted_count, _response_info=response_info ) - def __getattr__(self, name): + def __getattr__(self, name: str) -> Any: # Delegate other methods to the underlying ApplyResult return getattr(self._apply_result, name) @@ -134,6 +137,21 @@ class Index(PluginAware, IndexInterface): For improved performance, use the Pinecone GRPC index client. """ + _config: "Config" + """ :meta private: """ + + _openapi_config: "OpenApiConfiguration" + """ :meta private: """ + + _pool_threads: int + """ :meta private: """ + + _vector_api: VectorOperationsApi + """ :meta private: """ + + _api_client: ApiClient + """ :meta private: """ + _bulk_import_resource: "BulkImportResource" | None """ :meta private: """ diff --git a/pinecone/db_data/index_asyncio.py b/pinecone/db_data/index_asyncio.py index 6ad220ace..0cb243429 100644 --- a/pinecone/db_data/index_asyncio.py +++ b/pinecone/db_data/index_asyncio.py @@ -65,6 +65,7 @@ from .query_results_aggregator import QueryNamespacesResults if TYPE_CHECKING: + from pinecone.config import Config, OpenApiConfiguration from .resources.asyncio.bulk_import_asyncio import BulkImportResourceAsyncio from .resources.asyncio.namespace_asyncio import NamespaceResourceAsyncio @@ -168,6 +169,18 @@ async def main(): Failing to do this may result in error messages appearing from the underlyling aiohttp library. """ + config: "Config" + """ :meta private: """ + + _openapi_config: "OpenApiConfiguration" + """ :meta private: """ + + _vector_api: AsyncioVectorOperationsApi + """ :meta private: """ + + _api_client: AsyncioApiClient + """ :meta private: """ + _bulk_import_resource: "BulkImportResourceAsyncio" | None """ :meta private: """ diff --git a/pinecone/grpc/resources/vector_grpc.py b/pinecone/grpc/resources/vector_grpc.py index 4812d3f34..7a2e0065b 100644 --- a/pinecone/grpc/resources/vector_grpc.py +++ b/pinecone/grpc/resources/vector_grpc.py @@ -176,7 +176,7 @@ def _upsert_batch( def upsert_from_dataframe( self, df, - namespace: Optional[str] = None, + namespace: str | None = None, batch_size: int = 500, use_async_requests: bool = True, show_progress: bool = True, diff --git a/pinecone/inference/inference.py b/pinecone/inference/inference.py index 2fd3fdcfc..061a2f85b 100644 --- a/pinecone/inference/inference.py +++ b/pinecone/inference/inference.py @@ -172,8 +172,7 @@ def embed( ``n`` embeddings, where ``n`` = len(inputs). Precision of returned embeddings is either float16 or float32, with float32 being the default. ``model`` key is the model used to generate the embeddings. ``usage`` key contains the total number of tokens used at request-time. - - Example: + :rtype: EmbeddingsList .. code-block:: python diff --git a/pinecone/utils/plugin_aware.py b/pinecone/utils/plugin_aware.py index 540e9cd52..26b65b7ab 100644 --- a/pinecone/utils/plugin_aware.py +++ b/pinecone/utils/plugin_aware.py @@ -25,6 +25,9 @@ class PluginAware: can't be changed without breaking compatibility with plugins in the wild. """ + _plugins_loaded: bool + """ :meta private: """ + def __init__(self, *args: Any, **kwargs: Any) -> None: """ Initialize the PluginAware class. diff --git a/pyproject.toml b/pyproject.toml index 9d400839a..2acf9524d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,6 +97,7 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["pinecone"] +include = ["pinecone/py.typed"] [tool.pytest.ini_options] asyncio_mode = "strict"