Skip to content

Commit

Permalink
verdi process list: Add exit_message as projectable attribute (#5853
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sphuber authored Dec 22, 2022
1 parent 2adf62f commit 76ef9da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions aiida/tools/query/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class CalculationQueryBuilder:
_compound_projections = ('state',)
_default_projections = ('pk', 'ctime', 'process_label', 'state', 'process_status')
_valid_projections = (
'pk', 'uuid', 'ctime', 'mtime', 'state', 'process_state', 'process_status', 'exit_status', 'sealed',
'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state', 'scheduler_state',
'exception'
'pk', 'uuid', 'ctime', 'mtime', 'state', 'process_state', 'process_status', 'exit_status', 'exit_message',
'sealed', 'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state',
'scheduler_state', 'exception'
)

def __init__(self, mapper=None):
Expand Down
2 changes: 2 additions & 0 deletions aiida/tools/query/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, projections, projection_labels=None, projection_attributes=No
process_state_key = f'attributes.{ProcessNode.PROCESS_STATE_KEY}'
process_status_key = f'attributes.{ProcessNode.PROCESS_STATUS_KEY}'
exit_status_key = f'attributes.{ProcessNode.EXIT_STATUS_KEY}'
exit_message_key = f'attributes.{ProcessNode.EXIT_MESSAGE_KEY}'
exception_key = f'attributes.{ProcessNode.EXCEPTION_KEY}'

default_labels = {'pk': 'PK', 'uuid': 'UUID', 'ctime': 'Created', 'mtime': 'Modified', 'state': 'Process State'}
Expand All @@ -105,6 +106,7 @@ def __init__(self, projections, projection_labels=None, projection_attributes=No
'process_state': process_state_key,
'process_status': process_status_key,
'exit_status': exit_status_key,
'exit_message': exit_message_key,
'exception': exception_key,
}

Expand Down
11 changes: 9 additions & 2 deletions tests/cmdline/commands/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from aiida.cmdline.commands import cmd_process
from aiida.common.links import LinkType
from aiida.common.log import LOG_LEVEL_REPORT
from aiida.engine import ProcessState
from aiida.engine import Process, ProcessState
from aiida.orm import CalcJobNode, Group, WorkChainNode, WorkflowNode, WorkFunctionNode
from tests.utils.processes import WaitProcess

Expand Down Expand Up @@ -73,7 +73,9 @@ def test_list(self, run_cli_command):

# Set the WorkChainNode as failed
if state == ProcessState.FINISHED:
calc.set_exit_status(1)
exit_code = Process.exit_codes.ERROR_UNSPECIFIED
calc.set_exit_status(exit_code.status)
calc.set_exit_message(exit_code.message)

# Set the waiting work chain as paused as well
if state == ProcessState.WAITING:
Expand Down Expand Up @@ -174,6 +176,11 @@ def test_list(self, run_cli_command):

assert len(result.output_lines) == 1

# There should be a failed WorkChain with exit status 1
for flag in ['-P', '--project']:
result = run_cli_command(cmd_process.process_list, ['-r', '-X', flag, 'exit_message'])
assert Process.exit_codes.ERROR_UNSPECIFIED.message in result.output

def test_process_show(self, run_cli_command):
"""Test verdi process show"""
workchain_one = WorkChainNode()
Expand Down

0 comments on commit 76ef9da

Please sign in to comment.