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

feat: Update pinecone client #756

Closed
wants to merge 1 commit into from
Closed

Conversation

mmurraysans
Copy link

Related Issues

Proposed Changes:

This PR requires pinecone_client > 3 and does away with the pinecone.init method in favor of the new class based methods. I aimed to minimize the changes to the codebase as much as possible.

How did you test it?

  • unit tests
  • integration tests

Notes for the reviewer

The new client introduced a PodSpec and a ServerlessPodSpec so I had to add some additional checks for the index_creation_kwargs argument that is worth a look to make sure this makes sense to everyone.

Checklist

@mmurraysans mmurraysans requested a review from a team as a code owner May 24, 2024 15:30
@mmurraysans mmurraysans requested review from shadeMe and removed request for a team May 24, 2024 15:30
@CLAassistant
Copy link

CLAassistant commented May 24, 2024

CLA assistant check
All committers have signed the CLA.

@shadeMe shadeMe requested review from anakin87 and removed request for shadeMe May 27, 2024 08:49
@anakin87 anakin87 self-assigned this May 28, 2024
Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

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

Hey, @mmurraysans. Thanks for the contribution!

I found some opportunities for improvement.

Also, the tests that require an API key are skipped in community branches.
Feel free to test the changes locally and ping me when you are done (I will do another check).

Comment on lines +27 to +28
# "pinecone-client<3", # our implementation is not compatible with pinecone-client>=3
"pinecone-client>3", # our implementation is not compatible with pinecone-client>=3
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# "pinecone-client<3", # our implementation is not compatible with pinecone-client>=3
"pinecone-client>3", # our implementation is not compatible with pinecone-client>=3
"pinecone-client>=3",

ban-relative-imports = "parents"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
Copy link
Member

Choose a reason for hiding this comment

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

could you discard the changes in this file?

Comment on lines 56 to +59
:param index_creation_kwargs: Additional keyword arguments to pass to the index creation method.
You can find the full list of supported arguments in the
[API reference](https://docs.pinecone.io/reference/create_index).
In addition the the documented arguments an indexType key specifies the type of index to create.
Copy link
Member

Choose a reason for hiding this comment

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

Consistently with the new API, I would:

  • remove environment
  • add a new parameter called spec: a dictionary with the same structure shown in the Pinecone API reference.

Two examples of spec:

{
  "pod": {
     "environment": "us-west-1-gcp",
     "pod_type": "p1.x1",
     "pods": 1
  }
}

{
  "serverless": {
      "region": "us-east-1",
      "cloud": "aws"
  }
}

Comment on lines +68 to +77
spec = index_creation_kwargs.pop("spec", None)
if spec:
index_spec = (
ServerlessSpec(**spec)
if index_creation_kwargs.pop("indexType", "").lower() == "serverless"
else PodSpec(**spec)
)
pc.create_index(name=index, dimension=dimension, spec=index_spec, **index_creation_kwargs)
else:
pc.create_index(name=index, dimension=dimension, **index_creation_kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

Let's change this part according to the comment above (introduction of the spec parameter).

Comment on lines +13 to +15
@pytest.fixture(autouse=True)
def patch_api_key(monkeypatch):
monkeypatch.setenv("PINECONE_API_KEY", "env-api-key")
Copy link
Member

Choose a reason for hiding this comment

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

I think this change should be discarded.
The API key is already set as a secret in this repository.

Comment on lines -29 to -34
assert document_store.environment == "gcp-starter"
assert document_store.index == "my_index"
assert document_store.namespace == "test"
assert document_store.batch_size == 50
assert document_store.dimension == 30
assert document_store.index_creation_kwargs == {"metric": "euclidean"}
Copy link
Member

Choose a reason for hiding this comment

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

please reintroduce the deleted assertions

@masci masci changed the title feat(pinecone): Update pinecone client feat: Update pinecone client May 28, 2024
@anakin87
Copy link
Member

anakin87 commented Jun 7, 2024

I'm closing this because inactive.
Superseded by #793.

@anakin87 anakin87 closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration:pinecone type:documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add source_tag attribute to PineconeDocumentStore Pinecone-python-client v3.0.0 breaks pinecone-haystack
3 participants