Skip to content

Commit

Permalink
Add configuration items about lance home
Browse files Browse the repository at this point in the history
  • Loading branch information
jieguangzhou committed Nov 10, 2023
1 parent b50935e commit dc73752
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions superduperdb/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
# TODO further simplify these configurations

import os
import re
import typing as t
from enum import Enum
Expand Down Expand Up @@ -143,6 +144,7 @@ def self_hosted_vector_search(self) -> bool:

#: The configuration for the vector search
vector_search: 'str' = 'in_memory' # "in_memory" / "lance"
lance_home: str = os.path.join('.superduperdb', 'vector_indices')

artifact_store: t.Optional[str] = None
metadata_store: t.Optional[str] = None
Expand Down
6 changes: 2 additions & 4 deletions superduperdb/vector_search/lance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy
import pyarrow as pa

from superduperdb import CFG
from superduperdb.vector_search.base import BaseVectorSearcher, VectorItem


Expand All @@ -27,10 +28,7 @@ def __init__(
index: t.Optional[t.List[str]] = None,
measure: t.Optional[str] = None,
):
lance_home = os.environ.get(
'SUPERDUPERDB_LANCE_HOME', '.superduperdb/vector_indices'
)
self.dataset_path = f'{lance_home}/{identifier}.lance'
self.dataset_path = os.path.join(CFG.lance_home, f'{identifier}.lance')
self.dimensions = dimensions
self._created = False
self.measure = measure
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/vector_search/test_vector_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import pytest

from superduperdb import CFG
from superduperdb.vector_search.base import VectorItem
from superduperdb.vector_search.in_memory import InMemoryVectorSearcher
from superduperdb.vector_search.lance import LanceVectorSearcher
Expand All @@ -12,7 +13,7 @@
@pytest.fixture
def index_data(monkeypatch):
with tempfile.TemporaryDirectory() as unique_dir:
monkeypatch.setenv('SUPERDUPERDB_LANCE_HOME', str(unique_dir))
monkeypatch.setattr(CFG, 'lance_home', str(unique_dir))
h = np.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]])
ids = [str(uuid.uuid4()) for _ in range(h.shape[0])]
yield h, ids
Expand Down

0 comments on commit dc73752

Please sign in to comment.