Repository navigation
fix(weaviate): wrap fetch_object_by_id again, and keep the v4 list honest - #4714
Open
iruzen-dono wants to merge 1 commit into
Open
iruzen-dono wants to merge 1 commit into
iruzen-dono wants to merge 1 commit into
Conversation
…nest
`weaviate.collections.queries.fetch_object_by_id.query` stopped existing in a
later 4.x, so the entry stopped resolving and `_instrument` skipped it without
saying anything: `fetch_object_by_id` has produced no span on current
weaviate-client releases, while the package declares support for `>=3.26,<5`.
Measured on weaviate-client 4.24.1: 12 of the 16 entries in
`WRAPPED_METHODS_v4` resolve. The class now lives one module up, as
`weaviate.collections.queries.fetch_object_by_id`, which is the same class the
`.query` module re-exported on 4.4.0 (checked: identical object), so the path
change is behaviour-preserving on the 4.x releases that still have both.
The other three failures are `weaviate.gql.*.do`: they resolve on 4.4.0 and the
SDK removed them later in the same major. They stay wrapped for the releases
that still ship them, but they move to `WRAPPED_METHODS_v4_legacy` so that
`WRAPPED_METHODS_v4` means "this has to hold on the client we test against" --
which is what the new test asserts, one case per entry.
Test evidence, all against the real client:
- weaviate-client 4.24.1, without the path fix: 4 failed, among them
`_FetchObjectByIDQuery.fetch_object_by_id` ("has no fetch_object_by_id on
weaviate-client 4.24.1: no span will be emitted").
- weaviate-client 4.24.1, with the patch: 13 passed.
- weaviate-client 4.4.0, with the patch: 13 passed, so the older 4.x line is
untouched.
- Behaviourally, on 4.24.1: `_FetchObjectByIDQuery.__dict__["fetch_object_by_id"]`
is `NoneType` before `instrument()` and a `FunctionWrapper` after it, and a
plain function again after `uninstrument()`.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
On current
weaviate-clientreleases,fetch_object_by_idproduces no span, and nothing says so.WRAPPED_METHODS_v4pointsfetch_object_by_idatweaviate.collections.queries.fetch_object_by_id.query. That module existed in the first 4.x releases and was flattened later in the same major;_instrumentresolves each entry defensively (except ModuleNotFoundError: continue, thenhasattr), so the miss is a silent skip rather than an error. The package still declares_instruments = ("weaviate-client >= 3.26.0, <5").Measured
Against
weaviate-client4.24.1, 12 of the 16 entries inWRAPPED_METHODS_v4resolve. The four that do not:weaviate.collections.queries.fetch_object_by_id.queryweaviate.gql.filter.GraphQL.dodorenamed tobuildweaviate.gql.aggregate.AggregateBuilder.dodorenamed tobuildweaviate.gql.get.GetBuilder.doOn
weaviate-client4.4.0 all sixteen resolve, so the list was correct when it was written and drifted afterwards.The fix
fetch_object_by_idis the one of the four that is a wrong path rather than an API change: the class now lives atweaviate.collections.queries.fetch_object_by_id, which on 4.4.0 re-exports the identical class object from the.querymodule, so pointing the entry at the parent is behaviour-preserving for the releases that still have both and restores the span everywhere else.The three
weaviate.gql.*.doentries stay wrapped for the 4.x releases that still ship those methods, but they move intoWRAPPED_METHODS_v4_legacy. That leavesWRAPPED_METHODS_v4meaning this must resolve on the client the package runs on, which is a property a test can assert — the legacy list is the part that is allowed to disappear upstream.Test
One case per entry of
WRAPPED_METHODS_v4, importing the module and checking the method on the named holder. No server, no cassette.All four runs below are real, against the client each one names:
_FetchObjectByIDQuery.fetch_object_by_id: "has no fetch_object_by_id on weaviate-client 4.24.1: no span will be emitted"Behaviourally, also on 4.24.1:
_FetchObjectByIDQuery.__dict__["fetch_object_by_id"]isNoneTypebeforeinstrument(), aFunctionWrapperafter it, and a plain function again afteruninstrument().ruff check .passes; this repo's lint target does not runruff format, so nothing was reformatted.One thing this does not fix
tests/test_weaviate_instrumentation.pyhas never run in CI: thetestdependency group pinsweaviate-client>=3.26,<4, so the whole v4 module short-circuits onpytest.importorskip("weaviate.classes"). That is why this drift could sit unnoticed — the CI client has noweaviate.classesat all.The new test inherits that skip. Making it run means lifting the pin to
<5and giving thetest-packagesjob a weaviate instance, since the v4 fixtures callweaviate.connect_to_localand there are no cassettes for them. I did not do that here: it changes CI for every package in the repo, and this PR should be reviewable as a two-file fix. Say the word and I will open it as a follow-up.Summary by CodeRabbit