Repository navigation
fix(retrieval): hydrate DeepLakeVectorStore fallback cache after reconnect - #1046
Merged
Merged
Conversation
…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]>
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.
Summary
dataset.search(embedding_data=…, return_tensors=…)signature is unavailable (SDK version mismatch → caughtAttributeError/TypeError),DeepLakeVectorStorefalls back to an in-process cosine-similarity scan over_documents/_local_vectors.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._hydrate_local_state(), called lazily right before the fallback scan: if the local cache is empty, it reads persisted rows back vialen(dataset)+ row-style indexing (dataset[i]["text"/"metadata"/"embedding"]), matching the row/column style the class's_add_columnsalready assumes (deeplake.types.Text()/Dict()/Embedding()viaadd_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
test_deeplake_fallback_hydrates_from_dataset_after_reconnectusing a hand-written fake dataset (nosearchmethod,__len__/__getitem__only) simulating a reconnect — confirmed it fails on the pre-fix code (IndexError/empty results) and passes after the fix.test_deeplake_and_myscale_smoke(native search path) still passes.ruff check,ruff format --check,mypyclean on touched files.Closes #1015