Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(qdrant): fix non-class type fields
Signed-off-by: TERBOUCHE Hacene <hacene.terbouche@gmail.com>
  • Loading branch information
TerboucheHacene committed Aug 13, 2023
commit 21fbb2137289751c50d4b5dc04796c5ca8079d35
2 changes: 1 addition & 1 deletion docarray/index/backends/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 11 additions & 1 deletion tests/index/qdrant/test_configurations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List

import numpy as np
import pytest
from pydantic import Field
Expand All @@ -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]


Expand Down Expand Up @@ -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