def get_node_summary(node): """Return a multi line string with a pretty formatted summary of a Node. :param node: a Node instance :return: a string summary of the node """ from plumpy import ProcessState from aiida.orm import ProcessNode table_headers = ['Property', 'Value'] table = [] if isinstance(node, ProcessNode): table.append(['type', node.process_label]) try: process_state = ProcessState(node.process_state) except (AttributeError, ValueError): pass else: process_state_string = process_state.value.capitalize() if process_state == ProcessState.FINISHED and node.exit_message: table.append([ 'state', f'{process_state_string} [{node.exit_status}] {node.exit_message}' ]) elif process_state == ProcessState.FINISHED: table.append( ['state', f'{process_state_string} [{node.exit_status}]']) elif process_state == ProcessState.EXCEPTED: table.append( ['state', f'{process_state_string} <{node.exception}>']) else: table.append(['state', process_state_string]) else: table.append(['type', node.__class__.__name__]) table.append(['pk', str(node.pk)]) table.append(['uuid', str(node.uuid)]) table.append(['label', node.label]) table.append(['description', node.description]) table.append(['ctime', node.ctime]) table.append(['mtime', node.mtime]) try: computer = node.computer except AttributeError: pass else: if computer is not None: table.append( ['computer', f'[{node.computer.pk}] {node.computer.label}']) return tabulate(table, headers=table_headers)
def get_node_summary(node): """ Return a multi line string with a pretty formatted summary of a Node :param node: a Node instance :return: a string summary of the node """ from plumpy import ProcessState from aiida.orm.implementation.general.calculation import AbstractCalculation table_headers = ['Property', 'Value'] table = [] table.append(['type', node.__class__.__name__]) table.append(['pk', str(node.pk)]) table.append(['uuid', str(node.uuid)]) table.append(['label', node.label]) table.append(['description', node.description]) table.append(['ctime', node.ctime]) table.append(['mtime', node.mtime]) if issubclass(node.__class__, AbstractCalculation): try: process_state = node.process_state except AttributeError: process_state = None try: table.append(['process state', ProcessState(process_state)]) except ValueError: table.append(['process state', process_state]) try: table.append(['exit status', node.exit_status]) except AttributeError: table.append(['exit status', None]) try: computer = node.get_computer() except AttributeError: pass else: if computer is not None: table.append([ 'computer', '[{}] {}'.format(node.get_computer().pk, node.get_computer().name) ]) try: code = node.get_code() except AttributeError: pass else: if code is not None: table.append(['code', code.label]) return tabulate(table, headers=table_headers)
def process_state(self): """ Return the process state of the Calculation :returns: the process state instance of ProcessState enum """ state = self.get_attr(self.PROCESS_STATE_KEY, None) if state is None: return state else: return ProcessState(state)
def process_state(self): """ Return the process state :returns: the process state instance of ProcessState enum """ state = self.get_attribute(self.PROCESS_STATE_KEY, None) if state is None: return state return ProcessState(state)