| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 64bbf14 commit fea121b
15 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ | |||
| 23 | 23 | from docarray.display.document_array_summary import DocArraySummary | |
| 24 | 24 | from docarray.exceptions.exceptions import UnusableObjectError | |
| 25 | 25 | from docarray.typing.abstract_type import AbstractType | |
| 26 | - from docarray.utils._internal._typing import change_cls_name | ||
| 26 | + from docarray.utils._internal._typing import change_cls_name, safe_issubclass | ||
| 27 | 27 | ||
| 28 | 28 | if TYPE_CHECKING: | |
| 29 | 29 | from docarray.proto import DocListProto, NodeProto | |
@@ -53,7 +53,7 @@ def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]): | |||
| 53 | 53 | if not isinstance(item, type): | |
| 54 | 54 | return Generic.__class_getitem__.__func__(cls, item) # type: ignore | |
| 55 | 55 | # this do nothing that checking that item is valid type var or str | |
| 56 | - if not issubclass(item, BaseDoc): | ||
| 56 | + if not safe_issubclass(item, BaseDoc): | ||
| 57 | 57 | raise ValueError( | |
| 58 | 58 | f'{cls.__name__}[item] item should be a Document not a {item} ' | |
| 59 | 59 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | from docarray.array.list_advance_indexing import IndexIterType, ListAdvancedIndexing | |
| 25 | 25 | from docarray.base_doc import AnyDoc, BaseDoc | |
| 26 | 26 | from docarray.typing import NdArray | |
| 27 | + from docarray.utils._internal._typing import safe_issubclass | ||
| 27 | 28 | ||
| 28 | 29 | if TYPE_CHECKING: | |
| 29 | 30 | from pydantic import BaseConfig | |
@@ -158,7 +159,9 @@ def _validate_docs(self, docs: Iterable[T_doc]) -> Iterable[T_doc]: | |||
| 158 | 159 | ||
| 159 | 160 | def _validate_one_doc(self, doc: T_doc) -> T_doc: | |
| 160 | 161 | """Validate if a Document is compatible with this `DocList`""" | |
| 161 | - if not issubclass(self.doc_type, AnyDoc) and not isinstance(doc, self.doc_type): | ||
| 162 | + if not safe_issubclass(self.doc_type, AnyDoc) and not isinstance( | ||
| 163 | + doc, self.doc_type | ||
| 164 | + ): | ||
| 162 | 165 | raise ValueError(f'{doc} is not a {self.doc_type}') | |
| 163 | 166 | return doc | |
| 164 | 167 | ||
@@ -218,7 +221,7 @@ def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]): | |||
| 218 | 221 | not is_union_type(field_type) | |
| 219 | 222 | and self.__class__.doc_type.__fields__[field].required | |
| 220 | 223 | and isinstance(field_type, type) | |
| 221 | - and issubclass(field_type, BaseDoc) | ||
| 224 | + and safe_issubclass(field_type, BaseDoc) | ||
| 222 | 225 | ): | |
| 223 | 226 | # calling __class_getitem__ ourselves is a hack otherwise mypy complain | |
| 224 | 227 | # most likely a bug in mypy though | |
@@ -272,7 +275,7 @@ def validate( | |||
| 272 | 275 | return value | |
| 273 | 276 | elif isinstance(value, DocVec): | |
| 274 | 277 | if ( | |
| 275 | - issubclass(value.doc_type, cls.doc_type) | ||
| 278 | + safe_issubclass(value.doc_type, cls.doc_type) | ||
| 276 | 279 | or value.doc_type == cls.doc_type | |
| 277 | 280 | ): | |
| 278 | 281 | return cast(T, value.to_doc_list()) | |
@@ -326,7 +329,7 @@ def __getitem__(self, item): | |||
| 326 | 329 | @classmethod | |
| 327 | 330 | def __class_getitem__(cls, item: Union[Type[BaseDoc], TypeVar, str]): | |
| 328 | 331 | ||
| 329 | - if isinstance(item, type) and issubclass(item, BaseDoc): | ||
| 332 | + if isinstance(item, type) and safe_issubclass(item, BaseDoc): | ||
| 330 | 333 | return AnyDocArray.__class_getitem__.__func__(cls, item) # type: ignore | |
| 331 | 334 | else: | |
| 332 | 335 | return super().__class_getitem__(item) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | from docarray.base_doc.mixins.io import _type_to_protobuf | |
| 32 | 32 | from docarray.typing import NdArray | |
| 33 | 33 | from docarray.typing.tensor.abstract_tensor import AbstractTensor | |
| 34 | - from docarray.utils._internal._typing import is_tensor_union | ||
| 34 | + from docarray.utils._internal._typing import is_tensor_union, safe_issubclass | ||
| 35 | 35 | from docarray.utils._internal.misc import is_tf_available, is_torch_available | |
| 36 | 36 | ||
| 37 | 37 | if TYPE_CHECKING: | |
@@ -231,19 +231,19 @@ def _check_doc_field_not_none(field_name, doc): | |||
| 231 | 231 | field_type = tensor_type | |
| 232 | 232 | # all generic tensor types such as AnyTensor, ImageTensor, etc. are subclasses of AbstractTensor. | |
| 233 | 233 | # Perform check only if the field_type is not an alias and is a subclass of AbstractTensor | |
| 234 | - elif not isinstance(field_type, typingGenericAlias) and issubclass( | ||
| 234 | + elif not isinstance(field_type, typingGenericAlias) and safe_issubclass( | ||
| 235 | 235 | field_type, AbstractTensor | |
| 236 | 236 | ): | |
| 237 | 237 | # check if the tensor associated with the field_name in the document is a subclass of the tensor_type | |
| 238 | 238 | # e.g. if the field_type is AnyTensor but the type(docs[0][field_name]) is ImageTensor, | |
| 239 | 239 | # then we change the field_type to ImageTensor, since AnyTensor is a union of all the tensor types | |
| 240 | 240 | # and does not override any methods of specific tensor types | |
| 241 | 241 | tensor = getattr(docs[0], field_name) | |
| 242 | - if issubclass(tensor.__class__, tensor_type): | ||
| 242 | + if safe_issubclass(tensor.__class__, tensor_type): | ||
| 243 | 243 | field_type = tensor_type | |
| 244 | 244 | ||
| 245 | 245 | if isinstance(field_type, type): | |
| 246 | - if tf_available and issubclass(field_type, TensorFlowTensor): | ||
| 246 | + if tf_available and safe_issubclass(field_type, TensorFlowTensor): | ||
| 247 | 247 | # tf.Tensor does not allow item assignment, therefore the | |
| 248 | 248 | # optimized way | |
| 249 | 249 | # of initializing an empty array and assigning values to it | |
@@ -263,7 +263,7 @@ def _check_doc_field_not_none(field_name, doc): | |||
| 263 | 263 | stacked: tf.Tensor = tf.stack(tf_stack) | |
| 264 | 264 | tensor_columns[field_name] = TensorFlowTensor(stacked) | |
| 265 | 265 | ||
| 266 | - elif issubclass(field_type, AbstractTensor): | ||
| 266 | + elif safe_issubclass(field_type, AbstractTensor): | ||
| 267 | 267 | if first_doc_is_none: | |
| 268 | 268 | _verify_optional_field_of_docs(docs) | |
| 269 | 269 | tensor_columns[field_name] = None | |
@@ -291,7 +291,7 @@ def _check_doc_field_not_none(field_name, doc): | |||
| 291 | 291 | val = getattr(doc, field_name) | |
| 292 | 292 | cast(AbstractTensor, tensor_columns[field_name])[i] = val | |
| 293 | 293 | ||
| 294 | - elif issubclass(field_type, BaseDoc): | ||
| 294 | + elif safe_issubclass(field_type, BaseDoc): | ||
| 295 | 295 | if first_doc_is_none: | |
| 296 | 296 | _verify_optional_field_of_docs(docs) | |
| 297 | 297 | doc_columns[field_name] = None | |
@@ -307,7 +307,7 @@ def _check_doc_field_not_none(field_name, doc): | |||
| 307 | 307 | tensor_type=self.tensor_type | |
| 308 | 308 | ) | |
| 309 | 309 | ||
| 310 | - elif issubclass(field_type, AnyDocArray): | ||
| 310 | + elif safe_issubclass(field_type, AnyDocArray): | ||
| 311 | 311 | if first_doc_is_none: | |
| 312 | 312 | _verify_optional_field_of_docs(docs) | |
| 313 | 313 | docs_vec_columns[field_name] = None | |
@@ -362,7 +362,7 @@ def validate( | |||
| 362 | 362 | return value | |
| 363 | 363 | elif isinstance(value, DocList): | |
| 364 | 364 | if ( | |
| 365 | - issubclass(value.doc_type, cls.doc_type) | ||
| 365 | + safe_issubclass(value.doc_type, cls.doc_type) | ||
| 366 | 366 | or value.doc_type == cls.doc_type | |
| 367 | 367 | ): | |
| 368 | 368 | return cast(T, value.to_doc_vec()) | |
@@ -481,7 +481,7 @@ def _set_data_and_columns( | |||
| 481 | 481 | # set data and prepare columns | |
| 482 | 482 | processed_value: T | |
| 483 | 483 | if isinstance(value, DocList): | |
| 484 | - if not issubclass(value.doc_type, self.doc_type): | ||
| 484 | + if not safe_issubclass(value.doc_type, self.doc_type): | ||
| 485 | 485 | raise TypeError( | |
| 486 | 486 | f'{value} schema : {value.doc_type} is not compatible with ' | |
| 487 | 487 | f'this DocVec schema : {self.doc_type}' | |
@@ -491,7 +491,7 @@ def _set_data_and_columns( | |||
| 491 | 491 | ) # we need to copy data here | |
| 492 | 492 | ||
| 493 | 493 | elif isinstance(value, DocVec): | |
| 494 | - if not issubclass(value.doc_type, self.doc_type): | ||
| 494 | + if not safe_issubclass(value.doc_type, self.doc_type): | ||
| 495 | 495 | raise TypeError( | |
| 496 | 496 | f'{value} schema : {value.doc_type} is not compatible with ' | |
| 497 | 497 | f'this DocVec schema : {self.doc_type}' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ | |||
| 27 | 27 | from docarray.base_doc.mixins import IOMixin, UpdateMixin | |
| 28 | 28 | from docarray.typing import ID | |
| 29 | 29 | from docarray.typing.tensor.abstract_tensor import AbstractTensor | |
| 30 | + from docarray.utils._internal._typing import safe_issubclass | ||
| 30 | 31 | ||
| 31 | 32 | if TYPE_CHECKING: | |
| 32 | 33 | from pydantic import Protocol | |
@@ -351,7 +352,7 @@ def _exclude_docarray( | |||
| 351 | 352 | ||
| 352 | 353 | type_ = self._get_field_type(field) | |
| 353 | 354 | if isinstance(type_, type) and ( | |
| 354 | - issubclass(type_, DocList) or issubclass(type_, DocVec) | ||
| 355 | + safe_issubclass(type_, DocList) or safe_issubclass(type_, DocVec) | ||
| 355 | 356 | ): | |
| 356 | 357 | docarray_exclude_fields.append(field) | |
| 357 | 358 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | from typing import TYPE_CHECKING, Dict, List, Type, TypeVar | |
| 3 | 3 | ||
| 4 | 4 | from typing_inspect import get_origin | |
| 5 | + from docarray.utils._internal._typing import safe_issubclass | ||
| 5 | 6 | ||
| 6 | 7 | T = TypeVar('T', bound='UpdateMixin') | |
| 7 | 8 | ||
@@ -108,7 +109,9 @@ def _group_fields(doc: 'UpdateMixin') -> _FieldGroups: | |||
| 108 | 109 | if field_name not in FORBIDDEN_FIELDS_TO_UPDATE: | |
| 109 | 110 | field_type = doc._get_field_type(field_name) | |
| 110 | 111 | ||
| 111 | - if isinstance(field_type, type) and issubclass(field_type, DocList): | ||
| 112 | + if isinstance(field_type, type) and safe_issubclass( | ||
| 113 | + field_type, DocList | ||
| 114 | + ): | ||
| 112 | 115 | nested_docarray_fields.append(field_name) | |
| 113 | 116 | else: | |
| 114 | 117 | origin = get_origin(field_type) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | from docarray import BaseDoc, DocList, DocVec | |
| 6 | 6 | from docarray.typing import TorchTensor | |
| 7 | - from docarray.utils._internal._typing import change_cls_name | ||
| 7 | + from docarray.utils._internal._typing import change_cls_name, safe_issubclass | ||
| 8 | 8 | ||
| 9 | 9 | T_doc = TypeVar('T_doc', bound=BaseDoc) | |
| 10 | 10 | ||
@@ -141,7 +141,7 @@ def collate_fn(cls, batch: List[T_doc]): | |||
| 141 | 141 | ||
| 142 | 142 | @classmethod | |
| 143 | 143 | def __class_getitem__(cls, item: Type[BaseDoc]) -> Type['MultiModalDataset']: | |
| 144 | - if not issubclass(item, BaseDoc): | ||
| 144 | + if not safe_issubclass(item, BaseDoc): | ||
| 145 | 145 | raise ValueError( | |
| 146 | 146 | f'{cls.__name__}[item] item should be a Document not a {item} ' | |
| 147 | 147 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | from pydantic import create_model, create_model_from_typeddict | |
| 4 | 4 | from pydantic.config import BaseConfig | |
| 5 | 5 | from typing_extensions import TypedDict | |
| 6 | + from docarray.utils._internal._typing import safe_issubclass | ||
| 6 | 7 | ||
| 7 | 8 | from docarray import BaseDoc | |
| 8 | 9 | ||
@@ -38,8 +39,8 @@ def create_doc( | |||
| 38 | 39 | tensor=(AudioNdArray, ...), | |
| 39 | 40 | ) | |
| 40 | 41 | ||
| 41 | - assert issubclass(MyAudio, BaseDoc) | ||
| 42 | - assert issubclass(MyAudio, Audio) | ||
| 42 | + assert safe_issubclass(MyAudio, BaseDoc) | ||
| 43 | + assert safe_issubclass(MyAudio, Audio) | ||
| 43 | 44 | ``` | |
| 44 | 45 | ||
| 45 | 46 | :param __model_name: name of the created model | |
@@ -54,7 +55,7 @@ def create_doc( | |||
| 54 | 55 | :return: the new Document class | |
| 55 | 56 | """ | |
| 56 | 57 | ||
| 57 | - if not issubclass(__base__, BaseDoc): | ||
| 58 | + if not safe_issubclass(__base__, BaseDoc): | ||
| 58 | 59 | raise ValueError(f'{type(__base__)} is not a BaseDoc or its subclass') | |
| 59 | 60 | ||
| 60 | 61 | doc = create_model( | |
@@ -96,8 +97,8 @@ class MyAudio(TypedDict): | |||
| 96 | 97 | ||
| 97 | 98 | Doc = create_doc_from_typeddict(MyAudio, __base__=Audio) | |
| 98 | 99 | ||
| 99 | - assert issubclass(Doc, BaseDoc) | ||
| 100 | - assert issubclass(Doc, Audio) | ||
| 100 | + assert safe_issubclass(Doc, BaseDoc) | ||
| 101 | + assert safe_issubclass(Doc, Audio) | ||
| 101 | 102 | ``` | |
| 102 | 103 | ||
| 103 | 104 | --- | |
@@ -108,7 +109,7 @@ class MyAudio(TypedDict): | |||
| 108 | 109 | """ | |
| 109 | 110 | ||
| 110 | 111 | if '__base__' in kwargs: | |
| 111 | - if not issubclass(kwargs['__base__'], BaseDoc): | ||
| 112 | + if not safe_issubclass(kwargs['__base__'], BaseDoc): | ||
| 112 | 113 | raise ValueError(f'{kwargs["__base__"]} is not a BaseDoc or its subclass') | |
| 113 | 114 | else: | |
| 114 | 115 | kwargs['__base__'] = BaseDoc | |
@@ -136,7 +137,7 @@ def create_doc_from_dict(model_name: str, data_dict: Dict[str, Any]) -> Type['T_ | |||
| 136 | 137 | ||
| 137 | 138 | MyDoc = create_doc_from_dict(model_name='MyDoc', data_dict=data_dict) | |
| 138 | 139 | ||
| 139 | - assert issubclass(MyDoc, BaseDoc) | ||
| 140 | + assert safe_issubclass(MyDoc, BaseDoc) | ||
| 140 | 141 | ``` | |
| 141 | 142 | ||
| 142 | 143 | --- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -362,7 +362,9 @@ def __getitem__( | |||
| 362 | 362 | for field_name, type_, _ in self._flatten_schema( | |
| 363 | 363 | cast(Type[BaseDoc], self._schema) | |
| 364 | 364 | ): | |
| 365 | - if issubclass(type_, AnyDocArray) and isinstance(doc_sequence[0], Dict): | ||
| 365 | + if safe_issubclass(type_, AnyDocArray) and isinstance( | ||
| 366 | + doc_sequence[0], Dict | ||
| 367 | + ): | ||
| 366 | 368 | for doc in doc_sequence: | |
| 367 | 369 | self._get_subindex_doclist(doc, field_name) # type: ignore | |
| 368 | 370 | ||
@@ -534,7 +536,7 @@ def find_batched( | |||
| 534 | 536 | if search_field: | |
| 535 | 537 | if '__' in search_field: | |
| 536 | 538 | fields = search_field.split('__') | |
| 537 | - if issubclass(self._schema._get_field_type(fields[0]), AnyDocArray): # type: ignore | ||
| 539 | + if safe_issubclass(self._schema._get_field_type(fields[0]), AnyDocArray): # type: ignore | ||
| 538 | 540 | return self._subindices[fields[0]].find_batched( | |
| 539 | 541 | queries, | |
| 540 | 542 | search_field='__'.join(fields[1:]), | |
@@ -799,7 +801,7 @@ def __class_getitem__(cls, item: Type[TSchema]): | |||
| 799 | 801 | # do nothing | |
| 800 | 802 | # enables use in static contexts with type vars, e.g. as type annotation | |
| 801 | 803 | return Generic.__class_getitem__.__func__(cls, item) | |
| 802 | - if not issubclass(item, BaseDoc): | ||
| 804 | + if not safe_issubclass(item, BaseDoc): | ||
| 803 | 805 | raise ValueError( | |
| 804 | 806 | f'{cls.__name__}[item] `item` should be a Document not a {item} ' | |
| 805 | 807 | ) | |
@@ -849,7 +851,7 @@ def _flatten_schema( | |||
| 849 | 851 | # treat as if it was a single non-optional type | |
| 850 | 852 | for t_arg in union_args: | |
| 851 | 853 | if t_arg is not type(None): | |
| 852 | - if issubclass(t_arg, BaseDoc): | ||
| 854 | + if safe_issubclass(t_arg, BaseDoc): | ||
| 853 | 855 | names_types_fields.extend( | |
| 854 | 856 | cls._flatten_schema(t_arg, name_prefix=inner_prefix) | |
| 855 | 857 | ) | |
@@ -1044,15 +1046,15 @@ def _convert_dict_to_doc( | |||
| 1044 | 1046 | for field_name, _ in schema.__fields__.items(): | |
| 1045 | 1047 | t_ = schema._get_field_type(field_name) | |
| 1046 | 1048 | ||
| 1047 | - if not is_union_type(t_) and issubclass(t_, AnyDocArray): | ||
| 1049 | + if not is_union_type(t_) and safe_issubclass(t_, AnyDocArray): | ||
| 1048 | 1050 | self._get_subindex_doclist(doc_dict, field_name) | |
| 1049 | 1051 | ||
| 1050 | 1052 | if is_optional_type(t_): | |
| 1051 | 1053 | for t_arg in get_args(t_): | |
| 1052 | 1054 | if t_arg is not type(None): | |
| 1053 | 1055 | t_ = t_arg | |
| 1054 | 1056 | ||
| 1055 | - if not is_union_type(t_) and issubclass(t_, BaseDoc): | ||
| 1057 | + if not is_union_type(t_) and safe_issubclass(t_, BaseDoc): | ||
| 1056 | 1058 | inner_dict = {} | |
| 1057 | 1059 | ||
| 1058 | 1060 | fields = [ | |
@@ -1125,7 +1127,7 @@ def _find_subdocs( | |||
| 1125 | 1127 | ) -> FindResult: | |
| 1126 | 1128 | """Find documents in the subindex and return subindex docs and scores.""" | |
| 1127 | 1129 | fields = subindex.split('__') | |
| 1128 | - if not subindex or not issubclass( | ||
| 1130 | + if not subindex or not safe_issubclass( | ||
| 1129 | 1131 | self._schema._get_field_type(fields[0]), AnyDocArray # type: ignore | |
| 1130 | 1132 | ): | |
| 1131 | 1133 | raise ValueError(f'subindex {subindex} is not valid') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,7 +95,7 @@ def __init__(self, db_config=None, **kwargs): | |||
| 95 | 95 | self._logger.debug('Mappings have been updated with db_config.index_mappings') | |
| 96 | 96 | ||
| 97 | 97 | for col_name, col in self._column_infos.items(): | |
| 98 | - if issubclass(col.docarray_type, AnyDocArray): | ||
| 98 | + if safe_issubclass(col.docarray_type, AnyDocArray): | ||
| 99 | 99 | continue | |
| 100 | 100 | if col.db_type == 'dense_vector' and ( | |
| 101 | 101 | not col.n_dim and col.config['dims'] < 0 | |
@@ -336,7 +336,7 @@ def python_type_to_db_type(self, python_type: Type) -> Any: | |||
| 336 | 336 | self._logger.debug(f'Mapping Python type {python_type} to database type') | |
| 337 | 337 | ||
| 338 | 338 | for allowed_type in ELASTIC_PY_VEC_TYPES: | |
| 339 | - if issubclass(python_type, allowed_type): | ||
| 339 | + if safe_issubclass(python_type, allowed_type): | ||
| 340 | 340 | self._logger.info( | |
| 341 | 341 | f'Mapped Python type {python_type} to database type "dense_vector"' | |
| 342 | 342 | ) | |
@@ -354,7 +354,7 @@ def python_type_to_db_type(self, python_type: Type) -> Any: | |||
| 354 | 354 | } | |
| 355 | 355 | ||
| 356 | 356 | for type in elastic_py_types.keys(): | |
| 357 | - if issubclass(python_type, type): | ||
| 357 | + if safe_issubclass(python_type, type): | ||
| 358 | 358 | self._logger.info( | |
| 359 | 359 | f'Mapped Python type {python_type} to database type "{elastic_py_types[type]}"' | |
| 360 | 360 | ) | |
@@ -381,7 +381,7 @@ def _index( | |||
| 381 | 381 | '_id': row['id'], | |
| 382 | 382 | } | |
| 383 | 383 | for col_name, col in self._column_infos.items(): | |
| 384 | - if issubclass(col.docarray_type, AnyDocArray): | ||
| 384 | + if safe_issubclass(col.docarray_type, AnyDocArray): | ||
| 385 | 385 | continue | |
| 386 | 386 | if col.db_type == 'dense_vector' and np.all(row[col_name] == 0): | |
| 387 | 387 | row[col_name] = row[col_name] + 1.0e-9 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -265,7 +265,7 @@ def python_type_to_db_type(self, python_type: Type) -> Any: | |||
| 265 | 265 | if any(issubclass(python_type, vt) for vt in QDRANT_PY_VECTOR_TYPES): | |
| 266 | 266 | return 'vector' | |
| 267 | 267 | ||
| 268 | - if issubclass(python_type, docarray.typing.id.ID): | ||
| 268 | + if safe_issubclass(python_type, docarray.typing.id.ID): | ||
| 269 | 269 | return 'id' | |
| 270 | 270 | ||
| 271 | 271 | return 'payload' | |
@@ -587,7 +587,7 @@ def _build_point_from_row(self, row: Dict[str, Any]) -> rest.PointStruct: | |||
| 587 | 587 | vectors: Dict[str, List[float]] = {} | |
| 588 | 588 | payload: Dict[str, Any] = {'__generated_vectors': []} | |
| 589 | 589 | for column_name, column_info in self._column_infos.items(): | |
| 590 | - if issubclass(column_info.docarray_type, AnyDocArray): | ||
| 590 | + if safe_issubclass(column_info.docarray_type, AnyDocArray): | ||
| 591 | 591 | continue | |
| 592 | 592 | if column_info.db_type in ['id', 'payload']: | |
| 593 | 593 | payload[column_name] = row.get(column_name) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments