Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when creating LanceDB vectorstore with a table #30124

Open
5 tasks done
metadaddy opened this issue Mar 5, 2025 · 0 comments
Open
5 tasks done

AttributeError when creating LanceDB vectorstore with a table #30124

metadaddy opened this issue Mar 5, 2025 · 0 comments
Labels
Ɑ: vector store Related to vector store module

Comments

@metadaddy
Copy link
Contributor

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

I'm creating the LanceDB table and passing it to the LanceDB vectorstore constructor, like this:

import lancedb
from langchain_community.vectorstores import LanceDB

# Set this to point to an existing LanceDB vectorstore
uri = 's3://my-bucket/path/to/db'
connection = lancedb.connect(uri)
lance_table = connection.open_table('vectorstore')
vectorstore = LanceDB(
    embedding=OpenAIEmbeddings() # or whatever the correct class is for the vectorstore
    mode="append",
    connection=connection,
    table=lance_table,
)

Error Message and Stack Trace (if applicable)

  File "/Users/ppatterson/src/ai-rag-app-part-1/ai_rag_app/utils/vectorstore.py", line 57, in open_vectorstore_and_table
    vectorstore = LanceDB(
        embedding=OpenAIEmbeddings()
    ...<2 lines>...
        table=lance_table,
    )
  File "/Users/ppatterson/src/ai-rag-app-part-1/.venv/lib/python3.13/site-packages/langchain_community/vectorstores/lancedb.py", line 131, in __init__
    table, (lancedb.db.LanceTable, lancedb.remote.table.RemoteTable)
                                   ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'lancedb.remote' has no attribute 'table'

Description

  • I'm creating the LanceDB table in my code, so that I can query it before adding documents.
  • I expect to be able to create a connection and table, just as the LanceDB vectorstore does, and pass them to the vectorstore constructor
  • Instead, the vectorstore constructor raises an AttributeError, since it has imported lancedb, but this doesn't import lancedb.remote.table

The fix is to add another import after the existing one:

"""Initialize with Lance DB vectorstore"""
lancedb = guard_import("lancedb")  # existing import
lancedb.remote.table = guard_import("lancedb.remote.table")  # add this one

I can submit a PR.

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
Python Version: 3.13.1 (main, Feb 25 2025, 10:24:37) [Clang 16.0.0 (clang-1600.0.26.6)]

Package Information

langchain_core: 0.3.41
langchain: 0.3.20
langchain_community: 0.3.19
langsmith: 0.3.11
langchain_google_genai: 2.0.11
langchain_ollama: 0.2.3
langchain_openai: 0.3.7
langchain_text_splitters: 0.3.6

Optional packages not installed

langserve

Other Dependencies

aiohttp<4.0.0,>=3.8.3: Installed. No version info available.
async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
dataclasses-json<0.7,>=0.5.7: Installed. No version info available.
filetype: 1.2.0
google-ai-generativelanguage: 0.6.16
httpx: 0.28.1
httpx-sse<1.0.0,>=0.4.0: Installed. No version info available.
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-anthropic;: Installed. No version info available.
langchain-aws;: Installed. No version info available.
langchain-cohere;: Installed. No version info available.
langchain-community;: Installed. No version info available.
langchain-core<1.0.0,>=0.3.34: Installed. No version info available.
langchain-core<1.0.0,>=0.3.39: Installed. No version info available.
langchain-core<1.0.0,>=0.3.41: Installed. No version info available.
langchain-deepseek;: Installed. No version info available.
langchain-fireworks;: Installed. No version info available.
langchain-google-genai;: Installed. No version info available.
langchain-google-vertexai;: Installed. No version info available.
langchain-groq;: Installed. No version info available.
langchain-huggingface;: Installed. No version info available.
langchain-mistralai;: Installed. No version info available.
langchain-ollama;: Installed. No version info available.
langchain-openai;: Installed. No version info available.
langchain-text-splitters<1.0.0,>=0.3.6: Installed. No version info available.
langchain-together;: Installed. No version info available.
langchain-xai;: Installed. No version info available.
langchain<1.0.0,>=0.3.20: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
langsmith<0.4,>=0.1.17: Installed. No version info available.
numpy<3,>=1.26.2: Installed. No version info available.
ollama: 0.4.7
openai<2.0.0,>=1.58.1: Installed. No version info available.
orjson: 3.10.15
packaging: 24.2
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.10.6
pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available.
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pytest: Installed. No version info available.
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.3
requests-toolbelt: 1.0.0
requests<3,>=2: Installed. No version info available.
rich: Installed. No version info available.
SQLAlchemy<3,>=1.4: Installed. No version info available.
tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available.
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken<1,>=0.7: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.
zstandard: 0.23.0

@dosubot dosubot bot added the Ɑ: vector store Related to vector store module label Mar 5, 2025
ccurme added a commit that referenced this issue Mar 5, 2025
**Description:**

This PR adds a call to `guard_import()` to fix an AttributeError raised
when creating LanceDB vectorstore instance with an existing LanceDB
table.

**Issue:**

This PR fixes issue #30124.

**Dependencies:**

No additional dependencies.

**Twitter handle:**

[@metadaddy](https://x.com/metadaddy), but I spend more time at
[@metadaddy.net](https://bsky.app/profile/metadaddy.net) these days.

---------

Co-authored-by: Chester Curme <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: vector store Related to vector store module
Projects
None yet
Development

No branches or pull requests

1 participant