[SDK][Python] Add Qdrant retrieval integration#5423
Conversation
📋 PR Linter Failed❌ Invalid Title Format. Your PR title must include a ticket/issue number and may optionally include component tags (
Example: ❌ Incomplete Issues Section. You must reference at least one GitHub issue ( |
| @dataclass(frozen=True) | ||
| class RetrievalTrackingConfig: | ||
| provider: str | ||
| operation_paths: Tuple[str, ...] | ||
| project_name: Optional[str] = None |
There was a problem hiding this comment.
RetrievalTrackingConfig and the two public helpers in this module (patch_retrieval_client, as_tuple) currently have no docstrings, so callers can't learn what fields/arguments mean, what is returned, or what happens when no operations are patched; can we add concise docstrings (including the dataclass fields, the target mutation/opik_tracked side effect, and the tuple conversion) per the documentation guidance?
Finding type: Document behavior and context
- Apply fix with Baz
Other fix methods
Prompt for AI Agents:
In sdks/python/src/opik/integrations/_retrieval_tracker.py around lines 11 to 15, add
concise docstrings to the RetrievalTrackingConfig dataclass and to the two public helper
functions patch_retrieval_client and as_tuple. For RetrievalTrackingConfig, document
each field (provider, operation_paths, project_name) and what they represent. For
patch_retrieval_client, document the target parameter, the fact that the function may
mutate target by setting target.opik_tracked when any operations are patched, the return
value (the original or mutated target), and behavior when no operations are found. For
as_tuple, document that it converts an iterable of paths to an immutable tuple of
strings. Keep each docstring short (one to three sentences) and follow existing
project's docstring style.
| def track_qdrant(qdrant_client: Any, project_name: Optional[str] = None) -> Any: | ||
| """Adds Opik tracking wrappers to a Qdrant client. | ||
|
|
||
| The integration is dependency-light and patches known retrieval methods if present. | ||
| """ | ||
| config = RetrievalTrackingConfig( | ||
| provider="qdrant", | ||
| operation_paths=as_tuple( | ||
| [ | ||
| "query", | ||
| "query_points", | ||
| "search", | ||
| "search_batch", | ||
| "recommend", | ||
| "discover", | ||
| "scroll", | ||
| ] | ||
| ), | ||
| project_name=project_name, | ||
| ) | ||
| return patch_retrieval_client(qdrant_client, config) |
There was a problem hiding this comment.
New track_qdrant patching logic adds retrieval tracking per sdks/python/AGENTS.md, but no unit test under tests/unit/ exercises it (no existing coverage for _retrieval_tracker or Qdrant patching paths); can we add a test that verifies the expected methods are wrapped/tagged or document why it's intentionally skipped? (Guideline: sdks/python/AGENTS.md)
Finding type: AI Coding Guidelines
- Apply fix with Baz
Other fix methods
Prompt for AI Agents:
In sdks/python/src/opik/integrations/qdrant/opik_tracker.py around lines 12-32, the new
track_qdrant function adds retrieval-patching logic but has no unit test coverage. Add a
new unit test file tests/unit/test_qdrant_tracker.py that constructs a minimal fake
Qdrant client object with callable attributes named: query, query_points, search,
search_batch, recommend, discover, and scroll; call track_qdrant(fake_client) and then
assert each of those attributes is still callable but has been replaced/wrapped (for
example, by having the fake methods set a flag or increment a counter when invoked and
the wrapper should still call the original and allow inspection). Make the test verify
at least that (1) each method exists and is callable after wrapping, (2) invoking a
wrapped method calls through to the original fake implementation, and (3) the
RetrievalTrackingConfig.provider equals 'qdrant' via any accessible side-effect or by
patching/inspecting the patch_retrieval_client call. If adding a test is not feasible,
add a short explanatory note in tests/unit/README.md describing why Qdrant patching is
intentionally untested and referencing sdks/python/AGENTS.md.
There was a problem hiding this comment.
Commit 9b00b9c addressed this comment by adding a new unit test file sdks/python/tests/unit/integrations/test_qdrant_tracker.py that exercises the Qdrant retrieval patching path via track_qdrant(), spies on opik.integrations._retrieval_tracker.opik.track, asserts retrieval metadata (e.g., opik.provider == "qdrant" and operations like qdrant.search/qdrant.query_points), and verifies patching idempotency (not re-applied).
📋 PR Linter Failed❌ Invalid Title Format. Your PR title must include a ticket/issue number and may optionally include component tags (
Example: ❌ Incomplete Issues Section. You must reference at least one GitHub issue ( |
1 similar comment
📋 PR Linter Failed❌ Invalid Title Format. Your PR title must include a ticket/issue number and may optionally include component tags (
Example: ❌ Incomplete Issues Section. You must reference at least one GitHub issue ( |
| ```python | ||
| from qdrant_client import QdrantClient | ||
| from opik.integrations.qdrant import track_qdrant | ||
|
|
||
| client = QdrantClient(url="http://localhost:6333") | ||
| client = track_qdrant(client, project_name="retrieval-demo") | ||
|
|
||
| result = client.search( | ||
| collection_name="docs", | ||
| query_vector=[0.1, 0.2, 0.3], | ||
| limit=5, | ||
| ) | ||
| ``` |
There was a problem hiding this comment.
The new Qdrant example is a hand‑pasted snippet without the required one‑line intent/trigger note, required-vs-optional field guidance, or maintenance note pointing to whichever autogenerated canonical example this complements; can we either link to the generated example or add those required doc attributes (intent, applicability, optional/required fields, and pointer to the canonical source and update cadence) when embedding it?
Finding type: Keep docs accurate
Want Baz to fix this for you? Activate Fixer
Other fix methods
Prompt for AI Agents:
In apps/opik-documentation/documentation/fern/docs/tracing/integrations/qdrant.mdx
around lines 17-29, the embedded Python usage snippet (the example/usage block) is
missing the required documentation attributes: a one-line intent/trigger note, guidance
which fields are required vs optional, and a maintenance note linking to the canonical
autogenerated example plus its update cadence. Edit the chunk immediately before or
above the code block to add (1) a single-sentence intent/trigger describing when to use
this snippet, (2) a short bullet or parenthetical that lists which parameters are
required vs optional in the example (e.g., required: client and collection_name;
optional: query_vector, limit), and (3) a maintenance note with a pointer (URL or repo
path) to the autogenerated canonical example and a recommended update cadence. Keep the
changes concise and place them so they are clearly associated with the usage example.
Details
Adds first-pass Python retrieval integration wrapper for Qdrant.
This PR includes:
track_qdrant__init__.py)Change checklist
Issues
Testing
cd sdks/python && PYTHONPATH=src pytest tests/unit/integrations/test_qdrant_tracker.py2 passedDocumentation
docs/tracing/integrations/qdrant.mdxdocs.yml