Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions pinecone/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ from pinecone.db_data.dataclasses import (
QueryResponse,
UpsertResponse,
UpdateResponse,
TextQuery,
VectorQuery,
Document,
DocumentSearchResponse,
)
from pinecone.db_data.query_helpers import text_query, vector_query
from pinecone.db_data.models import (
DeleteRequest,
DescribeIndexStatsRequest,
Expand Down Expand Up @@ -84,6 +89,20 @@ from pinecone.db_control.models import (
BackupList,
RestoreJobModel,
RestoreJobList,
# Schema field types
TextField,
IntegerField,
FloatField,
DenseVectorField,
SparseVectorField,
SemanticTextField,
SchemaField,
SchemaBuilder,
# Deployment classes
ServerlessDeployment,
ByocDeployment,
PodDeployment,
Deployment,
)
from pinecone.db_control.models.serverless_spec import (
ScalingConfigManualDict,
Expand Down Expand Up @@ -165,6 +184,13 @@ __all__ = [
"SearchQuery",
"SearchQueryVector",
"SearchRerank",
"TextQuery",
"VectorQuery",
"Document",
"DocumentSearchResponse",
# Query helper functions
"text_query",
"vector_query",
# Data response classes
"FetchResponse",
"FetchByMetadataResponse",
Expand Down Expand Up @@ -215,6 +241,20 @@ __all__ = [
"BackupList",
"RestoreJobModel",
"RestoreJobList",
# Schema field types
"TextField",
"IntegerField",
"FloatField",
"DenseVectorField",
"SparseVectorField",
"SemanticTextField",
"SchemaField",
"SchemaBuilder",
# Deployment classes
"ServerlessDeployment",
"ByocDeployment",
"PodDeployment",
"Deployment",
# Control plane types
"ConfigureIndexEmbed",
"CreateIndexForModelEmbedTypedDict",
Expand Down
1 change: 1 addition & 0 deletions tests/integration/rest_sync/db/data/fts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""FTS data plane integration tests."""
147 changes: 147 additions & 0 deletions tests/integration/rest_sync/db/data/fts/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
"""Fixtures for FTS data plane integration tests."""

import pytest
import uuid
import logging
import dotenv
from pinecone import Pinecone, TextField, IntegerField, DenseVectorField
from tests.integration.helpers import (
delete_indexes_from_run,
index_tags,
embedding_values,
poll_until_lsn_reconciled,
)

dotenv.load_dotenv()

logger = logging.getLogger(__name__)

RUN_ID = str(uuid.uuid4())

FTS_INDEX_DIMENSION = 8


@pytest.fixture(scope="module")
def pc():
"""Create a Pinecone client."""
return Pinecone()


@pytest.fixture(scope="module")
def fts_tags(request):
"""Generate tags for FTS test indexes."""
return index_tags(request, RUN_ID)


@pytest.fixture(scope="module")
def fts_index_name():
"""Generate a unique index name for FTS tests."""
return f"fts-data-{str(uuid.uuid4())[:8]}"


@pytest.fixture(scope="module")
def fts_index_host(pc: Pinecone, fts_index_name: str, fts_tags: dict):
"""Create an FTS-enabled index with schema and return its host.

This creates an index with:
- title: full-text searchable text field
- description: full-text searchable text field
- category: filterable text field
- year: filterable integer field
- embedding: dense vector field
"""
schema = {
"title": TextField(full_text_searchable=True),
"description": TextField(full_text_searchable=True),
"category": TextField(filterable=True),
"year": IntegerField(filterable=True),
"embedding": DenseVectorField(dimension=FTS_INDEX_DIMENSION, metric="cosine"),
}

logger.info(f"Creating FTS index {fts_index_name} with schema")
pc.db.index.create(name=fts_index_name, schema=schema, tags=fts_tags)

description = pc.db.index.describe(name=fts_index_name)
host = description.host
logger.info(f"FTS index {fts_index_name} created with host: {host}")

yield host

logger.info(f"Deleting FTS index {fts_index_name}")
try:
pc.db.index.delete(name=fts_index_name)
except Exception as e:
logger.warning(f"Failed to delete FTS index {fts_index_name}: {e}")


@pytest.fixture(scope="module")
def fts_index(pc: Pinecone, fts_index_name: str, fts_index_host: str):
"""Get an Index client for the FTS index."""
return pc.Index(name=fts_index_name, host=fts_index_host)


@pytest.fixture(scope="module")
def seeded_fts_namespace(fts_index, fts_index_name):
"""Seed the FTS index with test documents and return the namespace.

Returns the namespace that contains the seeded documents.
"""
namespace = f"test-{str(uuid.uuid4())[:8]}"

documents = [
{
"_id": "movie-1",
"title": "Return of the Pink Panther",
"description": "Inspector Clouseau investigates a diamond heist.",
"category": "comedy",
"year": 1975,
"embedding": embedding_values(FTS_INDEX_DIMENSION),
},
{
"_id": "movie-2",
"title": "The Pink Panther Strikes Again",
"description": "Clouseau's former boss tries to eliminate him.",
"category": "comedy",
"year": 1976,
"embedding": embedding_values(FTS_INDEX_DIMENSION),
},
{
"_id": "movie-3",
"title": "Revenge of the Pink Panther",
"description": "Clouseau is believed dead and investigates his own murder.",
"category": "comedy",
"year": 1978,
"embedding": embedding_values(FTS_INDEX_DIMENSION),
},
{
"_id": "movie-4",
"title": "The Matrix",
"description": "A hacker discovers the true nature of reality.",
"category": "scifi",
"year": 1999,
"embedding": embedding_values(FTS_INDEX_DIMENSION),
},
{
"_id": "movie-5",
"title": "Blade Runner",
"description": "A blade runner must pursue and terminate rogue replicants.",
"category": "scifi",
"year": 1982,
"embedding": embedding_values(FTS_INDEX_DIMENSION),
},
]

logger.info(f"Upserting {len(documents)} documents to namespace {namespace}")
upsert_response = fts_index.upsert_documents(namespace=namespace, documents=documents)

poll_until_lsn_reconciled(fts_index, upsert_response._response_info, namespace=namespace)

logger.info(f"Seeded namespace {namespace} with {len(documents)} documents")
return namespace


def pytest_sessionfinish(session, exitstatus):
"""Clean up indexes created during the test session."""
logger.info("Running final cleanup after FTS data plane tests...")
pc = Pinecone()
delete_indexes_from_run(pc, RUN_ID)
Loading