MCPcopy Create free account
hub / github.com/CaraJ7/MMSearch / PickleWriteable

Class PickleWriteable

retrieve_content/tokenization/utils.py:5–21  ·  view source on GitHub ↗

Mixin for persisting an instance with pickle.

Source from the content-addressed store, hash-verified

3
4
5class PickleWriteable:
6 """Mixin for persisting an instance with pickle."""
7
8 def save(self, path):
9 try:
10 with open(path, 'wb') as f:
11 pickle.dump(self, f)
12 except (pickle.PickleError, OSError) as e:
13 raise IOError('Unable to save {} to path: {}'.format(self.__class__.__name__, path)) from e
14
15 @classmethod
16 def load(cls, path):
17 try:
18 with open(path, 'rb') as f:
19 return pickle.load(f)
20 except (pickle.PickleError, OSError) as e:
21 raise IOError('Unable to load {} from path: {}'.format(cls.__name__, path)) from e

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected