Skip to content

Import VectorSearchIndex from its canonical module#435

Merged
bbqiu merged 5 commits into
mainfrom
jennsun/fix-vector-search-index-import
Jun 9, 2026
Merged

Import VectorSearchIndex from its canonical module#435
bbqiu merged 5 commits into
mainfrom
jennsun/fix-vector-search-index-import

Conversation

@jennsun

@jennsun jennsun commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

context: https://databricks.slack.com/archives/C065NC65Q9F/p1780691337648119

Fix ImportError: cannot import name 'VectorSearchIndex' from 'databricks.vector_search.client' that breaks every consumer of databricks_openai.vector_search_retriever_tool (transitively: databricks_langchain, app-templates LangGraph template, etc.) once databricks-vectorsearch>=0.74 removes the client.py re-export.

Root cause

VectorSearchIndex has lived canonically in databricks.vector_search.index since databricks-vectorsearch==0.50 (verified against 0.50/0.55/0.68/0.73 wheels). It was importable from databricks.vector_search.client only as a side effect of client.py doing from databricks.vector_search.index import VectorSearchIndex near the top of its own module.

The new databricks-vectorsearch>=0.74 release (which now also pulls databricks-ai-search>=0.73 as a transitive dep) removed that side-effect import, so consumers that wrote from databricks.vector_search.client import VectorSearchIndex blow up — the bridge being one of them. (Aside: databricks-ai-search==0.73 exposes VectorSearchIndex as a back-compat alias for AISearchIndex via databricks.ai_search.index, but the rename doesn't matter for this fix — the canonical databricks.vector_search.index path keeps working on every released version of databricks-vectorsearch.)

Fix

Import VectorSearchIndex from its canonical location:

from databricks.vector_search.index import VectorSearchIndex

Applied in 5 files — 1 production module (integrations/openai/src/databricks_openai/vector_search_retriever_tool.py) and 4 test/test-util files that had the same broken import. Net diff: +6/−5.

Companion change in integrations/langchain/pyproject.toml: add databricks-openai = { path = "../openai", editable = true } to [tool.uv.sources] so the langchain test job uses the in-flight databricks-openai source (which has the fix) instead of the broken PyPI release, mirroring the existing databricks-ai-bridge source pin. This is a dev/CI-only directive — [tool.uv.sources] is stripped from published wheels, so end users still resolve databricks-openai from PyPI per the unchanged databricks-openai>=0.14.0 dep.

Reproduction (mimics the failure path the user hit on the LangGraph template)

python -m venv .venv && .venv/bin/pip install databricks-vectorsearch==0.74 databricks-openai

# Before this PR (legacy import path — user's traceback):
python -c "from databricks.vector_search.client import VectorSearchIndex"
# ImportError: cannot import name 'VectorSearchIndex' from 'databricks.vector_search.client'

# After this PR (the fixed module imports cleanly):
python -c "from databricks_openai.vector_search_retriever_tool import VectorSearchRetrieverTool"
# (no error)

For local reproduction without access to a 0.74 build, simulate the breakage on an older vectorsearch by importing the module and deleting the attribute: import databricks.vector_search.client as c; del c.VectorSearchIndex — same effect.

Validation

  • All 53 unit tests in integrations/openai/tests/unit_tests/test_vector_search_retriever_tool.py pass on the fixed source under simulated 0.74 breakage (del databricks.vector_search.client.VectorSearchIndex injected via conftest).
  • Static check: grep -rn "from databricks.vector_search.client import VectorSearchIndex" returns zero hits across the fixed codebase.
  • Canonical path verified against databricks-vectorsearch==0.50/0.55/0.68/0.73 wheels — all have databricks.vector_search.index.VectorSearchIndex defined as a class.

Release implications

Once merged, this needs a databricks-ai-bridge patch release so downstream consumers (app-templates LangGraph template, databricks-langchain, databricks-openai) pick up the fix from PyPI without a git pin.

The companion app-templates change at databricks/app-templates#235 temporarily pins the langgraph templates at this branch's git URL so customers aren't blocked while the release goes out; that pin should be removed once the bridge release ships.

CI status

3 non-Required cross-version matrix jobs fail (openai_test (3.10, v0.3.0 / v0.4.0 / v0.5.0)); all Required checks are green.

These 3 failures pre-exist on main. Verified via a no-op baseline PR (#436): an empty commit off upstream/main triggers CI and reproduces 14 failures, all 3 of which are also failing here — plus 11 more that this PR fixes. So PR #435 is a strict improvement over current main state.

The matrix runs frozen historical sources from old tags against current PyPI and is hit by two unrelated upstream API drifts:

  1. databricks-vectorsearch>=0.74 removed the VectorSearchIndex re-export from databricks.vector_search.client. Historical sources still import from that path. (Same bug this PR fixes for HEAD; the historical sources are frozen by tag and can't pick up the fix.)
  2. mlflow 2.x removed mlflow.get_last_active_trace() in favor of get_last_active_trace_id(). Historical test code still calls the old name; the matrix's existing mlflow<3 pin is too loose.

Both predate this PR and are surfaced only because main hadn't re-run CI since 2026-05-13. Being handed off to the integration-tests owner to triage separately (options: tighter per-entry mlflow: pin, install each historical tag's uv.lock for exact dep parity, or retire the cross-version matrix).

Test plan

  • CI: existing unit tests pass on this branch
  • Local: uv sync in app-templates/agent-langgraph with the companion override and start the agent server — no ImportError on agent boot
  • After merge + patch release: drop the app-templates override

cc @vadim-antonov (Databricks Vector Search) — heard you've been working on a related change on the VS side; please flag if there's something here that should be coordinated.

`databricks.vector_search.client` re-exported `VectorSearchIndex` only as
a side effect of doing `from databricks.vector_search.index import
VectorSearchIndex` at the top of `client.py`. A recent release of
`databricks-vectorsearch` (and/or the new `databricks-ai-search`
package) removes that line, breaking every consumer that did
`from databricks.vector_search.client import VectorSearchIndex`.

The canonical home of `VectorSearchIndex` has been `databricks.vector_
search.index` since at least 0.55. Import from there, with a try/except
preferring the new `databricks.ai_search.index` location so the bridge
keeps working regardless of which underlying package the user installs.

Reproduces user's traceback from the app-templates LangGraph template:
  ImportError: cannot import name 'VectorSearchIndex' from
  'databricks.vector_search.client'
jennsun added 4 commits June 8, 2026 12:06
- ruff format/check: add the blank line ruff format wants above the
  try/except import block; let ruff --fix re-sort the import sections
  so I001 is happy.
- integrations/langchain depends on databricks-openai (via
  databricks_langchain.utils), but its pyproject left databricks-openai
  to come from PyPI. With PyPI now shipping databricks-vectorsearch
  >=0.74 (which removed the VectorSearchIndex re-export from
  databricks.vector_search.client), the PyPI databricks-openai 0.15.0
  blows up at import time and the langchain test job can't even
  collect. Add `databricks-openai = { path = "../openai", editable
  = true }` to [tool.uv.sources] so CI uses the (fixed) source.

The openai_cross_version_test matrix (v0.3.0/v0.4.0/v0.5.0) checks out
historical tags whose openai integration has the same broken import
that this PR fixes for HEAD. Those tests can't be fixed by this PR
because the historical sources are frozen — they need either a pin on
databricks-vectorsearch<0.74 in the matrix, or to be dropped. Tracking
separately.
The openai_test (v0.3.0/v0.4.0/v0.5.0) jobs check out historical tags
of integrations/openai and run them against current PyPI. Those
historical sources import `VectorSearchIndex` from
`databricks.vector_search.client` (the bug this PR fixes for HEAD), and
`databricks-vectorsearch>=0.74` removed that re-export. The frozen
sources can't be fixed, so constrain the env to the version range they
were validated against.
The earlier try/except favoring `databricks.ai_search.index` was speculative
future-proofing for a possible package rename, but `databricks-ai-search==0.73`
itself exposes `VectorSearchIndex` only as a back-compat alias for
`AISearchIndex` (`databricks/ai_search/index.py:682`). Today and on every
released `databricks-vectorsearch` from 0.50 onward, `databricks.vector_search.
index.VectorSearchIndex` is the canonical class — so a one-line direct import
suffices and the cascade was just indirection.

Validated under simulated `databricks-vectorsearch>=0.74` breakage (legacy
`databricks.vector_search.client.VectorSearchIndex` attribute removed):
  - reproduces the user's `ImportError` for the legacy path
  - fixed `databricks_openai.vector_search_retriever_tool` imports cleanly
  - all 53 openai unit tests pass under the simulated breakage
@bbqiu bbqiu merged commit 4503aeb into main Jun 9, 2026
43 of 46 checks passed
@bbqiu bbqiu deleted the jennsun/fix-vector-search-index-import branch June 9, 2026 06:17
jennsun added a commit that referenced this pull request Jun 9, 2026
…ot `.client`)

The original docstrings said `databricks.vector_search.client.
VectorSearchIndex.similarity_search` — the same wrong-path
incidental-re-export bug that PR #435 fixed in the actual code. The
earlier bulk sed in this PR carried the bug forward into the new
package name, producing `databricks.ai_search.client.VectorSearchIndex`
which does not even resolve (the new `databricks.ai_search.client`
imports `AISearchIndex`, not `VectorSearchIndex`; only the alias on
`.index` exists).

Fix the docstrings to point at the real home of the class:

  databricks.ai_search.client.VectorSearchIndex  →  databricks.ai_search.index.VectorSearchIndex
jennsun added a commit that referenced this pull request Jun 9, 2026
## Summary

`databricks-vectorsearch` is deprecated and has been renamed to `databricks-ai-search`. Follow-up to #435.

When tests run, `databricks-vectorsearch` now emits:

> DeprecationWarning: databricks-vectorsearch is deprecated and has been renamed to databricks-ai-search. Imports under 'databricks.vector_search.*' will continue to work as a thin re-export of 'databricks.ai_search.*', but new code should switch to 'pip install databricks-ai-search' and 'from databricks.ai_search.* import ...'.

This PR follows that recommendation literally.

## Changes

- **`pyproject.toml` × 4** (root, `integrations/openai`, `integrations/langchain`, `integrations/llamaindex`): replace `databricks-vectorsearch>=*` with `databricks-ai-search>=0.73`.
- **12 Python files** under `src/`, `integrations/*/src/`, `integrations/*/tests/`, and `tests/`: every `from databricks.vector_search.* import ...` → `from databricks.ai_search.* import ...`. Includes `mock.patch` target strings and the `ImportError` fallback message in `databricks_langchain/vectorstores.py`.
- Symbol names are unchanged. `databricks-ai-search==0.73` exposes back-compat aliases for the names the bridge uses:
  - `databricks/ai_search/client.py:1090`: `VectorSearchClient = AISearchClient`
  - `databricks/ai_search/index.py:682`: `VectorSearchIndex = AISearchIndex`
  - `databricks/ai_search/exceptions.py:47`: `VectorSearchException = AISearchException`
  - `Reranker`, `DatabricksReranker`, `CredentialStrategy` exist under the same submodule paths.

Net diff: **+54 / −54 across 16 files** (pure rename).

## Validation

- **Package landscape**: in a fresh venv with the migrated branch installed editable, only `databricks-ai-search==0.73` is present — `databricks-vectorsearch` is no longer pulled at all.
- **Smoke**: `from databricks_openai.vector_search_retriever_tool import VectorSearchRetrieverTool` resolves `VectorSearchIndex` to `databricks.ai_search.index` even with the `databricks.vector_search` package completely absent.
- **Tests**:
  - 53/53 openai unit tests pass.
  - 258/258 langchain unit tests pass (4 pre-existing skips).
  - `ruff check` + `ruff format --check` clean.

## Companion notes

- This complements #435 (the `VectorSearchIndex` canonical-path fix). With both changes shipped, the bridge no longer touches the `databricks.vector_search.*` namespace at all and stops triggering the deprecation warning.
- The langchain pyproject's `databricks-openai = { path = "../openai", editable = true }` source pin (added in #435) is preserved — still needed until the next `databricks-openai` release containing the canonical-path fix ships to PyPI; can be removed in a follow-up cleanup after that release.
- Out of scope: the cross-version matrix (`openai_test (3.10, v0.x)` / `langchain_test (3.10, v0.x)`) still tests *historical* tags whose frozen source imports `databricks.vector_search.client.VectorSearchIndex`. Those tags cannot be retroactively migrated — this PR doesn't try to. Tracked separately for Dhruv.

## Test plan

- [ ] CI green on this branch
- [ ] After merge + release: any consumers of `databricks_ai_bridge`, `databricks_langchain`, `databricks_openai`, or `databricks_llamaindex` no longer see the upstream `DeprecationWarning` about `databricks-vectorsearch`
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