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

[Fix] openapi_config deprecation warning incorrectly shown #327

Merged
merged 1 commit into from Mar 29, 2024

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented Mar 29, 2024

Problem

A deprecation warning about openapi_config was appearing even when users were not passing in that keyword parameter.

Solution

One of the things that makes the openapi_config object (instance of OpenApiConfiguration, a generated class) difficult to work with is that it carries a large amount of state; some of the fields inside of it are essentially constant (e.g. API key header) and others need to be adjusted based on which index you are trying to upsert/query/etc from. But you can't simply update those host values because multiple Index client objects could be sharing the same object reference. Consequently, a copy() method was added to make a deepcopy of this object before modifying any configuration properties when targeting an index.

For similar reasons, the same copy() method was being invoked when users passed in an openapi_config object as a kwarg to Pinecone(openapi_config=config, api_key='key'). This object was traditionally used as a vehicle for proxy configuration but needed to be merged with other configuration information, and the copy method ensures those changes are isolated from any other references to the object passed by the user.

Anyway, the deprecation notice was erroneously added inside the copy method even though it has these two very different use cases and only one of those use cases make sense for the warning notice to appear. To fix the issue, we simply migration the warning notice into the constructor method of the Pinecone class. This __init__() method is only invoked when creating the client, there's no concern about code reuse causing the notice to appear at other times.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

@jhamon jhamon requested a review from ssmith-pc March 29, 2024 22:28
@jhamon jhamon marked this pull request as ready for review March 29, 2024 22:29
@ssmith-pc
Copy link
Contributor

makes sense to me, looks good

@jhamon jhamon merged commit d864f65 into main Mar 29, 2024
125 checks passed
@jhamon jhamon deleted the jhamon/fix-warning-message branch March 29, 2024 22:40
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

2 participants