Merge pull request #355 from tseaver/fix-354-connect_lancedb-w-relative-db_path

fix: pass absolute 'db_path' to 'lancedb.connect_async'
This commit is contained in:
Yiorgis Gozadinos 2026-04-25 09:26:08 +03:00 committed by GitHub
commit 7828a8b05d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View file

@ -70,7 +70,7 @@ async def connect_lancedb(
else:
if db_path is None:
raise ValueError("No lancedb.uri configured and no db_path provided")
return await lancedb.connect_async(db_path)
return await lancedb.connect_async(db_path.absolute())
class DocumentRecord(LanceModel):

View file

@ -1,7 +1,30 @@
import pathlib
from unittest import mock
import pytest
from haiku.rag.config import AppConfig
from haiku.rag.store import Store
from haiku.rag.store.engine import get_database_stats
from haiku.rag.store.engine import connect_lancedb, get_database_stats
@pytest.mark.asyncio
@pytest.mark.parametrize("w_relative", [False, True])
@mock.patch("lancedb.connect_async")
async def test_connect_lancedb(ldbca, w_relative):
config = AppConfig(environment="testing")
relative_db_path = pathlib.Path("path/to/lancedb")
absolute_db_path = relative_db_path.absolute()
if w_relative:
db_path = relative_db_path
else:
db_path = absolute_db_path
found = await connect_lancedb(config, db_path)
assert found is ldbca.return_value
ldbca.assert_awaited_once_with(absolute_db_path)
class TestGetDatabaseStats: