Skip to content

[SDK][Python] Add Qdrant retrieval integration#5423

Draft
vincentkoc wants to merge 6 commits intomainfrom
vincentkoc-code/integration-qdrant
Draft

[SDK][Python] Add Qdrant retrieval integration#5423
vincentkoc wants to merge 6 commits intomainfrom
vincentkoc-code/integration-qdrant

Conversation

@vincentkoc
Copy link
Member

@vincentkoc vincentkoc commented Feb 26, 2026

Details

Adds first-pass Python retrieval integration wrapper for Qdrant.

This PR includes:

  • tracker function: track_qdrant
  • provider module export (__init__.py)
  • shared retrieval tracking helper used by provider wrappers
  • Qdrant integration documentation page
  • navigation update for the integration docs
  • provider-specific unit tests for wrapper behavior and metadata contract

Change checklist

  • User facing
  • Documentation update

Issues

  • Resolves #
  • OPIK-

Testing

  • cd sdks/python && PYTHONPATH=src pytest tests/unit/integrations/test_qdrant_tracker.py
  • Result: 2 passed

Documentation

  • Added docs/tracing/integrations/qdrant.mdx
  • Updated docs navigation in docs.yml

@github-actions github-actions bot added python Pull requests that update Python code Python SDK labels Feb 26, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

📋 PR Linter Failed

Invalid Title Format. Your PR title must include a ticket/issue number and may optionally include component tags ([FE], [BE], etc.).

  • Internal contributors: Open a JIRA ticket and link to it: [OPIK-xxxx] or [CUST-xxxx] or [DND-xxxx] or [DEV-xxxx] [COMPONENT] Your change
  • External contributors: Open a Github Issue and link to it via its number: [issue-xxxx] [COMPONENT] Your change
  • No ticket: Use [NA] [COMPONENT] Your change (Issues section not required)

Example: [issue-3108] [BE] [FE] Fix authentication bug or [OPIK-1234] Fix bug or [NA] Update README


Incomplete Issues Section. You must reference at least one GitHub issue (#xxxx), Jira ticket (OPIK-xxxx), CUST ticket (CUST-xxxx), DEV ticket (DEV-xxxx), or DND ticket (DND-xxxx) under the ## Issues section.

Comment on lines +11 to +15
@dataclass(frozen=True)
class RetrievalTrackingConfig:
provider: str
operation_paths: Tuple[str, ...]
project_name: Optional[str] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix in Cursor

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.

Comment on lines +12 to +32
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix in Cursor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

📋 PR Linter Failed

Invalid Title Format. Your PR title must include a ticket/issue number and may optionally include component tags ([FE], [BE], etc.).

  • Internal contributors: Open a JIRA ticket and link to it: [OPIK-xxxx] or [CUST-xxxx] or [DND-xxxx] or [DEV-xxxx] [COMPONENT] Your change
  • External contributors: Open a Github Issue and link to it via its number: [issue-xxxx] [COMPONENT] Your change
  • No ticket: Use [NA] [COMPONENT] Your change (Issues section not required)

Example: [issue-3108] [BE] [FE] Fix authentication bug or [OPIK-1234] Fix bug or [NA] Update README


Incomplete Issues Section. You must reference at least one GitHub issue (#xxxx), Jira ticket (OPIK-xxxx), CUST ticket (CUST-xxxx), DEV ticket (DEV-xxxx), or DND ticket (DND-xxxx) under the ## Issues section.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

📋 PR Linter Failed

Invalid Title Format. Your PR title must include a ticket/issue number and may optionally include component tags ([FE], [BE], etc.).

  • Internal contributors: Open a JIRA ticket and link to it: [OPIK-xxxx] or [CUST-xxxx] or [DND-xxxx] or [DEV-xxxx] [COMPONENT] Your change
  • External contributors: Open a Github Issue and link to it via its number: [issue-xxxx] [COMPONENT] Your change
  • No ticket: Use [NA] [COMPONENT] Your change (Issues section not required)

Example: [issue-3108] [BE] [FE] Fix authentication bug or [OPIK-1234] Fix bug or [NA] Update README


Incomplete Issues Section. You must reference at least one GitHub issue (#xxxx), Jira ticket (OPIK-xxxx), CUST ticket (CUST-xxxx), DEV ticket (DEV-xxxx), or DND ticket (DND-xxxx) under the ## Issues section.

@github-actions
Copy link
Contributor

Comment on lines +17 to +29
```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,
)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix in Cursor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Python SDK python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant