FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Bug: issubclass cause error in IOMixin._get_access_paths · Issue #1584 · docarray/docarray · GitHub

Bug: issubclass cause error in IOMixin._get_access_paths #1584

Description

The issue described in #1557 still exists in IOMixin._get_access_paths, here is an example:

from typing import List
from docarray import BaseDoc, DocList

class TestDoc(BaseDoc):
    topics: List[str]

dl = DocList[TestDoc]([TestDoc(topics=["a", "b"])])
dl.to_dataframe()

Produces the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[1], line 6
      4     topics: List[str]
      5 dl = DocList[TestDoc]([TestDoc(topics=["a", "b"])])
----> 6 dl.to_dataframe()

File ~/miniconda3/envs/test/lib/python3.11/site-packages/docarray/array/doc_list/io.py:542, in IOMixinArray.to_dataframe(self)
    535 if self.doc_type == AnyDoc:
    536     raise TypeError(
    537         'DocList must be homogeneous to be converted to a DataFrame.'
    538         'There is no document schema defined. '
    539         'Please specify the DocList\'s Document type using `DocList[MyDoc]`.'
    540     )
--> 542 fields = self.doc_type._get_access_paths()
    543 df = pd.DataFrame(columns=fields)
    545 for doc in self:

File ~/miniconda3/envs/test/lib/python3.11/site-packages/docarray/base_doc/mixins/io.py:397, in IOMixin._get_access_paths(cls)
    395 for field in cls.__fields__.keys():
    396     field_type = cls._get_field_type(field)
--> 397     if not is_union_type(field_type) and issubclass(field_type, BaseDoc):
    398         sub_paths = field_type._get_access_paths()
    399         for path in sub_paths:

File <frozen abc>:123, in __subclasscheck__(cls, subclass)

TypeError: issubclass() arg 1 must be a class```

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL