pydantic
CamelModel
¶
Bases: BaseModel
Allows models to be defined with camel case properties.
See
https://medium.com/analytics-vidhya/camel-case-models-with-fast-api-and-pydantic-5a8acb6c0eee
Source code in m/pydantic.py
KebabModel
¶
Bases: BaseModel
Allows models to be defined with kebab case properties.
Inputs and outputs need to be written using a KebabModel
as a base class.
This is so that their definitions may be written using kebab casing in the
final action.yaml
.
from m.github.actions import KebabModel, InArg
class MyInput(KebabModel):
my_input: str = InArg(help='description')
Source code in m/pydantic.py
load_model(model, file_path, transform=None)
¶
Load a model from a json or yaml file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
type[GenericModel]
|
The class to create an instance of. |
required |
file_path |
str
|
The path to the file. |
required |
transform |
DataTransformer | None
|
A function to transform the data before creating the model. |
None
|
Returns:
Type | Description |
---|---|
Res[GenericModel]
|
A |
Source code in m/pydantic.py
parse_model(model, model_data)
¶
Parse a python object using pydantics TypeAdapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
type[GenericModel]
|
The class to create an instance of. |
required |
model_data |
Any
|
The data to parse. |
required |
Returns:
Type | Description |
---|---|
Res[GenericModel]
|
A |