caikit.core.toolkit.serializers

Common serialization interfaces that are generally helpful for saving out models that are not necessarily specific to any domain’s 3rd party libraries.

Classes

ObjectSerializer

Abstract class for serializing an object to disk.

JSONSerializer

An ObjectSerializer for serializing to a JSON file.

TextSerializer

An ObjectSerializer for serializing a python list to a text file.

YAMLSerializer

An ObjectSerializer for serializing to a YAML file.

CSVSerializer

An ObjectSerializer for serializing to a CSV file.

PickleSerializer

An ObjectSerializer for pickling arbitrary Python objects.

Module Contents

class caikit.core.toolkit.serializers.ObjectSerializer[source]

Bases: abc.ABC

Abstract class for serializing an object to disk.

abstract serialize(obj, file_path)[source]

Serialize the provided object to the specified file path.

Args:

obj (object): The object to serialize file_path (str): Absolute path to which the object should be

serialized

class caikit.core.toolkit.serializers.JSONSerializer[source]

Bases: ObjectSerializer

An ObjectSerializer for serializing to a JSON file.

serialize(obj, file_path)[source]

Serialize the provided object to a JSON file.

Args:

obj (object): The object to serialize file_path (str): Absolute path to which the object should be

serialized

class caikit.core.toolkit.serializers.TextSerializer[source]

Bases: ObjectSerializer

An ObjectSerializer for serializing a python list to a text file.

serialize(obj, file_path)[source]

Serialize the provided python list to a text file.

Args:

obj (list(str)): The list to serialize file_path (str): Absolute path to which the object should be

serialized

class caikit.core.toolkit.serializers.YAMLSerializer[source]

Bases: ObjectSerializer

An ObjectSerializer for serializing to a YAML file.

serialize(obj, file_path)[source]

Serialize the provided object to a YAML file.

Args:

obj (object): The object to serialize file_path (str): Absolute path to which the object should be

serialized

class caikit.core.toolkit.serializers.CSVSerializer[source]

Bases: ObjectSerializer

An ObjectSerializer for serializing to a CSV file.

serialize(obj, file_path)[source]

Serialize the provided object to a CSV file.

Args:

obj (object): The object to serialize file_path (str): Absolute path to which the object should be

serialized

class caikit.core.toolkit.serializers.PickleSerializer[source]

Bases: ObjectSerializer

An ObjectSerializer for pickling arbitrary Python objects.

serialize(obj, file_path)[source]

Serialize the provided object to a CSV file.

Args:

obj (any): The object to serialize file_path (str): Absolute path to which the object should be

serialized