Skip to content

Commit

Permalink
chore: Test sparse recommend
Browse files Browse the repository at this point in the history
  • Loading branch information
hh-space-invader committed Mar 11, 2025
1 parent 22034e5 commit 3ec2fa7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
26 changes: 18 additions & 8 deletions tests/congruence_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@
)


@pytest.fixture
def local_client() -> QdrantClient:
client: QdrantClient = init_local()
initialize_fixture_collection(client)
@pytest.fixture(scope="session")
def storage() -> str:
return ":memory:"


@pytest.fixture(scope="session")
def prefer_grpc() -> bool:
return False


@pytest.fixture(scope="session")
def local_client(storage: str) -> QdrantClient:
client: QdrantClient = init_local(storage=storage)
# initialize_fixture_collection(client)
yield client
delete_fixture_collection(client)


@pytest.fixture
def remote_client() -> QdrantClient:
client: QdrantClient = init_remote()
initialize_fixture_collection(client)
@pytest.fixture(scope="session")
def remote_client(prefer_grpc: bool) -> QdrantClient:
client: QdrantClient = init_remote(prefer_grpc=prefer_grpc)
# initialize_fixture_collection(client)
yield client
delete_fixture_collection(client)
9 changes: 2 additions & 7 deletions tests/congruence_tests/test_sparse_recommend.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,13 @@ def recommend_batch(client: QdrantBase) -> list[list[models.ScoredPoint]]:
)


def test_simple_recommend() -> None:
def test_simple_recommend(local_client: QdrantBase, remote_client: QdrantBase) -> None:
fixture_points = generate_sparse_fixtures()

secondary_collection_points = generate_sparse_fixtures(100)

searcher = TestSimpleRecommendation()

local_client = init_local()
init_client(
local_client,
fixture_points,
Expand All @@ -225,7 +224,6 @@ def test_simple_recommend() -> None:
sparse_vectors_config=sparse_vectors_config,
)

remote_client = init_remote()
init_client(
remote_client,
fixture_points,
Expand Down Expand Up @@ -270,16 +268,13 @@ def test_simple_recommend() -> None:
raise e


def test_query_with_nan():
def test_query_with_nan(local_client: QdrantBase, remote_client: QdrantBase) -> None:
fixture_points = generate_sparse_fixtures()
sparse_vector_dict = random_sparse_vectors({"sparse-image": sparse_image_vector_size})
sparse_vector = sparse_vector_dict["sparse-image"]
sparse_vector.values[0] = np.nan
using = "sparse-image"

local_client = init_local()
remote_client = init_remote()

init_client(
local_client,
fixture_points,
Expand Down

0 comments on commit 3ec2fa7

Please sign in to comment.