TaskFlow/SaveAndRestore

'''Save and restore task flow. Brief description.'''

Flow must be saved each time when 'on_task_finished' and 'on_task_reverted' events are happened.

What should be saved:

1. Flow type id.

2. Flow kwargs.

3. Flow state.

4. Task name (or other identifier, unique for each task).

5. Task data required to execute and revert.

6. Task state (executed, failed, etc).

7. Executed actions ids.

Restoring the flow:

Flow can be created from the blocks template (as a new flow). Flow id will help to choose the correct template. Then Flow state, kwargs and tasks data should be restored and set. Executed actions should be added to the proper collections. After the Flow can be resumed.

A little trick:

We don't need to save flow kwargs and create a table of dependencies between the Task and it's object in kwargs. We can redo executed saveActions instead and fill kwargs with data from Tasks.