Dask

Interface for Dask arrays

pydantic model DaskJsonDict[source]

Round-trip json serialized form of a dask array

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Fields:
field chunks: Iterable[tuple[int, ...]] [Required]
field dtype: str [Required]
field name: str [Required]
field shape: tuple[int, ...] | None = None
field type: Literal['dask'] [Required]
field value: list [Required]
to_array_input() Array[source]

Construct a dask array

class DaskInterface(shape: Tuple[int, ...] | Any = typing.Any, dtype: str | type | Any | generic = typing.Any)[source]

Interface for Dask Array

return_type

alias of Array

json_model

alias of DaskJsonDict

classmethod check(array: Any) bool[source]

check if array is a dask array

before_validation(array: Array) NDArrayType[source]

Try and coerce dicts that should be model objects into the model objects

get_object_dtype(array: NDArrayType) str | type | Any | generic[source]

Dask arrays require a compute() call to retrieve a single value

classmethod enabled() bool[source]

check if we successfully imported dask

classmethod to_json(array: Array, info: SerializationInfo | None = None) List | DaskJsonDict[source]

Convert an array to a JSON serializable array by first converting to a numpy array and then to a list.

Note

This is likely a very memory intensive operation if you are using dask for large arrays. This can’t be avoided, since the creation of the json string happens in-memory with Pydantic, so you are likely looking for a different method of serialization here using the python object itself rather than its JSON representation.