mirror of
https://github.com/qdrant/qdrant-client.git
synced 2026-08-01 15:40:54 -05:00
* base class for qdrant * WIP: implement local qdrant client * fix mypy * fix mypy * search tests * search tests * fix mypy * scroll test * filters: fixtures, tests, and fixes * fix types * fix types * fix types * fix: fix local CollectionInfo, add __test__ to avoid pytest complaints, fix typo * fix: fix typo in import * tests: add local upload tests (#139) * new: make local collection info more similar to remote one * new: add local upsert tests * tests: moved compare collections * scroll tests * recommendations test * tests: fix vector comparison in utils, add retrieve tests * fix: fix types * persistence test * fix: fix types * fix: fix db path creation * tests: add delete points tests, refactoring (#140) * skip local tests on old version * test aliases * test count * tests: add delete payload tests, move set and overwrite payload tests * tests: fix pytest warning * cover some more stuff with tests --------- Co-authored-by: George Panchuk <george.panchuk@qdrant.tech>
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
import random
|
|
|
|
from qdrant_client.http.models import PayloadSelectorExclude, PayloadSelectorInclude
|
|
from tests.congruence_tests.test_common import (
|
|
COLLECTION_NAME,
|
|
compare_client_results,
|
|
generate_fixtures,
|
|
)
|
|
|
|
|
|
def test_retrieve(local_client, remote_client) -> None:
|
|
num_vectors = 1000
|
|
fixture_records = generate_fixtures(num_vectors)
|
|
keys = list(fixture_records[0].payload.keys())
|
|
|
|
local_client.upload_records(COLLECTION_NAME, fixture_records)
|
|
remote_client.upload_records(COLLECTION_NAME, fixture_records)
|
|
|
|
id_ = random.randint(0, num_vectors)
|
|
|
|
compare_client_results(
|
|
local_client, remote_client, lambda c: c.retrieve(COLLECTION_NAME, [id_])
|
|
)
|
|
compare_client_results(
|
|
local_client,
|
|
remote_client,
|
|
lambda c: c.retrieve(COLLECTION_NAME, [id_], with_payload=False),
|
|
)
|
|
# with_vectors is not tested with `True` because `text` vectors are used with Cosine distance,
|
|
# and we do not normalize them in local version
|
|
|
|
compare_client_results(
|
|
local_client,
|
|
remote_client,
|
|
lambda c: c.retrieve(COLLECTION_NAME, [id_], with_vectors=["image", "code"]),
|
|
)
|
|
compare_client_results(
|
|
local_client,
|
|
remote_client,
|
|
lambda c: c.retrieve(
|
|
COLLECTION_NAME, [id_], with_vectors=["image", "code"], with_payload=False
|
|
),
|
|
)
|
|
|
|
sample_keys = random.sample(keys, 3)
|
|
compare_client_results(
|
|
local_client,
|
|
remote_client,
|
|
lambda c: c.retrieve(COLLECTION_NAME, [id_], with_payload=sample_keys),
|
|
)
|
|
compare_client_results(
|
|
local_client,
|
|
remote_client,
|
|
lambda c: c.retrieve(
|
|
COLLECTION_NAME,
|
|
[id_],
|
|
with_payload=PayloadSelectorInclude(include=sample_keys),
|
|
),
|
|
)
|
|
compare_client_results(
|
|
local_client,
|
|
remote_client,
|
|
lambda c: c.retrieve(
|
|
COLLECTION_NAME,
|
|
[id_],
|
|
with_payload=PayloadSelectorExclude(exclude=sample_keys),
|
|
),
|
|
)
|