chariots.serializers

Serializers are utils classes that are used throughout the Chariots framework to transform objects into bytes. there are for instance used to serialize the inner models of the machine learning ops:

>>> class LinearRegression(SKSupervisedOp):
...
...     serializer_cls = MySerializerCls
...
...     model_class = PCA
class chariots.ml.serializers.BaseSerializer[source]

Bases: abc.ABC

serializers are helper classes for communication and persistence through out the Chariots framework. There mostly used by MLOps.

for MLOps if you want to change the default serialization format (for the model to be saved), you will need to change the serializer_cls class attribute

abstract deserialize_object(serialized_object: bytes) → Any[source]

returns the deserialized object from serialized bytes (that will be loaded from a saver)

Parameters

serialized_object – the serialized bytes

Returns

the deserialized objects

abstract serialize_object(target: Any) → bytes[source]

serializes the object into bytes (for ml ops target will be the model itself and not the op, for the data ops the target will be the input of the node )

Parameters

target – the object that will be serialized

Returns

the bytes of the serialized object

class chariots.ml.serializers.DillSerializer[source]

Bases: chariots.ml.serializers._base_serializer.BaseSerializer

serializes objects using the dill library (similar to pickle but optimized for numpy arrays.

deserialize_object(serialized_object: bytes) → Any[source]

returns the deserialized object from serialized bytes (that will be loaded from a saver)

Parameters

serialized_object – the serialized bytes

Returns

the deserialized objects

serialize_object(target: Any) → bytes[source]

serializes the object into bytes (for ml ops target will be the model itself and not the op, for the data ops the target will be the input of the node )

Parameters

target – the object that will be serialized

Returns

the bytes of the serialized object

class chariots.ml.serializers.JSONSerializer[source]

Bases: chariots.ml.serializers._base_serializer.BaseSerializer

serializes objects into JSON format

deserialize_object(serialized_object: bytes) → Any[source]

returns the deserialized object from serialized bytes (that will be loaded from a saver)

Parameters

serialized_object – the serialized bytes

Returns

the deserialized objects

serialize_object(target: Any) → bytes[source]

serializes the object into bytes (for ml ops target will be the model itself and not the op, for the data ops the target will be the input of the node )

Parameters

target – the object that will be serialized

Returns

the bytes of the serialized object

class chariots.ml.serializers.CSVSerializer[source]

Bases: chariots.ml.serializers._base_serializer.BaseSerializer

A serializer to save a pandas data frame.

Raises

Typeerror – if the node receives something other than a pandas DataFrame

deserialize_object(serialized_object: bytes) → pandas.core.frame.DataFrame[source]

returns the deserialized object from serialized bytes (that will be loaded from a saver)

Parameters

serialized_object – the serialized bytes

Returns

the deserialized objects

serialize_object(target: pandas.core.frame.DataFrame) → bytes[source]

serializes the object into bytes (for ml ops target will be the model itself and not the op, for the data ops the target will be the input of the node )

Parameters

target – the object that will be serialized

Returns

the bytes of the serialized object