Files
qdrant-client/tests/congruence_tests/test_scroll.py
George baa3e264c8 Drop python 3.8 (#848)
* new: drop python 3.8 support, update type hints

* fix: remove 3.8 from ci

* fix: update type hints

* fix: make netlify use python3.10

* fix: try python3.9 for sphinx

* debug: try updating sphinx

* new: bump ffastembed to 0.4.2

* fix: install numpy<2 for mypy

* fix: install numpy via poetry
2024-11-15 15:54:32 +01:00

103 lines
2.8 KiB
Python

import random
from qdrant_client.client_base import QdrantBase
from qdrant_client.http.models import models
from tests.congruence_tests.test_common import (
COLLECTION_NAME,
compare_client_results,
generate_fixtures,
generate_sparse_fixtures,
init_client,
init_local,
init_remote,
sparse_vectors_config,
)
class TestSimpleScroller:
@classmethod
def scroll_all(cls, client: QdrantBase) -> list[models.Record]:
all_records = []
records, next_page = client.scroll(
collection_name=COLLECTION_NAME,
limit=10,
with_payload=True,
)
all_records.extend(records)
while next_page:
records, next_page = client.scroll(
collection_name=COLLECTION_NAME,
limit=20,
offset=next_page,
with_payload=True,
)
all_records.extend(records)
return all_records
def test_simple_search() -> None:
fixture_points = generate_fixtures(200)
scroller = TestSimpleScroller()
local_client = init_local()
init_client(local_client, fixture_points)
remote_client = init_remote()
init_client(remote_client, fixture_points)
compare_client_results(local_client, remote_client, scroller.scroll_all)
def test_simple_sparse_scroll() -> None:
fixture_points = generate_sparse_fixtures(200)
local_client = init_local()
init_client(local_client, fixture_points, sparse_vectors_config=sparse_vectors_config)
remote_client = init_remote()
init_client(remote_client, fixture_points, sparse_vectors_config=sparse_vectors_config)
scroller = TestSimpleScroller()
compare_client_results(local_client, remote_client, scroller.scroll_all)
def test_mixed_ids() -> None:
fixture_points = generate_fixtures(100, random_ids=True) + generate_fixtures(
100, random_ids=False
)
random.shuffle(fixture_points)
scroller = TestSimpleScroller()
local_client = init_local()
init_client(local_client, fixture_points)
remote_client = init_remote()
init_client(remote_client, fixture_points)
compare_client_results(local_client, remote_client, scroller.scroll_all)
def test_sparse_mixed_ids() -> None:
fixture_points = generate_sparse_fixtures(100, random_ids=True) + generate_sparse_fixtures(
100, random_ids=False
)
random.shuffle(fixture_points)
scroller = TestSimpleScroller()
local_client = init_local()
init_client(local_client, fixture_points, sparse_vectors_config=sparse_vectors_config)
remote_client = init_remote()
init_client(remote_client, fixture_points, sparse_vectors_config=sparse_vectors_config)
compare_client_results(local_client, remote_client, scroller.scroll_all)