From 17ef90369c191979072202e915f1623262e5c162 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 16 Jun 2025 13:46:28 -0400 Subject: [PATCH 01/12] add ConfigureIndexEmbed model and allow passing in IndexResource configure method, and building in the request factory --- pinecone/db_control/models/__init__.py | 2 + .../models/configure_index_embed.py | 32 +++++ pinecone/db_control/request_factory.py | 109 ++++++++++++++---- .../db_control/resources/asyncio/index.py | 21 +++- pinecone/db_control/resources/sync/index.py | 15 ++- 5 files changed, 147 insertions(+), 32 deletions(-) create mode 100644 pinecone/db_control/models/configure_index_embed.py diff --git a/pinecone/db_control/models/__init__.py b/pinecone/db_control/models/__init__.py index cf866f11..1a9c1284 100644 --- a/pinecone/db_control/models/__init__.py +++ b/pinecone/db_control/models/__init__.py @@ -11,6 +11,7 @@ from .backup_list import BackupList from .restore_job_model import RestoreJobModel from .restore_job_list import RestoreJobList +from .configure_index_embed import ConfigureIndexEmbed __all__ = [ @@ -28,4 +29,5 @@ "BackupList", "RestoreJobModel", "RestoreJobList", + "ConfigureIndexEmbed", ] diff --git a/pinecone/db_control/models/configure_index_embed.py b/pinecone/db_control/models/configure_index_embed.py new file mode 100644 index 00000000..bcdd0840 --- /dev/null +++ b/pinecone/db_control/models/configure_index_embed.py @@ -0,0 +1,32 @@ +from typing import Dict, Any, Optional +from dataclasses import dataclass, field + + +@dataclass +class ConfigureIndexEmbed: + """Configuration for embedding settings when configuring an index. + + Attributes: + model (str): The name of the embedding model to use with the index. + field_map (Dict[str, str]): Identifies the name of the text field from your document model that will be embedded. + read_parameters (Optional[Dict[str, Any]]): The read parameters for the embedding model. + write_parameters (Optional[Dict[str, Any]]): The write parameters for the embedding model. + """ + + model: str + field_map: Dict[str, str] + read_parameters: Optional[Dict[str, Any]] = None + write_parameters: Optional[Dict[str, Any]] = None + + def as_dict(self) -> Dict[str, Any]: + """Convert the ConfigureIndexEmbed instance to a dictionary. + + Returns: + Dict[str, Any]: A dictionary representation of the ConfigureIndexEmbed instance. + """ + return { + "model": self.model, + "field_map": self.field_map, + "read_parameters": self.read_parameters, + "write_parameters": self.write_parameters, + } diff --git a/pinecone/db_control/request_factory.py b/pinecone/db_control/request_factory.py index 3d6a3735..0e2a8d10 100644 --- a/pinecone/db_control/request_factory.py +++ b/pinecone/db_control/request_factory.py @@ -4,15 +4,21 @@ from pinecone.utils import parse_non_empty_args, convert_enum_to_string -from pinecone.core.openapi.db_control.model.create_collection_request import CreateCollectionRequest +from pinecone.core.openapi.db_control.model.create_collection_request import ( + CreateCollectionRequest, +) from pinecone.core.openapi.db_control.model.create_index_for_model_request import ( CreateIndexForModelRequest, ) from pinecone.core.openapi.db_control.model.create_index_for_model_request_embed import ( CreateIndexForModelRequestEmbed, ) -from pinecone.core.openapi.db_control.model.create_index_request import CreateIndexRequest -from pinecone.core.openapi.db_control.model.configure_index_request import ConfigureIndexRequest +from pinecone.core.openapi.db_control.model.create_index_request import ( + CreateIndexRequest, +) +from pinecone.core.openapi.db_control.model.configure_index_request import ( + ConfigureIndexRequest, +) from pinecone.core.openapi.db_control.model.configure_index_request_spec import ( ConfigureIndexRequestSpec, ) @@ -29,11 +35,20 @@ ) from pinecone.core.openapi.db_control.model.byoc_spec import ByocSpec as ByocSpecModel from pinecone.core.openapi.db_control.model.pod_spec import PodSpec as PodSpecModel -from pinecone.core.openapi.db_control.model.pod_spec_metadata_config import PodSpecMetadataConfig +from pinecone.core.openapi.db_control.model.pod_spec_metadata_config import ( + PodSpecMetadataConfig, +) from pinecone.core.openapi.db_control.model.create_index_from_backup_request import ( CreateIndexFromBackupRequest, ) -from pinecone.db_control.models import ServerlessSpec, PodSpec, ByocSpec, IndexModel, IndexEmbed +from pinecone.db_control.models import ( + ServerlessSpec, + PodSpec, + ByocSpec, + ConfigureIndexEmbed, + IndexModel, + IndexEmbed, +) from pinecone.db_control.enums import ( Metric, @@ -74,18 +89,30 @@ def __parse_deletion_protection( if deletion_protection in ["enabled", "disabled"]: return DeletionProtectionModel(deletion_protection) else: - raise ValueError("deletion_protection must be either 'enabled' or 'disabled'") + raise ValueError( + "deletion_protection must be either 'enabled' or 'disabled'" + ) @staticmethod - def __parse_index_spec(spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec]) -> IndexSpec: + def __parse_index_spec( + spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec], + ) -> IndexSpec: if isinstance(spec, dict): if "serverless" in spec: - spec["serverless"]["cloud"] = convert_enum_to_string(spec["serverless"]["cloud"]) - spec["serverless"]["region"] = convert_enum_to_string(spec["serverless"]["region"]) + spec["serverless"]["cloud"] = convert_enum_to_string( + spec["serverless"]["cloud"] + ) + spec["serverless"]["region"] = convert_enum_to_string( + spec["serverless"]["region"] + ) - index_spec = IndexSpec(serverless=ServerlessSpecModel(**spec["serverless"])) + index_spec = IndexSpec( + serverless=ServerlessSpecModel(**spec["serverless"]) + ) elif "pod" in spec: - spec["pod"]["environment"] = convert_enum_to_string(spec["pod"]["environment"]) + spec["pod"]["environment"] = convert_enum_to_string( + spec["pod"]["environment"] + ) args_dict = parse_non_empty_args( [ ("environment", spec["pod"].get("environment")), @@ -104,7 +131,9 @@ def __parse_index_spec(spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec]) -> elif "byoc" in spec: index_spec = IndexSpec(byoc=ByocSpecModel(**spec["byoc"])) else: - raise ValueError("spec must contain either 'serverless', 'pod', or 'byoc' key") + raise ValueError( + "spec must contain either 'serverless', 'pod', or 'byoc' key" + ) elif isinstance(spec, ServerlessSpec): index_spec = IndexSpec( serverless=ServerlessSpecModel(cloud=spec.cloud, region=spec.region) @@ -124,13 +153,17 @@ def __parse_index_spec(spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec]) -> ) index_spec = IndexSpec( - pod=PodSpecModel(environment=spec.environment, pod_type=spec.pod_type, **args_dict) + pod=PodSpecModel( + environment=spec.environment, pod_type=spec.pod_type, **args_dict + ) ) elif isinstance(spec, ByocSpec): args_dict = parse_non_empty_args([("environment", spec.environment)]) index_spec = IndexSpec(byoc=ByocSpecModel(**args_dict)) else: - raise TypeError("spec must be of type dict, ServerlessSpec, PodSpec, or ByocSpec") + raise TypeError( + "spec must be of type dict, ServerlessSpec, PodSpec, or ByocSpec" + ) return index_spec @@ -140,7 +173,9 @@ def create_index_request( spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec], dimension: Optional[int] = None, metric: Optional[Union[Metric, str]] = Metric.COSINE, - deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, + deletion_protection: Optional[ + Union[DeletionProtection, str] + ] = DeletionProtection.DISABLED, vector_type: Optional[Union[VectorType, str]] = VectorType.DENSE, tags: Optional[Dict[str, str]] = None, ) -> CreateIndexRequest: @@ -149,7 +184,9 @@ def create_index_request( if vector_type is not None: vector_type = convert_enum_to_string(vector_type) if deletion_protection is not None: - dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection) + dp = PineconeDBControlRequestFactory.__parse_deletion_protection( + deletion_protection + ) else: dp = None @@ -180,12 +217,16 @@ def create_index_for_model_request( region: Union[AwsRegion, GcpRegion, AzureRegion, str], embed: Union[IndexEmbed, CreateIndexForModelEmbedTypedDict], tags: Optional[Dict[str, str]] = None, - deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, + deletion_protection: Optional[ + Union[DeletionProtection, str] + ] = DeletionProtection.DISABLED, ) -> CreateIndexForModelRequest: cloud = convert_enum_to_string(cloud) region = convert_enum_to_string(region) if deletion_protection is not None: - dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection) + dp = PineconeDBControlRequestFactory.__parse_deletion_protection( + deletion_protection + ) else: dp = None tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags) @@ -222,17 +263,23 @@ def create_index_for_model_request( @staticmethod def create_index_from_backup_request( name: str, - deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, + deletion_protection: Optional[ + Union[DeletionProtection, str] + ] = DeletionProtection.DISABLED, tags: Optional[Dict[str, str]] = None, ) -> CreateIndexFromBackupRequest: if deletion_protection is not None: - dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection) + dp = PineconeDBControlRequestFactory.__parse_deletion_protection( + deletion_protection + ) else: dp = None tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags) - return CreateIndexFromBackupRequest(name=name, deletion_protection=dp, tags=tags_obj) + return CreateIndexFromBackupRequest( + name=name, deletion_protection=dp, tags=tags_obj + ) @staticmethod def configure_index_request( @@ -241,6 +288,7 @@ def configure_index_request( pod_type: Optional[Union[PodType, str]] = None, deletion_protection: Optional[Union[DeletionProtection, str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Union[Dict[str, Any], ConfigureIndexEmbed]] = None, ): if deletion_protection is None: dp = DeletionProtectionModel(description.deletion_protection) @@ -249,7 +297,9 @@ def configure_index_request( elif deletion_protection in ["enabled", "disabled"]: dp = DeletionProtectionModel(deletion_protection) else: - raise ValueError("deletion_protection must be either 'enabled' or 'disabled'") + raise ValueError( + "deletion_protection must be either 'enabled' or 'disabled'" + ) fetched_tags = description.tags if fetched_tags is None: @@ -271,9 +321,20 @@ def configure_index_request( if replicas: pod_config_args.update(replicas=replicas) + embed_config_args: Dict[str, Any] = {} + if embed is not None: + if isinstance(embed, ConfigureIndexEmbed): + embed_config_args = embed.as_dict() + else: + embed_config_args = embed + if pod_config_args != {}: - spec = ConfigureIndexRequestSpec(pod=ConfigureIndexRequestSpecPod(**pod_config_args)) - req = ConfigureIndexRequest(deletion_protection=dp, spec=spec, tags=IndexTags(**tags)) + spec = ConfigureIndexRequestSpec( + pod=ConfigureIndexRequestSpecPod(**pod_config_args) + ) + req = ConfigureIndexRequest( + deletion_protection=dp, spec=spec, tags=IndexTags(**tags) + ) else: req = ConfigureIndexRequest(deletion_protection=dp, tags=IndexTags(**tags)) diff --git a/pinecone/db_control/resources/asyncio/index.py b/pinecone/db_control/resources/asyncio/index.py index cb233bc4..e4798983 100644 --- a/pinecone/db_control/resources/asyncio/index.py +++ b/pinecone/db_control/resources/asyncio/index.py @@ -1,6 +1,6 @@ import logging import asyncio -from typing import Optional, Dict, Union +from typing import Optional, Dict, Union, Any, TypedDict from pinecone.db_control.models import ( @@ -10,6 +10,7 @@ IndexModel, IndexList, IndexEmbed, + ConfigureIndexEmbed, ) from pinecone.utils import docslinks @@ -46,7 +47,9 @@ async def create( dimension: Optional[int] = None, metric: Optional[Union[Metric, str]] = Metric.COSINE, timeout: Optional[int] = None, - deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, + deletion_protection: Optional[ + Union[DeletionProtection, str] + ] = DeletionProtection.DISABLED, vector_type: Optional[Union[VectorType, str]] = VectorType.DENSE, tags: Optional[Dict[str, str]] = None, ) -> IndexModel: @@ -74,7 +77,9 @@ async def create_for_model( region: Union[AwsRegion, GcpRegion, AzureRegion, str], embed: Union[IndexEmbed, CreateIndexForModelEmbedTypedDict], tags: Optional[Dict[str, str]] = None, - deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, + deletion_protection: Optional[ + Union[DeletionProtection, str] + ] = DeletionProtection.DISABLED, timeout: Optional[int] = None, ) -> IndexModel: req = PineconeDBControlRequestFactory.create_index_for_model_request( @@ -97,7 +102,9 @@ async def create_from_backup( *, name: str, backup_id: str, - deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, + deletion_protection: Optional[ + Union[DeletionProtection, str] + ] = DeletionProtection.DISABLED, tags: Optional[Dict[str, str]] = None, timeout: Optional[int] = None, ) -> IndexModel: @@ -109,7 +116,9 @@ async def create_from_backup( ) return await self.__poll_describe_index_until_ready(name, timeout) - async def __poll_describe_index_until_ready(self, name: str, timeout: Optional[int] = None): + async def __poll_describe_index_until_ready( + self, name: str, timeout: Optional[int] = None + ): total_wait_time = 0 while True: description = await self.describe(name=name) @@ -183,6 +192,7 @@ async def configure( pod_type: Optional[Union[PodType, str]] = None, deletion_protection: Optional[Union[DeletionProtection, str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Dict[str, Any]] = None, ): description = await self.describe(name=name) @@ -192,5 +202,6 @@ async def configure( pod_type=pod_type, deletion_protection=deletion_protection, tags=tags, + embed=embed, ) await self._index_api.configure_index(name, configure_index_request=req) diff --git a/pinecone/db_control/resources/sync/index.py b/pinecone/db_control/resources/sync/index.py index cf255ddf..70b7e596 100644 --- a/pinecone/db_control/resources/sync/index.py +++ b/pinecone/db_control/resources/sync/index.py @@ -1,10 +1,15 @@ import time import logging -from typing import Optional, Dict, Union, TYPE_CHECKING +from typing import Optional, Dict, Union, TYPE_CHECKING, Any, TypedDict from pinecone.db_control.index_host_store import IndexHostStore -from pinecone.db_control.models import IndexModel, IndexList, IndexEmbed +from pinecone.db_control.models import ( + IndexModel, + IndexList, + IndexEmbed, + ConfigureIndexEmbed, +) from pinecone.utils import docslinks, require_kwargs, PluginAware from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict @@ -144,7 +149,9 @@ def create_from_backup( return self.describe(name=name) return self.__poll_describe_index_until_ready(name, timeout) - def __poll_describe_index_until_ready(self, name: str, timeout: Optional[int] = None): + def __poll_describe_index_until_ready( + self, name: str, timeout: Optional[int] = None + ): total_wait_time = 0 while True: description = self.describe(name=name) @@ -224,6 +231,7 @@ def configure( pod_type: Optional[Union["PodType", str]] = None, deletion_protection: Optional[Union["DeletionProtection", str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Union[Dict[str, Any], "ConfigureIndexEmbed"]] = None, ) -> None: api_instance = self._index_api description = self.describe(name=name) @@ -234,6 +242,7 @@ def configure( pod_type=pod_type, deletion_protection=deletion_protection, tags=tags, + embed=embed, ) api_instance.configure_index(name, configure_index_request=req) From 21c2b0693753611097c23b210ba291c009fd5787 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 16 Jun 2025 16:18:34 -0400 Subject: [PATCH 02/12] move to using a simpler ConfigureIndexEmbed(TypedDict) class, update how we're building the configure index request call to be a bit more flexible --- pinecone/db_control/models/__init__.py | 2 -- .../models/configure_index_embed.py | 32 ------------------- pinecone/db_control/request_factory.py | 31 +++++++++--------- .../db_control/resources/asyncio/index.py | 6 ++-- pinecone/db_control/resources/sync/index.py | 6 ++-- pinecone/db_control/types/__init__.py | 3 +- .../db_control/types/configure_index_embed.py | 8 +++++ 7 files changed, 32 insertions(+), 56 deletions(-) delete mode 100644 pinecone/db_control/models/configure_index_embed.py create mode 100644 pinecone/db_control/types/configure_index_embed.py diff --git a/pinecone/db_control/models/__init__.py b/pinecone/db_control/models/__init__.py index 1a9c1284..cf866f11 100644 --- a/pinecone/db_control/models/__init__.py +++ b/pinecone/db_control/models/__init__.py @@ -11,7 +11,6 @@ from .backup_list import BackupList from .restore_job_model import RestoreJobModel from .restore_job_list import RestoreJobList -from .configure_index_embed import ConfigureIndexEmbed __all__ = [ @@ -29,5 +28,4 @@ "BackupList", "RestoreJobModel", "RestoreJobList", - "ConfigureIndexEmbed", ] diff --git a/pinecone/db_control/models/configure_index_embed.py b/pinecone/db_control/models/configure_index_embed.py deleted file mode 100644 index bcdd0840..00000000 --- a/pinecone/db_control/models/configure_index_embed.py +++ /dev/null @@ -1,32 +0,0 @@ -from typing import Dict, Any, Optional -from dataclasses import dataclass, field - - -@dataclass -class ConfigureIndexEmbed: - """Configuration for embedding settings when configuring an index. - - Attributes: - model (str): The name of the embedding model to use with the index. - field_map (Dict[str, str]): Identifies the name of the text field from your document model that will be embedded. - read_parameters (Optional[Dict[str, Any]]): The read parameters for the embedding model. - write_parameters (Optional[Dict[str, Any]]): The write parameters for the embedding model. - """ - - model: str - field_map: Dict[str, str] - read_parameters: Optional[Dict[str, Any]] = None - write_parameters: Optional[Dict[str, Any]] = None - - def as_dict(self) -> Dict[str, Any]: - """Convert the ConfigureIndexEmbed instance to a dictionary. - - Returns: - Dict[str, Any]: A dictionary representation of the ConfigureIndexEmbed instance. - """ - return { - "model": self.model, - "field_map": self.field_map, - "read_parameters": self.read_parameters, - "write_parameters": self.write_parameters, - } diff --git a/pinecone/db_control/request_factory.py b/pinecone/db_control/request_factory.py index 0e2a8d10..6f84987f 100644 --- a/pinecone/db_control/request_factory.py +++ b/pinecone/db_control/request_factory.py @@ -45,7 +45,6 @@ ServerlessSpec, PodSpec, ByocSpec, - ConfigureIndexEmbed, IndexModel, IndexEmbed, ) @@ -60,7 +59,7 @@ GcpRegion, AzureRegion, ) -from .types import CreateIndexForModelEmbedTypedDict +from .types import CreateIndexForModelEmbedTypedDict, ConfigureIndexEmbed logger = logging.getLogger(__name__) @@ -288,7 +287,7 @@ def configure_index_request( pod_type: Optional[Union[PodType, str]] = None, deletion_protection: Optional[Union[DeletionProtection, str]] = None, tags: Optional[Dict[str, str]] = None, - embed: Optional[Union[Dict[str, Any], ConfigureIndexEmbed]] = None, + embed: Optional[Union[ConfigureIndexEmbed, Dict]] = None, ): if deletion_protection is None: dp = DeletionProtectionModel(description.deletion_protection) @@ -321,24 +320,26 @@ def configure_index_request( if replicas: pod_config_args.update(replicas=replicas) - embed_config_args: Dict[str, Any] = {} + embed_config_args = None if embed is not None: - if isinstance(embed, ConfigureIndexEmbed): - embed_config_args = embed.as_dict() - else: - embed_config_args = embed + embed_config_args = dict(embed) - if pod_config_args != {}: + spec = None + if pod_config_args: spec = ConfigureIndexRequestSpec( pod=ConfigureIndexRequestSpecPod(**pod_config_args) ) - req = ConfigureIndexRequest( - deletion_protection=dp, spec=spec, tags=IndexTags(**tags) - ) - else: - req = ConfigureIndexRequest(deletion_protection=dp, tags=IndexTags(**tags)) - return req + args_dict = parse_non_empty_args( + [ + ("deletion_protection", dp), + ("tags", IndexTags(**tags)), + ("spec", spec), + ("embed", embed_config_args), + ] + ) + + return ConfigureIndexRequest(**args_dict) @staticmethod def create_collection_request(name: str, source: str) -> CreateCollectionRequest: diff --git a/pinecone/db_control/resources/asyncio/index.py b/pinecone/db_control/resources/asyncio/index.py index e4798983..294851ba 100644 --- a/pinecone/db_control/resources/asyncio/index.py +++ b/pinecone/db_control/resources/asyncio/index.py @@ -1,6 +1,6 @@ import logging import asyncio -from typing import Optional, Dict, Union, Any, TypedDict +from typing import Optional, Dict, Union, Any from pinecone.db_control.models import ( @@ -10,7 +10,6 @@ IndexModel, IndexList, IndexEmbed, - ConfigureIndexEmbed, ) from pinecone.utils import docslinks @@ -28,6 +27,7 @@ from pinecone.db_control.request_factory import PineconeDBControlRequestFactory from pinecone.core.openapi.db_control import API_VERSION from pinecone.utils import require_kwargs +from pinecone.db_control.types.configure_index_embed import ConfigureIndexEmbed logger = logging.getLogger(__name__) """ :meta private: """ @@ -192,7 +192,7 @@ async def configure( pod_type: Optional[Union[PodType, str]] = None, deletion_protection: Optional[Union[DeletionProtection, str]] = None, tags: Optional[Dict[str, str]] = None, - embed: Optional[Dict[str, Any]] = None, + embed: Optional[Union[ConfigureIndexEmbed, Dict]] = None, ): description = await self.describe(name=name) diff --git a/pinecone/db_control/resources/sync/index.py b/pinecone/db_control/resources/sync/index.py index 70b7e596..b11d4aef 100644 --- a/pinecone/db_control/resources/sync/index.py +++ b/pinecone/db_control/resources/sync/index.py @@ -1,6 +1,6 @@ import time import logging -from typing import Optional, Dict, Union, TYPE_CHECKING, Any, TypedDict +from typing import Optional, Dict, Union, TYPE_CHECKING, Any from pinecone.db_control.index_host_store import IndexHostStore @@ -8,13 +8,13 @@ IndexModel, IndexList, IndexEmbed, - ConfigureIndexEmbed, ) from pinecone.utils import docslinks, require_kwargs, PluginAware from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict from pinecone.db_control.request_factory import PineconeDBControlRequestFactory from pinecone.core.openapi.db_control import API_VERSION +from pinecone.db_control.types.configure_index_embed import ConfigureIndexEmbed logger = logging.getLogger(__name__) """ :meta private: """ @@ -231,7 +231,7 @@ def configure( pod_type: Optional[Union["PodType", str]] = None, deletion_protection: Optional[Union["DeletionProtection", str]] = None, tags: Optional[Dict[str, str]] = None, - embed: Optional[Union[Dict[str, Any], "ConfigureIndexEmbed"]] = None, + embed: Optional[Union["ConfigureIndexEmbed", Dict]] = None, ) -> None: api_instance = self._index_api description = self.describe(name=name) diff --git a/pinecone/db_control/types/__init__.py b/pinecone/db_control/types/__init__.py index aa10200b..e17254b0 100644 --- a/pinecone/db_control/types/__init__.py +++ b/pinecone/db_control/types/__init__.py @@ -1,3 +1,4 @@ from .create_index_for_model_embed import CreateIndexForModelEmbedTypedDict +from .configure_index_embed import ConfigureIndexEmbed -__all__ = ["CreateIndexForModelEmbedTypedDict"] +__all__ = ["CreateIndexForModelEmbedTypedDict", "ConfigureIndexEmbed"] diff --git a/pinecone/db_control/types/configure_index_embed.py b/pinecone/db_control/types/configure_index_embed.py new file mode 100644 index 00000000..59467be7 --- /dev/null +++ b/pinecone/db_control/types/configure_index_embed.py @@ -0,0 +1,8 @@ +from typing import TypedDict, Dict, Any, Optional + + +class ConfigureIndexEmbed(TypedDict): + model: str + field_map: Dict[str, str] + read_parameters: Optional[Dict[str, Any]] + write_parameters: Optional[Dict[str, Any]] From 7f279cabb6451b43f4f8afa88d52b29732b29ef7 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 16 Jun 2025 16:30:45 -0400 Subject: [PATCH 03/12] lint format --- pinecone/db_control/resources/asyncio/index.py | 2 +- pinecone/db_control/resources/sync/index.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pinecone/db_control/resources/asyncio/index.py b/pinecone/db_control/resources/asyncio/index.py index 294851ba..1d292198 100644 --- a/pinecone/db_control/resources/asyncio/index.py +++ b/pinecone/db_control/resources/asyncio/index.py @@ -1,6 +1,6 @@ import logging import asyncio -from typing import Optional, Dict, Union, Any +from typing import Optional, Dict, Union from pinecone.db_control.models import ( diff --git a/pinecone/db_control/resources/sync/index.py b/pinecone/db_control/resources/sync/index.py index b11d4aef..c10af5a3 100644 --- a/pinecone/db_control/resources/sync/index.py +++ b/pinecone/db_control/resources/sync/index.py @@ -1,6 +1,6 @@ import time import logging -from typing import Optional, Dict, Union, TYPE_CHECKING, Any +from typing import Optional, Dict, Union, TYPE_CHECKING from pinecone.db_control.index_host_store import IndexHostStore From a5035dfdfad953984eb78001db3b91282fe2c083 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 16 Jun 2025 17:47:37 -0400 Subject: [PATCH 04/12] export db_control types from the top of the package, make sure to pass ConfigureIndexRequestEmbed as the class to the generated core --- pinecone/__init__.py | 29 +++++++++++++++++++++----- pinecone/__init__.pyi | 7 +++++++ pinecone/db_control/__init__.py | 4 ++++ pinecone/db_control/request_factory.py | 9 +++++--- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/pinecone/__init__.py b/pinecone/__init__.py index 2e55fe84..c3ff4bff 100644 --- a/pinecone/__init__.py +++ b/pinecone/__init__.py @@ -2,7 +2,9 @@ .. include:: ../pdoc/README.md """ -from .deprecated_plugins import check_for_deprecated_plugins as _check_for_deprecated_plugins +from .deprecated_plugins import ( + check_for_deprecated_plugins as _check_for_deprecated_plugins, +) from .deprecation_warnings import * from .pinecone import Pinecone from .pinecone_asyncio import PineconeAsyncio @@ -46,7 +48,10 @@ "SearchRerank": ("pinecone.db_data.dataclasses", "SearchRerank"), "FetchResponse": ("pinecone.db_data.dataclasses", "FetchResponse"), "DeleteRequest": ("pinecone.db_data.models", "DeleteRequest"), - "DescribeIndexStatsRequest": ("pinecone.db_data.models", "DescribeIndexStatsRequest"), + "DescribeIndexStatsRequest": ( + "pinecone.db_data.models", + "DescribeIndexStatsRequest", + ), "DescribeIndexStatsResponse": ("pinecone.db_data.models", "IndexDescription"), "RpcStatus": ("pinecone.db_data.models", "RpcStatus"), "ScoredVector": ("pinecone.db_data.models", "ScoredVector"), @@ -55,7 +60,10 @@ "QueryResponse": ("pinecone.db_data.models", "QueryResponse"), "UpsertResponse": ("pinecone.db_data.models", "UpsertResponse"), "UpdateRequest": ("pinecone.db_data.models", "UpdateRequest"), - "ImportErrorMode": ("pinecone.db_data.resources.sync.bulk_import", "ImportErrorMode"), + "ImportErrorMode": ( + "pinecone.db_data.resources.sync.bulk_import", + "ImportErrorMode", + ), "VectorDictionaryMissingKeysError": ( "pinecone.db_data.errors", "VectorDictionaryMissingKeysError", @@ -66,7 +74,10 @@ ), "VectorTupleLengthError": ("pinecone.db_data.errors", "VectorTupleLengthError"), "SparseValuesTypeError": ("pinecone.db_data.errors", "SparseValuesTypeError"), - "SparseValuesMissingKeysError": ("pinecone.db_data.errors", "SparseValuesMissingKeysError"), + "SparseValuesMissingKeysError": ( + "pinecone.db_data.errors", + "SparseValuesMissingKeysError", + ), "SparseValuesDictionaryExpectedError": ( "pinecone.db_data.errors", "SparseValuesDictionaryExpectedError", @@ -89,7 +100,10 @@ "IndexEmbed": ("pinecone.db_control.models", "IndexEmbed"), "ByocSpec": ("pinecone.db_control.models", "ByocSpec"), "ServerlessSpec": ("pinecone.db_control.models", "ServerlessSpec"), - "ServerlessSpecDefinition": ("pinecone.db_control.models", "ServerlessSpecDefinition"), + "ServerlessSpecDefinition": ( + "pinecone.db_control.models", + "ServerlessSpecDefinition", + ), "PodSpec": ("pinecone.db_control.models", "PodSpec"), "PodSpecDefinition": ("pinecone.db_control.models", "PodSpecDefinition"), "PodType": ("pinecone.db_control.enums", "PodType"), @@ -97,6 +111,11 @@ "RestoreJobList": ("pinecone.db_control.models", "RestoreJobList"), "BackupModel": ("pinecone.db_control.models", "BackupModel"), "BackupList": ("pinecone.db_control.models", "BackupList"), + "ConfigureIndexEmbed": ("pinecone.db_control.types", "ConfigureIndexEmbed"), + "CreateIndexForModelEmbedTypedDict": ( + "pinecone.db_control.types", + "CreateIndexForModelEmbedTypedDict", + ), } _config_lazy_imports = { diff --git a/pinecone/__init__.pyi b/pinecone/__init__.pyi index 06de82ed..64fb527f 100644 --- a/pinecone/__init__.pyi +++ b/pinecone/__init__.pyi @@ -77,6 +77,10 @@ from pinecone.db_control.models import ( PodSpec, PodSpecDefinition, ) +from pinecone.db_control.types import ( + ConfigureIndexEmbed, + CreateIndexForModelEmbedTypedDict, +) from pinecone.pinecone import Pinecone from pinecone.pinecone_asyncio import PineconeAsyncio @@ -158,4 +162,7 @@ __all__ = [ "ServerlessSpecDefinition", "PodSpec", "PodSpecDefinition", + # Control plane types + "ConfigureIndexEmbed", + "CreateIndexForModelEmbedTypedDict", ] diff --git a/pinecone/db_control/__init__.py b/pinecone/db_control/__init__.py index 74c82cd8..7ac45251 100644 --- a/pinecone/db_control/__init__.py +++ b/pinecone/db_control/__init__.py @@ -1,5 +1,6 @@ from .enums import * from .models import * +from .types import * from .db_control import DBControl from .db_control_asyncio import DBControlAsyncio from .repr_overrides import install_repr_overrides @@ -30,6 +31,9 @@ "BackupList", "RestoreJobModel", "RestoreJobList", + # from .types + "ConfigureIndexEmbed", + "CreateIndexForModelEmbedTypedDict", # direct imports "DBControl", "DBControlAsyncio", diff --git a/pinecone/db_control/request_factory.py b/pinecone/db_control/request_factory.py index 6f84987f..bbd1b2f9 100644 --- a/pinecone/db_control/request_factory.py +++ b/pinecone/db_control/request_factory.py @@ -25,6 +25,9 @@ from pinecone.core.openapi.db_control.model.configure_index_request_spec_pod import ( ConfigureIndexRequestSpecPod, ) +from pinecone.core.openapi.db_control.model.configure_index_request_embed import ( + ConfigureIndexRequestEmbed, +) from pinecone.core.openapi.db_control.model.deletion_protection import ( DeletionProtection as DeletionProtectionModel, ) @@ -320,9 +323,9 @@ def configure_index_request( if replicas: pod_config_args.update(replicas=replicas) - embed_config_args = None + embed_config = None if embed is not None: - embed_config_args = dict(embed) + embed_config = ConfigureIndexRequestEmbed(**dict(embed)) spec = None if pod_config_args: @@ -335,7 +338,7 @@ def configure_index_request( ("deletion_protection", dp), ("tags", IndexTags(**tags)), ("spec", spec), - ("embed", embed_config_args), + ("embed", embed_config), ] ) From 5b6476ebadd598a55b0428bdf6accf4bc4b14671 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 16 Jun 2025 19:16:34 -0400 Subject: [PATCH 05/12] add embed to top level Pinecone configure_index method, update legacy interface and asyncio interface to support the embed parameter on configure --- pinecone/legacy_pinecone_interface.py | 10 +++++++++- pinecone/pinecone.py | 11 +++++++++-- pinecone/pinecone_interface_asyncio.py | 10 +++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pinecone/legacy_pinecone_interface.py b/pinecone/legacy_pinecone_interface.py index 2aca80ab..5cfe0aa8 100644 --- a/pinecone/legacy_pinecone_interface.py +++ b/pinecone/legacy_pinecone_interface.py @@ -26,7 +26,10 @@ GcpRegion, AzureRegion, ) - from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict + from pinecone.db_control.types import ( + CreateIndexForModelEmbedTypedDict, + ConfigureIndexEmbed, + ) class LegacyPineconeDBControlInterface(ABC): @@ -438,6 +441,7 @@ def configure_index( pod_type: Optional[Union["PodType", str]] = None, deletion_protection: Optional[Union["DeletionProtection", str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Union["ConfigureIndexEmbed", Dict]] = None, ): """ :param name: the name of the Index @@ -452,6 +456,10 @@ def configure_index( :type deletion_protection: str or DeletionProtection, optional :param tags: A dictionary of tags to apply to the index. Tags are key-value pairs that can be used to organize and manage indexes. To remove a tag, set the value to "". Tags passed to configure_index will be merged with existing tags and any with the value empty string will be removed. :type tags: Dict[str, str], optional + :param embed: configures the integrated inference embedding settings for the index. You can convert an existing index to an integrated index by specifying the embedding model and field_map. + The index vector type and dimension must match the model vector type and dimension, and the index similarity metric must be supported by the model. + You can later change the embedding configuration to update the field_map, read_parameters, or write_parameters. Once set, the model cannot be changed. + :type embed: Optional[Union[ConfigureIndexEmbed, Dict]], optional This method is used to modify an index's configuration. It can be used to: diff --git a/pinecone/pinecone.py b/pinecone/pinecone.py index 202bed3b..df6b8c65 100644 --- a/pinecone/pinecone.py +++ b/pinecone/pinecone.py @@ -18,7 +18,10 @@ from pinecone.db_data import _Index as Index, _IndexAsyncio as IndexAsyncio from pinecone.db_control.index_host_store import IndexHostStore from pinecone.core.openapi.db_control.api.manage_indexes_api import ManageIndexesApi - from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict + from pinecone.db_control.types import ( + CreateIndexForModelEmbedTypedDict, + ConfigureIndexEmbed, + ) from pinecone.db_control.enums import ( Metric, VectorType, @@ -225,7 +228,9 @@ def __init__( ) """ :meta private: """ - self._openapi_config = ConfigBuilder.build_openapi_config(self._config, **kwargs) + self._openapi_config = ConfigBuilder.build_openapi_config( + self._config, **kwargs + ) """ :meta private: """ if pool_threads is None: @@ -399,6 +404,7 @@ def configure_index( pod_type: Optional[Union["PodType", str]] = None, deletion_protection: Optional[Union["DeletionProtection", str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Union["ConfigureIndexEmbed", Dict]] = None, ): return self.db.index.configure( name=name, @@ -406,6 +412,7 @@ def configure_index( pod_type=pod_type, deletion_protection=deletion_protection, tags=tags, + embed=embed, ) def create_collection(self, name: str, source: str) -> None: diff --git a/pinecone/pinecone_interface_asyncio.py b/pinecone/pinecone_interface_asyncio.py index 843ee83a..24e714c9 100644 --- a/pinecone/pinecone_interface_asyncio.py +++ b/pinecone/pinecone_interface_asyncio.py @@ -30,7 +30,10 @@ GcpRegion, AzureRegion, ) - from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict + from pinecone.db_control.types import ( + ConfigureIndexEmbed, + CreateIndexForModelEmbedTypedDict, + ) class PineconeAsyncioDBControlInterface(ABC): @@ -711,6 +714,7 @@ async def configure_index( pod_type: Optional[Union["PodType", str]] = None, deletion_protection: Optional[Union["DeletionProtection", str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Union["ConfigureIndexEmbed", Dict]] = None, ): """ :param: name: the name of the Index @@ -719,6 +723,10 @@ async def configure_index( available pod types, please see `Understanding Indexes `_ :param: deletion_protection: If set to 'enabled', the index cannot be deleted. If 'disabled', the index can be deleted. :param: tags: A dictionary of tags to apply to the index. Tags are key-value pairs that can be used to organize and manage indexes. To remove a tag, set the value to "". Tags passed to configure_index will be merged with existing tags and any with the value empty string will be removed. + :param embed: configures the integrated inference embedding settings for the index. You can convert an existing index to an integrated index by specifying the embedding model and field_map. + The index vector type and dimension must match the model vector type and dimension, and the index similarity metric must be supported by the model. + You can later change the embedding configuration to update the field_map, read_parameters, or write_parameters. Once set, the model cannot be changed. + :type embed: Optional[Union[ConfigureIndexEmbed, Dict]], optional This method is used to modify an index's configuration. It can be used to: From 7b1146b47de52ad00efd785ff10614c5101b7ddf Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 17 Jun 2025 14:56:32 -0400 Subject: [PATCH 06/12] expose embed on asyncio configure method --- pinecone/pinecone_asyncio.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pinecone/pinecone_asyncio.py b/pinecone/pinecone_asyncio.py index 36d86495..d313dc6f 100644 --- a/pinecone/pinecone_asyncio.py +++ b/pinecone/pinecone_asyncio.py @@ -10,7 +10,10 @@ from .pinecone import check_realistic_host if TYPE_CHECKING: - from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict + from pinecone.db_control.types import ( + ConfigureIndexEmbed, + CreateIndexForModelEmbedTypedDict, + ) from pinecone.db_data import _IndexAsyncio from pinecone.db_control.enums import ( Metric, @@ -35,7 +38,9 @@ RestoreJobModel, RestoreJobList, ) - from pinecone.core.openapi.db_control.api.manage_indexes_api import AsyncioManageIndexesApi + from pinecone.core.openapi.db_control.api.manage_indexes_api import ( + AsyncioManageIndexesApi, + ) from pinecone.db_control.index_host_store import IndexHostStore logger = logging.getLogger(__name__) @@ -100,7 +105,9 @@ def __init__( ) """ :meta private: """ - self._openapi_config = ConfigBuilder.build_openapi_config(self._config, **kwargs) + self._openapi_config = ConfigBuilder.build_openapi_config( + self._config, **kwargs + ) """ :meta private: """ self._inference = None # Lazy initialization @@ -273,6 +280,7 @@ async def configure_index( pod_type: Optional[Union["PodType", str]] = None, deletion_protection: Optional[Union["DeletionProtection", str]] = None, tags: Optional[Dict[str, str]] = None, + embed: Optional[Union["ConfigureIndexEmbed", Dict]] = None, ): return await self.db.index.configure( name=name, @@ -280,6 +288,7 @@ async def configure_index( pod_type=pod_type, deletion_protection=deletion_protection, tags=tags, + embed=embed, ) async def create_collection(self, name: str, source: str): @@ -326,7 +335,9 @@ async def delete_backup(self, *, backup_id: str) -> None: async def list_restore_jobs( self, *, limit: Optional[int] = 10, pagination_token: Optional[str] = None ) -> "RestoreJobList": - return await self.db.restore_job.list(limit=limit, pagination_token=pagination_token) + return await self.db.restore_job.list( + limit=limit, pagination_token=pagination_token + ) @require_kwargs async def describe_restore_job(self, *, job_id: str) -> "RestoreJobModel": From 77a2118929dbe3a733d205da36a3d09d9275a436 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 18 Jun 2025 00:15:38 -0400 Subject: [PATCH 07/12] add integration tests for integrated inference upgrade path --- .../control/resources/index/test_configure.py | 25 ++++++++++++++++ .../serverless/test_configure_index_embed.py | 25 ++++++++++++++++ .../test_configure_index_embed.py | 29 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/integration/control/serverless/test_configure_index_embed.py create mode 100644 tests/integration/control_asyncio/test_configure_index_embed.py diff --git a/tests/integration/control/resources/index/test_configure.py b/tests/integration/control/resources/index/test_configure.py index f4c73094..12b0573c 100644 --- a/tests/integration/control/resources/index/test_configure.py +++ b/tests/integration/control/resources/index/test_configure.py @@ -41,3 +41,28 @@ def test_remove_multiple_tags(self, pc, ready_sl_index): assert found_tags is not None assert found_tags.get("foo", None) is None, "foo should be removed" assert found_tags.get("bar", None) is None, "bar should be removed" + + def test_configure_index_embed(self, pc, create_sl_index_params): + name = create_sl_index_params["name"] + create_sl_index_params["dimension"] = 1024 + pc.db.index.create(**create_sl_index_params) + desc = pc.db.index.describe_index(name) + assert desc.embed == None + + embed_config = { + "model": "multilingual-e5-large", + "field_map": {"text": "chunk_text"}, + } + pc.db.index.configure(name, embed=embed_config) + + desc = pc.db.index.describe_index(name) + assert desc.embed.model == "multilingual-e5-large" + assert desc.embed.field_map == {"text": "chunk_text"} + assert desc.embed.read_parameters == {} + assert desc.embed.write_parameters == {} + assert desc.embed.vector_type == "dense" + assert desc.embed.dimension == 1024 + assert desc.embed.metric == "cosine" + assert desc.embed.model_type == "dense" + + pc.db.index.delete_index(name) diff --git a/tests/integration/control/serverless/test_configure_index_embed.py b/tests/integration/control/serverless/test_configure_index_embed.py new file mode 100644 index 00000000..86fc9e3a --- /dev/null +++ b/tests/integration/control/serverless/test_configure_index_embed.py @@ -0,0 +1,25 @@ +class TestConfigureIndexEmbed: + def test_convert_index_to_integrated(self, client, create_sl_index_params): + name = create_sl_index_params["name"] + create_sl_index_params["dimension"] = 1024 + client.create_index(**create_sl_index_params) + desc = client.describe_index(name) + assert desc.embed == None + + embed_config = { + "model": "multilingual-e5-large", + "field_map": {"text": "chunk_text"}, + } + client.configure_index(name, embed=embed_config) + + desc = client.describe_index(name) + assert desc.embed.model == "multilingual-e5-large" + assert desc.embed.field_map == {"text": "chunk_text"} + assert desc.embed.read_parameters == {} + assert desc.embed.write_parameters == {} + assert desc.embed.vector_type == "dense" + assert desc.embed.dimension == 1024 + assert desc.embed.metric == "cosine" + assert desc.embed.model_type == "dense" + + client.delete_index(name) diff --git a/tests/integration/control_asyncio/test_configure_index_embed.py b/tests/integration/control_asyncio/test_configure_index_embed.py new file mode 100644 index 00000000..ab46c1e3 --- /dev/null +++ b/tests/integration/control_asyncio/test_configure_index_embed.py @@ -0,0 +1,29 @@ +from pinecone import PineconeAsyncio + + +class TestConfigureIndexEmbed: + async def test_convert_index_to_integrated(self, create_sl_index_params): + pc = PineconeAsyncio() + name = create_sl_index_params["name"] + create_sl_index_params["dimension"] = 1024 + await pc.create_index(**create_sl_index_params) + desc = await pc.describe_index(name) + assert desc.embed == None + + embed_config = { + "model": "multilingual-e5-large", + "field_map": {"text": "chunk_text"}, + } + await pc.configure_index(name, embed=embed_config) + + desc = await pc.describe_index(name) + assert desc.embed.model == "multilingual-e5-large" + assert desc.embed.field_map == {"text": "chunk_text"} + assert desc.embed.read_parameters == {} + assert desc.embed.write_parameters == {} + assert desc.embed.vector_type == "dense" + assert desc.embed.dimension == 1024 + assert desc.embed.metric == "cosine" + assert desc.embed.model_type == "dense" + + await pc.delete_index(name) From 107a1cd3c6c189adb8270bc6b43fe7a0b14f1c01 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 18 Jun 2025 01:01:32 -0400 Subject: [PATCH 08/12] fix assertions in embed integration tests --- .../control/resources/index/test_configure.py | 10 ++++++---- .../control/serverless/test_configure_index_embed.py | 10 ++++++---- .../control_asyncio/test_configure_index_embed.py | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/integration/control/resources/index/test_configure.py b/tests/integration/control/resources/index/test_configure.py index 12b0573c..22802dd3 100644 --- a/tests/integration/control/resources/index/test_configure.py +++ b/tests/integration/control/resources/index/test_configure.py @@ -47,7 +47,7 @@ def test_configure_index_embed(self, pc, create_sl_index_params): create_sl_index_params["dimension"] = 1024 pc.db.index.create(**create_sl_index_params) desc = pc.db.index.describe_index(name) - assert desc.embed == None + assert desc.embed is None embed_config = { "model": "multilingual-e5-large", @@ -58,11 +58,13 @@ def test_configure_index_embed(self, pc, create_sl_index_params): desc = pc.db.index.describe_index(name) assert desc.embed.model == "multilingual-e5-large" assert desc.embed.field_map == {"text": "chunk_text"} - assert desc.embed.read_parameters == {} - assert desc.embed.write_parameters == {} + assert desc.embed.read_parameters == {"input_type": "query", "truncate": "END"} + assert desc.embed.write_parameters == { + "input_type": "passage", + "truncate": "END", + } assert desc.embed.vector_type == "dense" assert desc.embed.dimension == 1024 assert desc.embed.metric == "cosine" - assert desc.embed.model_type == "dense" pc.db.index.delete_index(name) diff --git a/tests/integration/control/serverless/test_configure_index_embed.py b/tests/integration/control/serverless/test_configure_index_embed.py index 86fc9e3a..82658b8a 100644 --- a/tests/integration/control/serverless/test_configure_index_embed.py +++ b/tests/integration/control/serverless/test_configure_index_embed.py @@ -4,7 +4,7 @@ def test_convert_index_to_integrated(self, client, create_sl_index_params): create_sl_index_params["dimension"] = 1024 client.create_index(**create_sl_index_params) desc = client.describe_index(name) - assert desc.embed == None + assert desc.embed is None embed_config = { "model": "multilingual-e5-large", @@ -15,11 +15,13 @@ def test_convert_index_to_integrated(self, client, create_sl_index_params): desc = client.describe_index(name) assert desc.embed.model == "multilingual-e5-large" assert desc.embed.field_map == {"text": "chunk_text"} - assert desc.embed.read_parameters == {} - assert desc.embed.write_parameters == {} + assert desc.embed.read_parameters == {"input_type": "query", "truncate": "END"} + assert desc.embed.write_parameters == { + "input_type": "passage", + "truncate": "END", + } assert desc.embed.vector_type == "dense" assert desc.embed.dimension == 1024 assert desc.embed.metric == "cosine" - assert desc.embed.model_type == "dense" client.delete_index(name) diff --git a/tests/integration/control_asyncio/test_configure_index_embed.py b/tests/integration/control_asyncio/test_configure_index_embed.py index ab46c1e3..db05094d 100644 --- a/tests/integration/control_asyncio/test_configure_index_embed.py +++ b/tests/integration/control_asyncio/test_configure_index_embed.py @@ -8,7 +8,7 @@ async def test_convert_index_to_integrated(self, create_sl_index_params): create_sl_index_params["dimension"] = 1024 await pc.create_index(**create_sl_index_params) desc = await pc.describe_index(name) - assert desc.embed == None + assert desc.embed is None embed_config = { "model": "multilingual-e5-large", @@ -19,11 +19,13 @@ async def test_convert_index_to_integrated(self, create_sl_index_params): desc = await pc.describe_index(name) assert desc.embed.model == "multilingual-e5-large" assert desc.embed.field_map == {"text": "chunk_text"} - assert desc.embed.read_parameters == {} - assert desc.embed.write_parameters == {} + assert desc.embed.read_parameters == {"input_type": "query", "truncate": "END"} + assert desc.embed.write_parameters == { + "input_type": "passage", + "truncate": "END", + } assert desc.embed.vector_type == "dense" assert desc.embed.dimension == 1024 assert desc.embed.metric == "cosine" - assert desc.embed.model_type == "dense" await pc.delete_index(name) From 48db04e80f392d14ccdddd8f612366473aed313c Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 18 Jun 2025 01:36:25 -0400 Subject: [PATCH 09/12] add black defaults in pyproject.toml, undo a bunch of the <100 line breaks --- pinecone/__init__.py | 29 ++---- pinecone/db_control/request_factory.py | 96 +++++-------------- .../db_control/resources/asyncio/index.py | 18 +--- pinecone/db_control/resources/sync/index.py | 10 +- pinecone/legacy_pinecone_interface.py | 5 +- pinecone/pinecone.py | 9 +- pinecone/pinecone_asyncio.py | 17 +--- pinecone/pinecone_interface_asyncio.py | 5 +- pyproject.toml | 4 + 9 files changed, 48 insertions(+), 145 deletions(-) diff --git a/pinecone/__init__.py b/pinecone/__init__.py index e5b00edd..7b435e9e 100644 --- a/pinecone/__init__.py +++ b/pinecone/__init__.py @@ -2,9 +2,7 @@ .. include:: ../pdoc/README.md """ -from .deprecated_plugins import ( - check_for_deprecated_plugins as _check_for_deprecated_plugins, -) +from .deprecated_plugins import check_for_deprecated_plugins as _check_for_deprecated_plugins from .deprecation_warnings import * from .pinecone import Pinecone from .pinecone_asyncio import PineconeAsyncio @@ -48,10 +46,7 @@ "SearchRerank": ("pinecone.db_data.dataclasses", "SearchRerank"), "FetchResponse": ("pinecone.db_data.dataclasses", "FetchResponse"), "DeleteRequest": ("pinecone.db_data.models", "DeleteRequest"), - "DescribeIndexStatsRequest": ( - "pinecone.db_data.models", - "DescribeIndexStatsRequest", - ), + "DescribeIndexStatsRequest": ("pinecone.db_data.models", "DescribeIndexStatsRequest"), "DescribeIndexStatsResponse": ("pinecone.db_data.models", "IndexDescription"), "RpcStatus": ("pinecone.db_data.models", "RpcStatus"), "ScoredVector": ("pinecone.db_data.models", "ScoredVector"), @@ -60,14 +55,8 @@ "QueryResponse": ("pinecone.db_data.models", "QueryResponse"), "UpsertResponse": ("pinecone.db_data.models", "UpsertResponse"), "UpdateRequest": ("pinecone.db_data.models", "UpdateRequest"), - "NamespaceDescription": ( - "pinecone.core.openapi.db_data.models", - "NamespaceDescription", - ), - "ImportErrorMode": ( - "pinecone.db_data.resources.sync.bulk_import", - "ImportErrorMode", - ), + "NamespaceDescription": ("pinecone.core.openapi.db_data.models", "NamespaceDescription"), + "ImportErrorMode": ("pinecone.db_data.resources.sync.bulk_import", "ImportErrorMode"), "VectorDictionaryMissingKeysError": ( "pinecone.db_data.errors", "VectorDictionaryMissingKeysError", @@ -78,10 +67,7 @@ ), "VectorTupleLengthError": ("pinecone.db_data.errors", "VectorTupleLengthError"), "SparseValuesTypeError": ("pinecone.db_data.errors", "SparseValuesTypeError"), - "SparseValuesMissingKeysError": ( - "pinecone.db_data.errors", - "SparseValuesMissingKeysError", - ), + "SparseValuesMissingKeysError": ("pinecone.db_data.errors", "SparseValuesMissingKeysError"), "SparseValuesDictionaryExpectedError": ( "pinecone.db_data.errors", "SparseValuesDictionaryExpectedError", @@ -104,10 +90,7 @@ "IndexEmbed": ("pinecone.db_control.models", "IndexEmbed"), "ByocSpec": ("pinecone.db_control.models", "ByocSpec"), "ServerlessSpec": ("pinecone.db_control.models", "ServerlessSpec"), - "ServerlessSpecDefinition": ( - "pinecone.db_control.models", - "ServerlessSpecDefinition", - ), + "ServerlessSpecDefinition": ("pinecone.db_control.models", "ServerlessSpecDefinition"), "PodSpec": ("pinecone.db_control.models", "PodSpec"), "PodSpecDefinition": ("pinecone.db_control.models", "PodSpecDefinition"), "PodType": ("pinecone.db_control.enums", "PodType"), diff --git a/pinecone/db_control/request_factory.py b/pinecone/db_control/request_factory.py index bbd1b2f9..070185e9 100644 --- a/pinecone/db_control/request_factory.py +++ b/pinecone/db_control/request_factory.py @@ -4,21 +4,15 @@ from pinecone.utils import parse_non_empty_args, convert_enum_to_string -from pinecone.core.openapi.db_control.model.create_collection_request import ( - CreateCollectionRequest, -) +from pinecone.core.openapi.db_control.model.create_collection_request import CreateCollectionRequest from pinecone.core.openapi.db_control.model.create_index_for_model_request import ( CreateIndexForModelRequest, ) from pinecone.core.openapi.db_control.model.create_index_for_model_request_embed import ( CreateIndexForModelRequestEmbed, ) -from pinecone.core.openapi.db_control.model.create_index_request import ( - CreateIndexRequest, -) -from pinecone.core.openapi.db_control.model.configure_index_request import ( - ConfigureIndexRequest, -) +from pinecone.core.openapi.db_control.model.create_index_request import CreateIndexRequest +from pinecone.core.openapi.db_control.model.configure_index_request import ConfigureIndexRequest from pinecone.core.openapi.db_control.model.configure_index_request_spec import ( ConfigureIndexRequestSpec, ) @@ -38,19 +32,11 @@ ) from pinecone.core.openapi.db_control.model.byoc_spec import ByocSpec as ByocSpecModel from pinecone.core.openapi.db_control.model.pod_spec import PodSpec as PodSpecModel -from pinecone.core.openapi.db_control.model.pod_spec_metadata_config import ( - PodSpecMetadataConfig, -) +from pinecone.core.openapi.db_control.model.pod_spec_metadata_config import PodSpecMetadataConfig from pinecone.core.openapi.db_control.model.create_index_from_backup_request import ( CreateIndexFromBackupRequest, ) -from pinecone.db_control.models import ( - ServerlessSpec, - PodSpec, - ByocSpec, - IndexModel, - IndexEmbed, -) +from pinecone.db_control.models import ServerlessSpec, PodSpec, ByocSpec, IndexModel, IndexEmbed from pinecone.db_control.enums import ( Metric, @@ -91,30 +77,18 @@ def __parse_deletion_protection( if deletion_protection in ["enabled", "disabled"]: return DeletionProtectionModel(deletion_protection) else: - raise ValueError( - "deletion_protection must be either 'enabled' or 'disabled'" - ) + raise ValueError("deletion_protection must be either 'enabled' or 'disabled'") @staticmethod - def __parse_index_spec( - spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec], - ) -> IndexSpec: + def __parse_index_spec(spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec]) -> IndexSpec: if isinstance(spec, dict): if "serverless" in spec: - spec["serverless"]["cloud"] = convert_enum_to_string( - spec["serverless"]["cloud"] - ) - spec["serverless"]["region"] = convert_enum_to_string( - spec["serverless"]["region"] - ) + spec["serverless"]["cloud"] = convert_enum_to_string(spec["serverless"]["cloud"]) + spec["serverless"]["region"] = convert_enum_to_string(spec["serverless"]["region"]) - index_spec = IndexSpec( - serverless=ServerlessSpecModel(**spec["serverless"]) - ) + index_spec = IndexSpec(serverless=ServerlessSpecModel(**spec["serverless"])) elif "pod" in spec: - spec["pod"]["environment"] = convert_enum_to_string( - spec["pod"]["environment"] - ) + spec["pod"]["environment"] = convert_enum_to_string(spec["pod"]["environment"]) args_dict = parse_non_empty_args( [ ("environment", spec["pod"].get("environment")), @@ -133,9 +107,7 @@ def __parse_index_spec( elif "byoc" in spec: index_spec = IndexSpec(byoc=ByocSpecModel(**spec["byoc"])) else: - raise ValueError( - "spec must contain either 'serverless', 'pod', or 'byoc' key" - ) + raise ValueError("spec must contain either 'serverless', 'pod', or 'byoc' key") elif isinstance(spec, ServerlessSpec): index_spec = IndexSpec( serverless=ServerlessSpecModel(cloud=spec.cloud, region=spec.region) @@ -155,17 +127,13 @@ def __parse_index_spec( ) index_spec = IndexSpec( - pod=PodSpecModel( - environment=spec.environment, pod_type=spec.pod_type, **args_dict - ) + pod=PodSpecModel(environment=spec.environment, pod_type=spec.pod_type, **args_dict) ) elif isinstance(spec, ByocSpec): args_dict = parse_non_empty_args([("environment", spec.environment)]) index_spec = IndexSpec(byoc=ByocSpecModel(**args_dict)) else: - raise TypeError( - "spec must be of type dict, ServerlessSpec, PodSpec, or ByocSpec" - ) + raise TypeError("spec must be of type dict, ServerlessSpec, PodSpec, or ByocSpec") return index_spec @@ -175,9 +143,7 @@ def create_index_request( spec: Union[Dict, ServerlessSpec, PodSpec, ByocSpec], dimension: Optional[int] = None, metric: Optional[Union[Metric, str]] = Metric.COSINE, - deletion_protection: Optional[ - Union[DeletionProtection, str] - ] = DeletionProtection.DISABLED, + deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, vector_type: Optional[Union[VectorType, str]] = VectorType.DENSE, tags: Optional[Dict[str, str]] = None, ) -> CreateIndexRequest: @@ -186,9 +152,7 @@ def create_index_request( if vector_type is not None: vector_type = convert_enum_to_string(vector_type) if deletion_protection is not None: - dp = PineconeDBControlRequestFactory.__parse_deletion_protection( - deletion_protection - ) + dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection) else: dp = None @@ -219,16 +183,12 @@ def create_index_for_model_request( region: Union[AwsRegion, GcpRegion, AzureRegion, str], embed: Union[IndexEmbed, CreateIndexForModelEmbedTypedDict], tags: Optional[Dict[str, str]] = None, - deletion_protection: Optional[ - Union[DeletionProtection, str] - ] = DeletionProtection.DISABLED, + deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, ) -> CreateIndexForModelRequest: cloud = convert_enum_to_string(cloud) region = convert_enum_to_string(region) if deletion_protection is not None: - dp = PineconeDBControlRequestFactory.__parse_deletion_protection( - deletion_protection - ) + dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection) else: dp = None tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags) @@ -265,23 +225,17 @@ def create_index_for_model_request( @staticmethod def create_index_from_backup_request( name: str, - deletion_protection: Optional[ - Union[DeletionProtection, str] - ] = DeletionProtection.DISABLED, + deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, tags: Optional[Dict[str, str]] = None, ) -> CreateIndexFromBackupRequest: if deletion_protection is not None: - dp = PineconeDBControlRequestFactory.__parse_deletion_protection( - deletion_protection - ) + dp = PineconeDBControlRequestFactory.__parse_deletion_protection(deletion_protection) else: dp = None tags_obj = PineconeDBControlRequestFactory.__parse_tags(tags) - return CreateIndexFromBackupRequest( - name=name, deletion_protection=dp, tags=tags_obj - ) + return CreateIndexFromBackupRequest(name=name, deletion_protection=dp, tags=tags_obj) @staticmethod def configure_index_request( @@ -299,9 +253,7 @@ def configure_index_request( elif deletion_protection in ["enabled", "disabled"]: dp = DeletionProtectionModel(deletion_protection) else: - raise ValueError( - "deletion_protection must be either 'enabled' or 'disabled'" - ) + raise ValueError("deletion_protection must be either 'enabled' or 'disabled'") fetched_tags = description.tags if fetched_tags is None: @@ -329,9 +281,7 @@ def configure_index_request( spec = None if pod_config_args: - spec = ConfigureIndexRequestSpec( - pod=ConfigureIndexRequestSpecPod(**pod_config_args) - ) + spec = ConfigureIndexRequestSpec(pod=ConfigureIndexRequestSpecPod(**pod_config_args)) args_dict = parse_non_empty_args( [ diff --git a/pinecone/db_control/resources/asyncio/index.py b/pinecone/db_control/resources/asyncio/index.py index 1d292198..412e0673 100644 --- a/pinecone/db_control/resources/asyncio/index.py +++ b/pinecone/db_control/resources/asyncio/index.py @@ -1,6 +1,6 @@ import logging import asyncio -from typing import Optional, Dict, Union +from typing import Optional, Dict, Union, Any from pinecone.db_control.models import ( @@ -47,9 +47,7 @@ async def create( dimension: Optional[int] = None, metric: Optional[Union[Metric, str]] = Metric.COSINE, timeout: Optional[int] = None, - deletion_protection: Optional[ - Union[DeletionProtection, str] - ] = DeletionProtection.DISABLED, + deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, vector_type: Optional[Union[VectorType, str]] = VectorType.DENSE, tags: Optional[Dict[str, str]] = None, ) -> IndexModel: @@ -77,9 +75,7 @@ async def create_for_model( region: Union[AwsRegion, GcpRegion, AzureRegion, str], embed: Union[IndexEmbed, CreateIndexForModelEmbedTypedDict], tags: Optional[Dict[str, str]] = None, - deletion_protection: Optional[ - Union[DeletionProtection, str] - ] = DeletionProtection.DISABLED, + deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, timeout: Optional[int] = None, ) -> IndexModel: req = PineconeDBControlRequestFactory.create_index_for_model_request( @@ -102,9 +98,7 @@ async def create_from_backup( *, name: str, backup_id: str, - deletion_protection: Optional[ - Union[DeletionProtection, str] - ] = DeletionProtection.DISABLED, + deletion_protection: Optional[Union[DeletionProtection, str]] = DeletionProtection.DISABLED, tags: Optional[Dict[str, str]] = None, timeout: Optional[int] = None, ) -> IndexModel: @@ -116,9 +110,7 @@ async def create_from_backup( ) return await self.__poll_describe_index_until_ready(name, timeout) - async def __poll_describe_index_until_ready( - self, name: str, timeout: Optional[int] = None - ): + async def __poll_describe_index_until_ready(self, name: str, timeout: Optional[int] = None): total_wait_time = 0 while True: description = await self.describe(name=name) diff --git a/pinecone/db_control/resources/sync/index.py b/pinecone/db_control/resources/sync/index.py index c10af5a3..faf5f983 100644 --- a/pinecone/db_control/resources/sync/index.py +++ b/pinecone/db_control/resources/sync/index.py @@ -4,11 +4,7 @@ from pinecone.db_control.index_host_store import IndexHostStore -from pinecone.db_control.models import ( - IndexModel, - IndexList, - IndexEmbed, -) +from pinecone.db_control.models import IndexModel, IndexList, IndexEmbed from pinecone.utils import docslinks, require_kwargs, PluginAware from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict @@ -149,9 +145,7 @@ def create_from_backup( return self.describe(name=name) return self.__poll_describe_index_until_ready(name, timeout) - def __poll_describe_index_until_ready( - self, name: str, timeout: Optional[int] = None - ): + def __poll_describe_index_until_ready(self, name: str, timeout: Optional[int] = None): total_wait_time = 0 while True: description = self.describe(name=name) diff --git a/pinecone/legacy_pinecone_interface.py b/pinecone/legacy_pinecone_interface.py index 5cfe0aa8..0a085462 100644 --- a/pinecone/legacy_pinecone_interface.py +++ b/pinecone/legacy_pinecone_interface.py @@ -26,10 +26,7 @@ GcpRegion, AzureRegion, ) - from pinecone.db_control.types import ( - CreateIndexForModelEmbedTypedDict, - ConfigureIndexEmbed, - ) + from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict, ConfigureIndexEmbed class LegacyPineconeDBControlInterface(ABC): diff --git a/pinecone/pinecone.py b/pinecone/pinecone.py index df6b8c65..d8c8a1b4 100644 --- a/pinecone/pinecone.py +++ b/pinecone/pinecone.py @@ -18,10 +18,7 @@ from pinecone.db_data import _Index as Index, _IndexAsyncio as IndexAsyncio from pinecone.db_control.index_host_store import IndexHostStore from pinecone.core.openapi.db_control.api.manage_indexes_api import ManageIndexesApi - from pinecone.db_control.types import ( - CreateIndexForModelEmbedTypedDict, - ConfigureIndexEmbed, - ) + from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict, ConfigureIndexEmbed from pinecone.db_control.enums import ( Metric, VectorType, @@ -228,9 +225,7 @@ def __init__( ) """ :meta private: """ - self._openapi_config = ConfigBuilder.build_openapi_config( - self._config, **kwargs - ) + self._openapi_config = ConfigBuilder.build_openapi_config(self._config, **kwargs) """ :meta private: """ if pool_threads is None: diff --git a/pinecone/pinecone_asyncio.py b/pinecone/pinecone_asyncio.py index d313dc6f..425eb776 100644 --- a/pinecone/pinecone_asyncio.py +++ b/pinecone/pinecone_asyncio.py @@ -10,10 +10,7 @@ from .pinecone import check_realistic_host if TYPE_CHECKING: - from pinecone.db_control.types import ( - ConfigureIndexEmbed, - CreateIndexForModelEmbedTypedDict, - ) + from pinecone.db_control.types import ConfigureIndexEmbed, CreateIndexForModelEmbedTypedDict from pinecone.db_data import _IndexAsyncio from pinecone.db_control.enums import ( Metric, @@ -38,9 +35,7 @@ RestoreJobModel, RestoreJobList, ) - from pinecone.core.openapi.db_control.api.manage_indexes_api import ( - AsyncioManageIndexesApi, - ) + from pinecone.core.openapi.db_control.api.manage_indexes_api import AsyncioManageIndexesApi from pinecone.db_control.index_host_store import IndexHostStore logger = logging.getLogger(__name__) @@ -105,9 +100,7 @@ def __init__( ) """ :meta private: """ - self._openapi_config = ConfigBuilder.build_openapi_config( - self._config, **kwargs - ) + self._openapi_config = ConfigBuilder.build_openapi_config(self._config, **kwargs) """ :meta private: """ self._inference = None # Lazy initialization @@ -335,9 +328,7 @@ async def delete_backup(self, *, backup_id: str) -> None: async def list_restore_jobs( self, *, limit: Optional[int] = 10, pagination_token: Optional[str] = None ) -> "RestoreJobList": - return await self.db.restore_job.list( - limit=limit, pagination_token=pagination_token - ) + return await self.db.restore_job.list(limit=limit, pagination_token=pagination_token) @require_kwargs async def describe_restore_job(self, *, job_id: str) -> "RestoreJobModel": diff --git a/pinecone/pinecone_interface_asyncio.py b/pinecone/pinecone_interface_asyncio.py index 24e714c9..0d544f10 100644 --- a/pinecone/pinecone_interface_asyncio.py +++ b/pinecone/pinecone_interface_asyncio.py @@ -30,10 +30,7 @@ GcpRegion, AzureRegion, ) - from pinecone.db_control.types import ( - ConfigureIndexEmbed, - CreateIndexForModelEmbedTypedDict, - ) + from pinecone.db_control.types import ConfigureIndexEmbed, CreateIndexForModelEmbedTypedDict class PineconeAsyncioDBControlInterface(ABC): diff --git a/pyproject.toml b/pyproject.toml index ce982784..3852f355 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,3 +166,7 @@ docstring-code-line-length = "dynamic" # E712 Allow == comparison to True/False "tests/**" = ["E712"] + +[tool.black] +line-length = 100 +target-version = ["py39"] From 4058f2448e699f88214aa90a9705c5b425d67638 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 18 Jun 2025 03:24:49 -0400 Subject: [PATCH 10/12] lint --- pinecone/db_control/resources/asyncio/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinecone/db_control/resources/asyncio/index.py b/pinecone/db_control/resources/asyncio/index.py index 412e0673..5a844b5a 100644 --- a/pinecone/db_control/resources/asyncio/index.py +++ b/pinecone/db_control/resources/asyncio/index.py @@ -1,6 +1,6 @@ import logging import asyncio -from typing import Optional, Dict, Union, Any +from typing import Optional, Dict, Union from pinecone.db_control.models import ( From 570c5ff2e2543f27d4b7c6e01faa141e50d4a504 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 18 Jun 2025 03:26:53 -0400 Subject: [PATCH 11/12] use proper fixture name in sync resources test --- .../integration/control/resources/index/test_configure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/control/resources/index/test_configure.py b/tests/integration/control/resources/index/test_configure.py index 22802dd3..7b89382b 100644 --- a/tests/integration/control/resources/index/test_configure.py +++ b/tests/integration/control/resources/index/test_configure.py @@ -42,10 +42,10 @@ def test_remove_multiple_tags(self, pc, ready_sl_index): assert found_tags.get("foo", None) is None, "foo should be removed" assert found_tags.get("bar", None) is None, "bar should be removed" - def test_configure_index_embed(self, pc, create_sl_index_params): - name = create_sl_index_params["name"] - create_sl_index_params["dimension"] = 1024 - pc.db.index.create(**create_sl_index_params) + def test_configure_index_embed(self, pc, create_index_params): + name = create_index_params["name"] + create_index_params["dimension"] = 1024 + pc.db.index.create(**create_index_params) desc = pc.db.index.describe_index(name) assert desc.embed is None From b4ab8207ff43755f764f6cc77f70b38f12f927f0 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 18 Jun 2025 03:57:33 -0400 Subject: [PATCH 12/12] fix resource test --- .../integration/control/resources/index/test_configure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/control/resources/index/test_configure.py b/tests/integration/control/resources/index/test_configure.py index 7b89382b..96203e1a 100644 --- a/tests/integration/control/resources/index/test_configure.py +++ b/tests/integration/control/resources/index/test_configure.py @@ -46,16 +46,16 @@ def test_configure_index_embed(self, pc, create_index_params): name = create_index_params["name"] create_index_params["dimension"] = 1024 pc.db.index.create(**create_index_params) - desc = pc.db.index.describe_index(name) + desc = pc.db.index.describe(name=name) assert desc.embed is None embed_config = { "model": "multilingual-e5-large", "field_map": {"text": "chunk_text"}, } - pc.db.index.configure(name, embed=embed_config) + pc.db.index.configure(name=name, embed=embed_config) - desc = pc.db.index.describe_index(name) + desc = pc.db.index.describe(name=name) assert desc.embed.model == "multilingual-e5-large" assert desc.embed.field_map == {"text": "chunk_text"} assert desc.embed.read_parameters == {"input_type": "query", "truncate": "END"} @@ -67,4 +67,4 @@ def test_configure_index_embed(self, pc, create_index_params): assert desc.embed.dimension == 1024 assert desc.embed.metric == "cosine" - pc.db.index.delete_index(name) + pc.db.index.delete(name=name)