Skip to content

Commit

Permalink
CLI: Call sys.exit for launch command if process fails (#298)
Browse files Browse the repository at this point in the history
For testing purposes it is convenient to know whether the process
launched through the `acwf launch` commands finished successfully. To
this end, the commands will now call `sys.exit(1)` if the process did
not finish with a zero exit code (or excepted or was killed).
  • Loading branch information
sphuber authored Feb 6, 2023
1 parent 611c2e6 commit bb9090a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aiida_common_workflows/cli/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# -*- coding: utf-8 -*-
"""Module with utitlies for the CLI."""
import sys

import click


def echo_process_results(node):
"""Display a formatted table of the outputs registered for the given process node.
If the node corresponds to a process that was actually run and that did not finish with a zero exit code, this
function will call ``sys.exit(1)``.
:param node: the `ProcessNode` of a terminated process.
"""
from aiida.common.links import LinkType
Expand All @@ -32,6 +37,9 @@ def echo_process_results(node):
for triple in sorted(outputs, key=lambda triple: triple.link_label):
click.echo(f'{triple.link_label:25s} {triple.node.__class__.__name__}<{triple.node.pk}> ')

if not node.is_finished_ok:
sys.exit(1)


def launch_process(process, daemon, **inputs):
"""Launch a process with the given inputs.
Expand Down

0 comments on commit bb9090a

Please sign in to comment.