nannyml.io.store.serializers module

class nannyml.io.store.serializers.JoblibPickleSerializer[source]

Bases: Serializer

A serializer based on the joblib pickling library.

Examples

>>> ser = JoblibPickleSerializer()
>>> b = ser.serialize(obj=calc)
>>> loaded_calc = ser.deserialize(bytez=b)
class nannyml.io.store.serializers.PickleSerializer[source]

Bases: Serializer

A serializer based on the standard pickle library.

Examples

>>> ser = PickleSerializer()
>>> b = ser.serialize(obj=calc)
>>> loaded_calc = ser.deserialize(bytez=b)
class nannyml.io.store.serializers.Serializer[source]

Bases: ABC

Abstract class for converting objects into bytes and the other way around.

deserialize(bytez: bytes, *args, **kwargs) object[source]

Convert bytes back into an object

Parameters:
  • bytez (bytes) – The bytes to convert into an object

  • args (List[Any]) – Any arguments used to control the deserialization.

  • kwargs (Dict[str, Any]) – Any keyword arguments used to control the deserialization.

Returns:

obj – The object that was in the byte representation.

Return type:

object

serialize(obj, *args, **kwargs) bytes[source]

Convert an object into bytes.

Parameters:
  • obj (object) – The object to be converted.

  • args (List[Any]) – Any arguments used to control the serialization.

  • kwargs (Dict[str, Any]) – Any keyword arguments used to control the serialization.

Returns:

bytez – The byte representation of the given object

Return type:

bytes

Raises:

SerializeException – when an unexpected exception occurs during serialization.: