Skip to content

Is it possible to except a workflow when one element from the context fails? #4582

Answered by sphuber
JPchico asked this question in Q&A
Discussion options

You must be logged in to vote

There is nothing built into aiida-core that let's you instruct the workchain to terminate itself as soon as one of the "awaitables" excepts, is killed or terminates with a specific exit code. One could think of adding such a thing, but it would require a change in the current interface. One option would be to allow specifying a callback when adding an awaitable to the context, for example:

def submit_sub(self):
    for i in range(5):
        sub = self.submit(SomeProcess, **inputs)
        self.to_context_new(f'sub_{i}', sub, callback=self.check_sub)


def check_sub(self, sub_node):
    if sub_node.is_excepted or sub_node.is_killed or sub_node.exit_code.status < 400:
        return self.e…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@JPchico
Comment options

Answer selected by JPchico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants