Skip to content

Possible Regression: ValueError when creating Request object with DocList of ImageDocs #1501

@movchan74

Description

@movchan74

Description

I have tested the latest version from the main branch and encountered a failure with the following code snippet. This issue does not occur with the latest release, so it might be a regression. It is worth investigating before the next release.

from docarray import DocVec, BaseDoc, DocList
from docarray.documents.image import ImageDoc

class Request(BaseDoc):
    images: DocList[ImageDoc]
        
images = DocList[ImageDoc]([ImageDoc(url=f'http://url.com/{i}.png') for i in range(10)])
request = Request(images=images)
request.json()

The code above results in the following error:

ValueError: {'id': '8695291365f8c39b5dc7e5272aff41be', 'url': ImageUrl('http://url.com/0.png', host_type='domain'), 'tensor': None, 'embedding': None, 'bytes_': None} is not a <class 'docarray.documents.image.ImageDoc'>

Steps to reproduce

  1. Run the code snippet provided above using the latest version from the main branch.
  2. Observe the ValueError.

Expected behavior

The code should run without errors, creating a Request object with a DocList of ImageDoc objects, and output the JSON representation of the request object.

Additional information

The issue does not occur with the latest release. It might be a regression introduced in recent commits.

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