Class DefaultSerializer (1.45.0)

DefaultSerializer()

Default serializer for serialization and deserialization for prediction.

Methods

deserialize

deserialize(data: typing.Any, content_type: typing.Optional[str]) -> typing.Any

Deserializes the request data. Invoked before predict.

Parameters
NameDescription
dataAny

Required. The request data sent to the application.

content_typestr

Optional. The specified content type of the request.

Exceptions
TypeDescription
HTTPExceptionIf Json deserialization failed or the specified content type is not supported.

serialize

serialize(prediction: typing.Any, accept: typing.Optional[str]) -> typing.Any

Serializes the prediction results. Invoked after predict.

Parameters
NameDescription
predictionAny

Required. The generated prediction to be sent back to clients.

acceptstr

Optional. The specified content type of the response.

Exceptions
TypeDescription
HTTPExceptionIf Json serialization failed or the specified accept is not supported.