Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose missing configurations for grpc_config and pool_threads #296

Merged
merged 4 commits into from
Jan 23, 2024

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented Jan 22, 2024

Problem

This PR addresses a few configuration-related issues:

  • We moved pool_threads configuration up to the Pinecone client instance, but for backwards compatibility it would be nice to also allow it to be passed in the call to pc.Index(host='your-host', pool_threads=5)
  • We need to expose grpc_config as a keyword param when targeting indexes via the grpc-flavored client.

Solution

  • Pass through kwargs from .Index() to underlying Index class implementation
  • Add unit tests making sure pool_threads and grpc_config handled correctly.

Before (pool_threads)

from pinecone import Pinecone

pc = Pinecone(api_key='key', pool_threads=5)
pc.Index(host='host')
pc.upsert(...)

After (pool_threads, add backwards compatibility with old way)

You can use syntax as before, or alternatively can do this:

from pinecone import Pinecone

pc = Pinecone(api_key='key')
index = pc.Index(host='host', pool_threads=5)
index.upsert(...)

After (grpc, allow grpc_config to be passed)

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)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • None of the above: Add backwards compatibility on pool_threads config

Test Plan

New tests should be green in CI.

@jhamon jhamon requested a review from jseldess January 22, 2024 23:07
@jhamon jhamon changed the title pc.Index() accepts pool_threads config Expose missing configurations for grpc_config and pool_threads Jan 23, 2024
@jhamon jhamon marked this pull request as ready for review January 23, 2024 01:18
Copy link
Contributor

@tdonia tdonia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't run it locally but the code + tests make sense!

Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@jhamon jhamon merged commit 5eb002e into main Jan 23, 2024
64 checks passed
@jhamon jhamon deleted the jhamon/pool-threads-backcompat branch January 23, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants