Skip to content

Commit

Permalink
Improve output of verdi process status (#2871)
Browse files Browse the repository at this point in the history
Instead of displaying the node class and process state enum:

    CalcJobNode <pk=1000> [ProcessState.Running]

we print the process label and process state string value:

    PwCalculation<1000> Running

which is cleaner and gives more information
  • Loading branch information
sphuber authored May 14, 2019
1 parent c959379 commit e9b552a
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions aiida/cmdline/utils/ascii_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,32 @@ def _generate_node_label(node, node_attr, show_pk):
return label


def calc_info(calc_node):
def calc_info(node):
"""Return a string with the summary of the state of a CalculationNode."""
from aiida.orm import CalculationNode, CalcJobNode, WorkChainNode, WorkflowNode
from aiida.orm import ProcessNode, WorkChainNode

if isinstance(calc_node, WorkChainNode):
plabel = calc_node.process_label
pstate = calc_node.process_state
winfo = calc_node.stepper_state_info
if not isinstance(node, ProcessNode):
raise TypeError('Unknown type: {}'.format(type(node)))

if isinstance(node, WorkChainNode):
plabel = node.process_label
pstate = node.process_state.value.capitalize()
exit_status = node.exit_status
winfo = node.stepper_state_info

if winfo is None:
string = u'{} <pk={}> [{}]'.format(plabel, calc_node.pk, pstate)
string = u'{}<{}> {}'.format(plabel, node.pk, pstate)
else:
string = u'{} <pk={}> [{}] [{}]'.format(plabel, calc_node.pk, pstate, winfo)

elif isinstance(calc_node, CalcJobNode):
clabel = type(calc_node).__name__
cstate = str(calc_node.get_state())
string = u'{} <pk={}> [{}]'.format(clabel, calc_node.pk, cstate)
elif isinstance(calc_node, (CalculationNode, WorkflowNode)):
plabel = calc_node.process_label
pstate = calc_node.process_state
string = u'{} <pk={}> [{}]'.format(plabel, calc_node.pk, pstate)
string = u'{}<{}> {} [{}]'.format(plabel, node.pk, pstate, winfo)

else:
raise TypeError('Unknown type: {}'.format(type(calc_node)))
plabel = node.process_label
pstate = node.process_state.value.capitalize()
exit_status = node.exit_status
if exit_status is not None:
string = u'{}<{}> {} [{}]'.format(plabel, node.pk, pstate, exit_status)
else:
string = u'{}<{}> {}'.format(plabel, node.pk, pstate)

return string

Expand Down

0 comments on commit e9b552a

Please sign in to comment.