From 21fbb2137289751c50d4b5dc04796c5ca8079d35 Mon Sep 17 00:00:00 2001 From: TERBOUCHE Hacene Date: Sun, 13 Aug 2023 20:42:34 +0200 Subject: [PATCH] fix(qdrant): fix non-class type fields Signed-off-by: TERBOUCHE Hacene --- docarray/index/backends/qdrant.py | 2 +- tests/index/qdrant/test_configurations.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docarray/index/backends/qdrant.py b/docarray/index/backends/qdrant.py index aa0d49095e2..6f1330f9eab 100644 --- a/docarray/index/backends/qdrant.py +++ b/docarray/index/backends/qdrant.py @@ -269,7 +269,7 @@ def python_type_to_db_type(self, python_type: Type) -> Any: :param python_type: a python type. :return: the corresponding database column type. """ - if any(issubclass(python_type, vt) for vt in QDRANT_PY_VECTOR_TYPES): + if any(safe_issubclass(python_type, vt) for vt in QDRANT_PY_VECTOR_TYPES): return 'vector' if safe_issubclass(python_type, docarray.typing.id.ID): diff --git a/tests/index/qdrant/test_configurations.py b/tests/index/qdrant/test_configurations.py index d17ebbbdebf..93aed2dfe00 100644 --- a/tests/index/qdrant/test_configurations.py +++ b/tests/index/qdrant/test_configurations.py @@ -1,3 +1,5 @@ +from typing import List + import numpy as np import pytest from pydantic import Field @@ -7,7 +9,6 @@ from docarray.typing import NdArray from tests.index.qdrant.fixtures import start_storage, tmp_collection_name # noqa: F401 - pytestmark = [pytest.mark.slow, pytest.mark.index] @@ -44,3 +45,12 @@ class Schema(BaseDoc): index3 = QdrantDocumentIndex[Schema](collection_name='my_index') assert index3.index_name == 'my_index' + + +def test_index_with_non_class_type(): + class Schema(BaseDoc): + tens: NdArray = Field(dim=10) + list_field: List + + index = QdrantDocumentIndex[Schema]() + assert index.num_docs() == 0