padl.dumptools.serialize

class padl.dumptools.serialize.Serializer(val: Any, save_function: Callable, load_function: callable, file_suffix: Optional[str] = None, module: Optional[module] = None)

Serializer base class.

Parameters
  • val – The value to serialize.

  • save_function – The function to use for saving val.

  • load_function – The function to use for loading val.

  • file_suffix – If set, a string that will be appended to the path.

  • module – The module the serializer functions are defined in. Optional, default is to use the calling module.

save(path: pathlib.Path)

Save the serializer’s value to path.

Returns a codegraph containing code needed to load the value.

classmethod save_all(codegraph, path)

Save all values.

property varname

The varname to store in the dumped code.

padl.dumptools.serialize.json_serializer(val)

Create a json serializer for val.

padl.dumptools.serialize.load_json(path)

Loader for json.

padl.dumptools.serialize.save_json(val, path)

Saver for json.

padl.dumptools.serialize.value(val, serializer=None)

Helper function that marks things in the code that should be stored by value.