sagemaker.serve.marshalling.custom_payload_translator#

Defines CustomPayloadTranslator class that holds custom serialization/deserialization code

Classes

CustomPayloadTranslator([content_type, ...])

Abstract base class for handling custom payload serialization and deserialization.

class sagemaker.serve.marshalling.custom_payload_translator.CustomPayloadTranslator(content_type: str = 'application/custom', accept_type: str = 'application/custom')[source]#

Bases: ABC

Abstract base class for handling custom payload serialization and deserialization.

Provides a skeleton for customization requiring the overriding of the serialize_payload and deserialize_payload methods.

Parameters:
  • content_type (str) – The content type of the endpoint input data.

  • accept_type (str) – The content type of the data accepted from the endpoint.

property ACCEPT#

Placeholder docstring

property CONTENT_TYPE#

Placeholder docstring

deserialize(stream: IO, content_type: str = 'application/custom') object[source]#

Placeholder docstring

abstract deserialize_payload_from_stream(stream: IO) object[source]#

Deserialize stream into object.

Parameters:

stream (IO) – Stream of bytes

Returns:

Deserialized data

Return type:

object

serialize(payload: object, content_type: str = 'application/custom') bytes[source]#

Placeholder docstring

abstract serialize_payload_to_bytes(payload: object) bytes[source]#

Serialize payload into bytes

Parameters:

payload (object) – Data to be serialized into bytes.

Returns:

bytes of serialized data

Return type:

bytes