Release v3.0.2
Fixes
Create indexes using source_collection
option in PodSpec
This release resolves a bug when passing source_collection
as part of the PodSpec
. This option is used when creating a new index from vector data stored in a collection. The value of this field should be a collection you have created previously from an index and that shows with pc.list_collections()
. Currently collections and pod-based indexes are not portable across environments.
from pinecone import Pinecone
pc = Pinecone(api_key='YOUR_API_KEY')
pc.create_index(
name='my-index',
dimension=1536,
metric='cosine',
spec=PodSpec(
environment='us-east1-gcp',
source_collection='collection-2024jan16',
)
)
Pass optional GRPCClientConfig
when using PineconeGRPC
This could be considered as a fix for a UX bug or a micro-feature, depending on your perspective. In 3.0.2 we updated the pc.Index helper method that is used to build instances of the GRPCIndex
class. It now accepts an optional keyword param grpc_config
. Before this fix, you would need to import GRPCIndex
and instantiate GRPCIndex
yourself in order to pass this configuration and customize some settings, which was a bit clunky.
from pinecone.grpc import PineconeGRPC, GRPCClientConfig
pc = PineconeGRPC(api_key='YOUR_API_KEY')
grpc_config = GRPCClientConfig(
timeout=10,
secure=True,
reuse_channel=True
)
index = pc.Index(
name='my-index',
host='host',
grpc_config=grpc_config
)
# Now do data operations
index.upsert(...)
Pass optional pool_threads
config on the index.
Similar to the grpc_config
option, some people requested the ability to pass pool_threads
when targeting an index rather than in the initial client initialization. Now the optional configuration is accepted in both places, with the value passed to .Index()
taking precedence.
Now these are both valid approaches:
from pinecone import Pinecone
pc = Pinecone(api_key='key', pool_threads=5)
pc.Index(host='host')
pc.upsert(...)
from pinecone import Pinecone
pc = Pinecone(api_key='key')
index = pc.Index(host='host', pool_threads=5)
index.upsert(...)
Debugging
This is probably only relevant for internal Pinecone employees or support agents, but the index client now accepts configuration to attach additional headers to each data plane request. This can help with tracing requests in logs.
from pinecone import Pinecone
pc = Pinecone(api_key='xxx')
index = pc.Index(
host='hosturl',
additional_headers={ 'header-1': 'header-1-value' }
)
# Now do things
index.upsert(...)
The equivalent concept for PineconeGRPC
is to pass additional_metadata
. gRPC metadata fill a similar role as HTTP request headers, and should not be confused with metadata associated with vectors stored in your Pinecone indexes.
from pinecone.grpc import PineconeGRPC, GRPCClientConfig
pc = PineconeGRPC(api_key='YOUR_API_KEY')
grpc_config = GRPCClientConfig(additional_metadata={'extra-header': 'value123'})
index = pc.Index(
name='my-index',
host='host',
grpc_config=grpc_config
)
# do stuff
index.upsert(...)
Changelog
- README.md: Update install steps to escape brackets by @daverigby in #298
- Expose missing configurations for
grpc_config
andpool_threads
by @jhamon in #296 - Integration tests for collections by @jhamon in #299
- Optional configs to pass
additional_headers
/additional_metadata
to indexes by @jhamon in #297
New Contributors
- @daverigby made their first contribution in #298
Full Changelog: v3.0.1...v3.0.2