pytorch_pfn_extras.writing.SimpleWriter#

class pytorch_pfn_extras.writing.SimpleWriter(savefun=<function save>, fs=None, out_dir='', **kwds)#

Bases: Writer

The most simple snapshot writer.

This class just passes the arguments to the actual saving function.

Parameters:
  • savefun (Callable[[...], None]) – Callable object. It takes three arguments: the output file path, the serialized dictionary object, and the optional keyword arguments.

  • fs (Any) – FileSystem abstracting interface to implement all the operations. optional, defaults to None

  • out_dir (str) – str. Specifies the directory this writer will use. It takes precedence over the one specified in __call__ optional, defaults to ''

  • kwds (Any) – Keyword arguments for the savefun.

Methods

__init__([savefun, fs, out_dir])

finalize()

Finalizes the writer.

initialize(out_dir)

save(filename, out_dir, target, savefun, ...)

__call__(filename, out_dir, target, *, savefun=None, append=False)#

Does the actual writing to the file.

This method is invoked by a Snapshot object every time it takes a snapshot.

Parameters:
  • filename (str) – Name of the file into which the serialized target is saved. It is a concrete file name, i.e. not a pre-formatted template string.

  • out_dir (str) –

    Output directory. Corresponds to :py:attr:`ExtensionsManager.out

    <pytorch_pfn_extras.training.ExtensionsManager.out>`.

  • target (dict) – Serialized object which will be saved.

  • savefun (callable) – A callable that accepts a two positional arguments (an object to be serialized, file path) like torch.save.

  • append (bool) – Mode used to open the file. True to use the append mode, False to use the write mode (truncates the file if it already exists).

Return type:

None

__init__(savefun=<function save>, fs=None, out_dir='', **kwds)#
Parameters:
  • savefun (Callable[[...], None]) –

  • fs (Optional[Any]) –

  • out_dir (str) –

  • kwds (Any) –

Return type:

None