Skip to content

Commit

Permalink
Code review commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkuprowski committed Jan 10, 2025
1 parent 7f74808 commit 0b7da52
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions unstructured_ingest/v2/processes/connectors/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,32 +178,32 @@ def precheck(self):
def pod_delete_by_record_id(self, file_data: FileData) -> None:
"""Deletion for Pinecone Pod-based index."""
logger.debug(
f"Deleting any content with metadata "
f"deleting any content with metadata "
f"{self.upload_config.record_id_key}={file_data.identifier} "
f"from Pinecone pod index"
f"from pinecone pod index"
)
index = self.connection_config.get_index(pool_threads=MAX_POOL_THREADS)

# Build the delete_kwargs, only include 'namespace' if it's not None
delete_kwargs = {
"filter": {self.upload_config.record_id_key: {"$eq": file_data.identifier}},
}
if self.upload_config.namespace is not None:
delete_kwargs["namespace"] = self.upload_config.namespace
if namespace := self.upload_config.namespace:
delete_kwargs["namespace"] = namespace

resp = index.delete(**delete_kwargs)
logger.debug(
f"Deleted any content with metadata "
f"deleted any content with metadata "
f"{self.upload_config.record_id_key}={file_data.identifier} "
f"from Pinecone index: {resp}"
f"from pinecone index: {resp}"
)

def serverless_delete_by_record_id(self, file_data: FileData) -> None:
"""Deletion for Pinecone Serverless index."""
logger.debug(
f"Deleting any content with metadata "
f"deleting any content with metadata "
f"{self.upload_config.record_id_key}={file_data.identifier} "
f"from Pinecone serverless index"
f"from pinecone serverless index"
)
index = self.connection_config.get_index(pool_threads=MAX_POOL_THREADS)

Expand All @@ -220,12 +220,12 @@ def serverless_delete_by_record_id(self, file_data: FileData) -> None:
delete_kwargs["namespace"] = self.upload_config.namespace
delete_resp = index.delete(**delete_kwargs)
if delete_resp:
logger.error(f"Failed to delete batch of IDs: {delete_resp}")
logger.error(f"failed to delete batch of IDs: {delete_resp}")

logger.info(
f"Deleted {deleted_ids} records with metadata "
f"deleted {deleted_ids} records with metadata "
f"{self.upload_config.record_id_key}={file_data.identifier} "
f"from Pinecone index"
f"from pinecone index"
)

@requires_dependencies(["pinecone"], extras="pinecone")
Expand Down

0 comments on commit 0b7da52

Please sign in to comment.