Utilities
media_factory(*, base, **kwargs)
Generic model factory.
Creates a new model based on the provided base
model.
Usage:
# create our own media partial
music = functools.partial(media_factory, base=Music)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base |
Type[T]
|
The base type for model |
required |
**kwargs |
Any
|
The fields to declare into media model |
{}
|
Returns:
Type | Description |
---|---|
T
|
New media type instance |
Raises:
Type | Description |
---|---|
ModelValidationError
|
If model fails during schema validation |
Source code in nucleus/sdk/harvest/partials.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Built-in partials
model = functools.partial(create_model, __base__=Model)
Note
The partial model
enhance the create_model
pydantic factory function by extending the default model as a base argument. This partial allows the fast creation of metadata models. For more information check here.
image = functools.partial(media_factory, base=Image)
video = functools.partial(media_factory, base=Video)
Tip
We can extend the list of multimedia partials using media_factory
and our own media type.