caikit.runtime.http_server.pydantic_wrapper =========================================== .. py:module:: caikit.runtime.http_server.pydantic_wrapper .. autoapi-nested-parse:: This module holds the Pydantic wrapping required by the REST server, capable of converting to and from Pydantic models to our DataObjects. Attributes ---------- .. autoapisummary:: caikit.runtime.http_server.pydantic_wrapper.log caikit.runtime.http_server.pydantic_wrapper.PYDANTIC_TO_DM_MAPPING Functions --------- .. autoapisummary:: caikit.runtime.http_server.pydantic_wrapper.pydantic_to_dataobject caikit.runtime.http_server.pydantic_wrapper.dataobject_to_pydantic caikit.runtime.http_server.pydantic_wrapper._get_pydantic_type caikit.runtime.http_server.pydantic_wrapper._conditionally_convert_dataobject caikit.runtime.http_server.pydantic_wrapper._from_base64 caikit.runtime.http_server.pydantic_wrapper.pydantic_from_request caikit.runtime.http_server.pydantic_wrapper._parse_form_data_to_pydantic caikit.runtime.http_server.pydantic_wrapper._get_pydantic_subtypes Module Contents --------------- .. py:data:: log .. py:data:: PYDANTIC_TO_DM_MAPPING .. py:function:: pydantic_to_dataobject(pydantic_model: pydantic.BaseModel) -> caikit.core.data_model.base.DataBase Convert pydantic objects to our DM objects .. py:function:: dataobject_to_pydantic(dm_class: Type[caikit.core.data_model.base.DataBase]) -> Type[pydantic.BaseModel] Make a pydantic model based on the given proto message by using the data model class annotations to mirror as a pydantic model .. py:function:: _get_pydantic_type(field_type: type) -> type Recursive helper to get a valid pydantic type for every field type .. py:function:: _conditionally_convert_dataobject(obj: Any) -> Any .. py:function:: _from_base64(data: Union[bytes, str]) -> bytes .. py:function:: pydantic_from_request(pydantic_model: Type[pydantic.BaseModel], request: fastapi.Request) :async: 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` .. py:function:: _parse_form_data_to_pydantic(pydantic_model: Type[pydantic.BaseModel], form_data: fastapi.datastructures.FormData) -> pydantic.BaseModel Helper function to parse a fastapi form data into a pydantic model .. py:function:: _get_pydantic_subtypes(pydantic_model: Type[pydantic.BaseModel], keys: List[str]) -> List[type] Recursive helper to get the type_hint for a field