-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add built-in support and API for exit codes in WorkChains (#1640)
Currently it is possible to return non-zero integers from a WorkChain outline step to abort its execution and assign the exit status to the node, however, there is no official API yet to make this easier. Here we define the concept of an ExitCode, a named tuple that takes an integer exit status and a descriptive message. Through the ProcessSpec, a WorkChain developer can add exit codes that correspond to errors that may crop up during the execution of the workchain. For example the following spec definition: @classmethod def define(cls, spec): super(CifCleanWorkChain, cls).define(spec) spec.exit_code(418, 'ERROR_I_AM_A_TEAPOT', message='workchain found itself in an identity crisis') In one of the outline steps, the exit code can be used by retrieving it through either the integer exit status or the string label: return self.exit_codes('I_AM_A_TEAPOT') or return self.exit_codes(418) and return it. Returning an instance of ExitCode will trigger the exact same mechanism as returning an integer from an outline step. The engine will detect the ExitCode and return its exit status as the result, triggering the abort and the exit status to be set on the Node. Note that this addition required name changes in parts of the existing API. For example the Calculation attribute `finish_status` was renamed to `exit_status`. This is because it can now be accompanied by an string `exit_message`. The `exit_status` and `exit_message` together form the `ExitCode`.
- Loading branch information
Showing
24 changed files
with
415 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.