Files
qdrant-client/tests/embed_tests/test_schema_parser.py
George edde944bb3 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
2025-01-16 13:38:04 +01:00

54 lines
1.4 KiB
Python

import pytest
from qdrant_client import models
from qdrant_client.embed.schema_parser import ModelSchemaParser
from qdrant_client.embed.utils import FieldPath
def check_path_recursive(plain_path_parts: list[str], paths: list[FieldPath]) -> bool:
if not plain_path_parts:
return True
for path in paths:
if path.current == plain_path_parts[0]:
return check_path_recursive(plain_path_parts[1:], path.tail)
return False
@pytest.mark.parametrize(
"model",
[
models.Batch,
models.ContextPair,
models.ContextQuery,
models.DiscoverInput,
models.DiscoverQuery,
models.NearestQuery,
models.PointStruct,
models.PointVectors,
models.PointsBatch,
models.PointsList,
models.RecommendInput,
models.RecommendQuery,
models.UpdateVectors,
models.UpdateVectorsOperation,
models.UpsertOperation,
models.Prefetch,
models.QueryGroupsRequest,
models.QueryRequest,
models.QueryRequestBatch,
models.UpdateOperations,
],
)
def test_parser(model):
parser = ModelSchemaParser()
parser.parse_model(model)
for model_name, plain_paths in parser._cache.items():
count = 0
paths = parser.path_cache[model_name]
for plain_path in plain_paths:
count += check_path_recursive(plain_path.split("."), paths)
assert count == len(plain_paths)