Commit d864f65
authored
[Fix] openapi_config deprecation warning incorrectly shown (#327)
## 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
- [x] Bug fix (non-breaking change which fixes an issue)1 parent f229f45 commit d864f65
2 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
178 | | - | |
179 | 178 | | |
180 | 179 | | |
181 | 180 | | |
| |||
194 | 193 | | |
195 | 194 | | |
196 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
197 | 199 | | |
198 | 200 | | |
199 | 201 | | |
| |||
0 commit comments