Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Call sys.exit for launch command if process fails #298

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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