Skip to content

fix(retrieval): hydrate DeepLakeVectorStore fallback cache after reconnect - #1046

Merged
AmitoVrito merged 1 commit into
mainfrom
fix/deeplake-reconnect-fallback-1015
Sep 16, 2026
Merged

AmitoVrito merged 1 commit into
mainfrom
fix/deeplake-reconnect-fallback-1015

Conversation

@AmitoVrito

Copy link
Copy Markdown
Collaborator

Summary

  • If the native dataset.search(embedding_data=…, return_tensors=…) signature is unavailable (SDK version mismatch → caught AttributeError/TypeError), DeepLakeVectorStore falls back to an in-process cosine-similarity scan over _documents/_local_vectors.
  • Those caches are populated only by add() calls made in the current process. After a reconnect (a freshly-constructed instance attached to an already-populated dataset), they start empty — so the fallback silently returned [] for real, persisted data.
  • Added _hydrate_local_state(), called lazily right before the fallback scan: if the local cache is empty, it reads persisted rows back via len(dataset) + row-style indexing (dataset[i]["text"/"metadata"/"embedding"]), matching the row/column style the class's _add_columns already assumes (deeplake.types.Text()/Dict()/Embedding() via add_column). If the dataset doesn't support that access pattern, it's a no-op — no worse than before.

Note on confidence

The issue (and my own review of #1012 that filed it) flagged this as version-dependent — I don't have a real Deep Lake install/dataset to validate the exact row-access API against. The fix is written defensively (try/except around every access, silent no-op on any mismatch) so it can only improve the reconnect case and never regresses the existing native-search or fresh-dataset paths. Re-validating against a real Deep Lake dataset (testcontainer or local dataset path) once one is available in CI is still worth doing.

Test plan

  • Added test_deeplake_fallback_hydrates_from_dataset_after_reconnect using a hand-written fake dataset (no search method, __len__/__getitem__ only) simulating a reconnect — confirmed it fails on the pre-fix code (IndexError/empty results) and passes after the fix.
  • Existing test_deeplake_and_myscale_smoke (native search path) still passes.
  • ruff check, ruff format --check, mypy clean on touched files.

Closes #1015

…nnect

Fixes #1015. When the native dataset.search(...) signature is
unavailable, DeepLakeVectorStore falls back to an in-process cosine
scan over _documents/_local_vectors. Those caches are only populated
by add() calls made in the current process, so a freshly-constructed
instance attached to an already-populated dataset (a reconnect)
silently returned [] instead of the persisted data. The fallback now
hydrates the local cache from the dataset's persisted rows (when the
dataset supports len()/row-style indexing) before scanning.

Flagged in the issue as version-dependent -- worth re-validating
against a real Deep Lake dataset when one is available in CI.

Co-authored-by: Dhruv Garg <[email protected]>
@AmitoVrito
AmitoVrito merged commit 7011ec0 into main Sep 16, 2026
24 checks passed
@AmitoVrito
AmitoVrito deleted the fix/deeplake-reconnect-fallback-1015 branch September 16, 2026 15:17
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.

retrieval: DeepLakeVectorStore in-process fallback returns nothing after reconnect

1 participant