Skip to content

[Fix] openapi_config deprecation warning incorrectly shown - #327

Merged
jhamon merged 1 commit into
mainfrom
jhamon/fix-warning-message
Mar 29, 2024
Merged

jhamon merged 1 commit into
mainfrom
jhamon/fix-warning-message

Conversation

@jhamon

@jhamon jhamon commented Mar 29, 2024 •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor

makes sense to me, looks good

@jhamon
jhamon merged commit d864f65 into main Mar 29, 2024
@jhamon
jhamon deleted the jhamon/fix-warning-message branch March 29, 2024 22:40
mcpaddy added a commit to mcpaddy/pinecone-python-client that referenced this pull request May 22, 2024
* 'main' of github.com:pinecone-io/pinecone-python-client:
  [skip ci] Bump version to v4.1.0
  Bump tqdm from 4.66.1 to 4.66.3 (pinecone-io#344)
  Bump idna from 3.4 to 3.7 (pinecone-io#345)
  Bump jinja2 from 3.1.3 to 3.1.4 (pinecone-io#343)
  Add better error messages for mistaken `from_texts` and `from_documents` (pinecone-io#342)
  Support proxy_url and ssl_ca_certs options for gRPC (pinecone-io#341)
  Remove serverless public preview warnings (pinecone-io#340)
  [skip ci] Bump version to v4.0.0
  Improve upsert throughput by 3x (pinecone-io#334)
  Remove `merge` workflow and update `build-and-publish-docs` workflow to be manually runnable (pinecone-io#335)
  [skip ci] Bump version to v3.2.2
  [Fix] openapi_config deprecation warning incorrectly shown (pinecone-io#327)
  Add grpc unit test run, expand testing of VectorFactory (pinecone-io#326)
  [skip ci] Bump version to v3.2.1
  Allow clients to tag requests with a source_tag (pinecone-io#324)
  [skip ci] Bump version to v3.2.0
  Revise proxy configuration, add integration testing (pinecone-io#325)
  [Fix] Configuring SSL proxy via openapi_config object (pinecone-io#321)
  Update README.md (pinecone-io#323)
jhamon added a commit that referenced this pull request Sep 3, 2026
…trings (#545)

* docs(documents): fix misleading and broken examples in Documents docstrings

The rendered reference docs for the documents data-plane methods carried
several examples that read as doing something other than what they do.

- fetch: the by-filter pagination example was a loop that discarded every
  page. It never read response.documents on the first response, and each
  iteration overwrote `response` without touching the documents it had
  just fetched, so copying it cost N requests and yielded nothing.
  Rewritten as a do-while that reads each page before advancing the token.

- update: the two mutually exclusive call shapes (per-ID patch vs.
  by-filter patch) were shown as two bare calls in one block, reading as
  two sequential steps rather than alternatives. `title` and the reserved
  `_remove_fields` key sat in parallel positions, so `_remove_fields`
  looked like a field being set rather than a directive naming fields to
  delete. The per-ID patch was also shape-identical to an upsert payload,
  never showing that unnamed fields survive. The by-filter example
  filtered on `category` and then set `category`, raising a re-entrancy
  question the async, point-in-time `matched_records` contract does not
  answer.

- delete: split into labeled blocks, with `delete_all=True` called out on
  its own rather than sitting flush against two ordinary deletes.

- search: use the primary `doc.id` / `doc.score` properties instead of the
  `_id` / `_score` aliases, matching Document's own docstring and the
  `list` example. Return `content` rather than `category`, whose value the
  filter in the same call had already pinned to "tech".

- Every method example referenced an `idx` that no snippet defined; the
  class-level example bound `index`. It now binds `idx`.

- Every example used the index name as the namespace. Document operations
  have no default namespace, so this was the spot most likely to suggest
  the namespace tracks the index name. Examples now use a namespace
  distinct from the index name.

Applied identically to the sync and async twins. Docstrings only; no
behavior change. Verified with a clean Sphinx build, and by executing
every documented call shape through the request-body builders.

* docs(documents): correct include_fields semantics for search and fetch

The search docstring claimed "None (default) returns all fields; [] returns
only _id and score". Both halves were wrong: omitting include_fields returns
only _id/_score, identically to [], and the way to ask for every field is
["*"].

Confirmed against pinecone-db @ 56762d5c7b, where the split is deliberate and
property-tested (query-router EmptySemantics; field_selector_tests, including
check_empty_request_diverges — "search drops everything, fetch keeps
everything"). Both handlers do include_fields.unwrap_or_default(), so omitted
and [] are indistinguishable server-side; the wildcard is checked before any
per-name lookup, so ["*"] wins even alongside other names.

Fetch's docstring was correct but incomplete: [] and ["*"] also return every
field there. Both docstrings now name the asymmetry explicitly, since that is
what makes it a trap.

Adds an integration test on both the sync and async suites pinning all six
cases against a live data plane, and records the two minicone gaps
(pinecone-io/minicone#325, #327) that make it fail against the simulator.

Docstrings and tests only; no behavior change.

Closes #544
NishchayMahor pushed a commit to NishchayMahor/python-sdk-1 that referenced this pull request Sep 22, 2026
…r the 5s ceiling (pinecone-io#327) (pinecone-io#341)

* test(tooling): measured scoped timeout markers for the unit tests near the 5s ceiling (pinecone-io#327)

pinecone-io#306 made `timeout = 5` load-bearing for unit tests and handed back eight that
run within 1.7-2.5x of it. Its risk assessment was that they are wall-clock-bound
rather than CPU-bound, so unlike the grpc dataframe property test they should not
amplify on a slower runner. Measuring wall vs CPU per test confirms it: all eight
spend 0.1-0.5% of their runtime on CPU, and both costs are fixed constants in the
test doubles (a `threading.Event.wait(timeout=2)`, and a Retry-After of 2.0s that
the smear can stretch 1.5x).

Scoped markers sized against those measurements, at pinecone-io#306's ~7x ratio: 15s on the
three classes in test_grpc_dataframe_total_timeout.py that let the deadline fire
(2.01s each), and 20s on the sync and async Retry-After smear tests (2.96s). The
global 5s unit default is untouched.

Sweeping the whole suite for anything else above 1.5s found one test the ticket
did not know about, and it is the CPU-bound one: test_gaps_mode_end_to_end runs
1.65s at 94% CPU across two api_coverage.py subprocesses, i.e. the exact profile
that blew the 5s limit before. It gets 30s.

CI now runs pytest tests/unit with --durations, so a claimed margin can be
checked against real runner hardware without a throwaway commit.

Closes pinecone-io#327

* test(grpc): mark the two dataframe property tests the CI durations exposed (pinecone-io#327)

The --durations this PR added to CI paid for itself on its own first run. The
eight wall-clock-bound tests came in at 1.00x local->CI on all five Python
versions, exactly as pinecone-io#306 predicted. But the CPU-bound reference amplified
3.7-4.9x, reaching 6.22s on py3.10 — so pinecone-io#306's 60s marker on
test_batches_form_a_valid_partition is holding back a red on four of five
versions right now, not guarding a hypothetical.

Its two unmarked siblings in the same class share that profile and amplify ~3x
(0.70s/0.73s local -> 1.82-1.86s/1.69-2.19s CI), leaving 2.3x under the 5s
default on a cost that demonstrably clears 5s for the third member. 30s each,
sized against the CI maximum rather than the local reading.

Refs pinecone-io#327
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.

2 participants