docarray.dataclasses.types module#
- docarray.dataclasses.types.field(*, _source_field: Optional[dataclasses.Field] = 'None', setter: Optional[Callable] = 'None', getter: Optional[Callable] = 'None', default='MISSING', default_factory='MISSING', init='True', repr='True', hash='None', compare='True', metadata='None') docarray.dataclasses.types.Field [source]#
- Return type
Field
- docarray.dataclasses.types.dataclass(cls: Optional[T] = None, *, init: bool = 'True', repr: bool = 'True', eq: bool = 'True', order: bool = 'False', unsafe_hash: bool = 'False', frozen: bool = 'False', type_var_map: Optional[Dict[TypeVar, Callable[[_Field], Field]]] = 'None') T [source]#
Annotates a class as a DocArray dataclass type.
Example usage:
>>> from docarray.typing import Image, Text >>> from docarray import dataclass >>> @dataclass: >>> class X: >>> banner: Image = 'apple.png' >>> description: Text = 'This is a big red apple.'
- Parameters
type_var_map (
Optional
[Dict
[TypeVar
,Callable
[[ForwardRef
],ForwardRef
]]]) –a mapping from TypeVar to a callable that gives Field.
_TYPES_REGISTRY = { Image: lambda x: field(setter=image_setter, getter=image_getter, _source_field=x), Text: lambda x: field(setter=text_setter, getter=text_getter, _source_field=x), }
The default mapping will be overrided by this new mapping if they collide on the keys.
- Return type
T