Skip to content

Dynamic class creation #1152

Description

@jupyterjazz

Is your feature request related to a problem? Please describe.
In some scenarios users might want to dynamically create a class.
For example, in the search apps, data might be given through different sources, it might have a folder structure, and we are then responsible for converting it to a suitable docarray format, where this feature will come handy.

Describe the solution you'd like
Having a function that takes pairs of field names and their corresponding types and returns a class

Describe alternatives you've considered
Tried with Pydantic's create_model, and it works ok, but this doesn't return a BaseDocument so would be nice to have it handled inside docarray.

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