18. Snapshotting

veles.snapshotter.Snasphotter unit allows dumping the current workflow state in form of a Python pickle. Such “snapshot” can be stored on disk or in a database and used later to continue the workflow’s run from that point. In other words, snapshots are a kind of persistency. To restore from a snapshot and continue running, --snapshot command-line argument must be specified.

Internally, the main Veles workflow is pickled without the service classes such as veles.launcher.Launcher. This means that restoring from a snapshot requires the same workflow code as that the snapshot was taken with, because Python pickles contain only the data. Pickles are tolerant to code changes to some extent, but best way is to backup the code of the workflow together with the snapshot.

Every unit is pickled; veles.distributable.Pickleable base class ensures that attributes ending with a low dash sign (“_”) are not taken into the snapshot. Such attributes should be created inside Unit.init_unpickled() overriden method, which is called after each restoration from a snapshot and when the unit is created. Please note that __init__() is not called after unpickling. __getstate__() and __setstate__() methods are used, so child classes must call super() to override them. During unit’s initialization, it is possible to know if it was restored from a snapshot by reading restored_from_snapshot property. After the main workflow is initialized, it is always False.

Snapshots can be compressed with Snappy, Gzip, Bzip2 and Lzma algorithms. The default compression is Gzip. To change the compression type, pass “compression” argument to __init__():

Compression Argument value
no “” or None
Snappy “snappy”
Gzip “gz”
Bzip2 “bz2”
Lzma “xz”

18.2. Snapshotting to a database

In case of veles.znicz.standard_workflow.StandardWorkflow, you must add “odbc” parameter with Open Database Connectivity datasource definition, e.g. DRIVER={MySQL};SERVER=localhost;DATABASE=test;UID=test;PWD=test. By default, “veles” table will be used; to change it, set “table” parameter.

In case of manual workflow construction, you must link veles.snapshotter.SnasphotterToDB or any of it’s children and pass “odbc” and “table” constructor arguments.

The table scheme is as follows:

Field Type
timestamp datetime
id char(36)
log_id char(36)
workflow varchar(100)
name varchar(100)
codec varchar(10)
data longblob

Table Of Contents

Previous topic

17. Distributed Training: Master/slave

Next topic

19. Graphics and plotting

This Page