caikit.runtime.http_server.pydantic_wrapper
This module holds the Pydantic wrapping required by the REST server, capable of converting to and from Pydantic models to our DataObjects.
Attributes
Functions
Convert pydantic objects to our DM objects |
|
|
Make a pydantic model based on the given proto message by using the data |
|
Recursive helper to get a valid pydantic type for every field type |
|
|
|
Function to convert a fastapi request into a given pydantic model. This |
|
Helper function to parse a fastapi form data into a pydantic model |
|
Recursive helper to get the type_hint for a field |
Module Contents
- caikit.runtime.http_server.pydantic_wrapper.PYDANTIC_TO_DM_MAPPING
- caikit.runtime.http_server.pydantic_wrapper.pydantic_to_dataobject(pydantic_model: pydantic.BaseModel) caikit.core.data_model.base.DataBase[source]
Convert pydantic objects to our DM objects
- caikit.runtime.http_server.pydantic_wrapper.dataobject_to_pydantic(dm_class: Type[caikit.core.data_model.base.DataBase]) Type[pydantic.BaseModel][source]
Make a pydantic model based on the given proto message by using the data model class annotations to mirror as a pydantic model
- caikit.runtime.http_server.pydantic_wrapper._get_pydantic_type(field_type: type) type[source]
Recursive helper to get a valid pydantic type for every field type
- caikit.runtime.http_server.pydantic_wrapper._conditionally_convert_dataobject(obj: Any) Any[source]
- async caikit.runtime.http_server.pydantic_wrapper.pydantic_from_request(pydantic_model: Type[pydantic.BaseModel], request: fastapi.Request)[source]
Function to convert a fastapi request into a given pydantic model. This function parses the requests Content-Type and then correctly decodes the data. The currently supported Content-Types are application/json and multipart/form-data