simpleml.save_patterns.serializers.pickle

Module for pickle save patterns

Module Contents

Classes

PickleFileSerializer

PickleInMemorySerializer

PicklePersistenceMethods

Base class for internal pickle serialization/deserialization options

Attributes

__author__

simpleml.save_patterns.serializers.pickle.__author__ = Elisha Yadgaran[source]
class simpleml.save_patterns.serializers.pickle.PickleFileSerializer[source]

Bases: simpleml.save_patterns.base.BaseSerializer

static deserialize(filepath, source_directory='system_temp', **kwargs)[source]
Parameters
  • filepath (str) –

  • source_directory (str) –

Return type

Dict[str, Any]

static serialize(obj, filepath, format_directory=PICKLE_DIRECTORY, format_extension='.pkl', destination_directory='system_temp', **kwargs)[source]
Parameters
  • obj (Any) –

  • filepath (str) –

  • format_directory (str) –

  • format_extension (str) –

  • destination_directory (str) –

Return type

Dict[str, str]

class simpleml.save_patterns.serializers.pickle.PickleInMemorySerializer[source]

Bases: simpleml.save_patterns.base.BaseSerializer

static deserialize(obj, **kwargs)[source]
Parameters

obj (str) –

Return type

Dict[str, Any]

static serialize(obj, **kwargs)[source]
Parameters

obj (Any) –

Return type

Dict[str, str]

class simpleml.save_patterns.serializers.pickle.PicklePersistenceMethods[source]

Bases: object

Base class for internal pickle serialization/deserialization options

static dump_object(obj, filepath, overwrite=True)[source]

Pickles an object to a string or to the filesystem. Assumes that a NULL filepath expects a serialized string returned

Prepends path to SimpleML Pickle directory before saving. ONLY pass in a relative filepath from that location

Parameters
  • overwrite (bool) – Boolean indicating whether to first check if pickled object is already serialized. Defaults to not checking, but can be leverage by implementations that want the same artifact in multiple places

  • obj (Any) –

  • filepath (str) –

Return type

None

static dumps_object(obj)[source]

Pickles an object to a string or to the filesystem. Assumes that a NULL filepath expects a serialized string returned

Prepends path to SimpleML Pickle directory before saving. ONLY pass in a relative filepath from that location

Parameters
  • overwrite – Boolean indicating whether to first check if pickled object is already serialized. Defaults to not checking, but can be leverage by implementations that want the same artifact in multiple places

  • obj (Any) –

Return type

str

static load_object(filepath)[source]

Loads an object from a serialized string or filesystem. When stream is True, it tries to load the file directly from the string.

Prepends path to SimpleML Pickle directory before loading. ONLY pass in a relative filepath from that location

Parameters

filepath (str) –

Return type

Any

static loads_object(data)[source]

Loads an object from a serialized string or filesystem. When stream is True, it tries to load the file directly from the string.

Prepends path to SimpleML Pickle directory before loading. ONLY pass in a relative filepath from that location

Parameters

data (str) –

Return type

Any