aiida-core icon indicating copy to clipboard operation
aiida-core copied to clipboard

`Process`: properly cleanup when exception in state transition

Open sphuber opened this issue 1 year ago • 1 comments

Fixes #2861 Fixes #3334

If a process would hit an exception during a state transition, the node would not always be cleaned up properly. For example, when a process registers invalid outputs, the process would except in update_outputs which is called by on_entered which is called once the process has entered a new state.

This exception would not be dealt with, skipping the code that is responsible for updating the process state on the node. This would lead to the node of the excepted node to still show the previous incorrect state. Typically, users would see processes as Running in the output of verdi process list. This is because that value is taken from the process_state attribute, but this simply contained the incorrect state.

The solution requires a fix in plumpy, which was released with v0.21. but it also requires an update in update_node_state of the Process class to make sure the set_process_state call is made before the update_outputs which is prone to excepting in the case of invalid outputs having been registered by the process implementation.

sphuber avatar Oct 12 '22 20:10 sphuber

Note this is blocked because it requires a fix in plumpy provided by this PR https://github.com/aiidateam/plumpy/pull/240

sphuber avatar Oct 12 '22 20:10 sphuber