예제 #1
0
    def test_get_process_function_report(self):
        """Test the `get_process_function_report` utility."""
        from aiida.cmdline.utils.common import get_process_function_report

        warning = 'You have been warned'

        node = orm.CalcFunctionNode()
        node.store()

        # Add a log message through the logger
        node.logger.warning(warning)

        self.assertIn(warning, get_process_function_report(node))
예제 #2
0
    def update(self):
        """Update report that is shown."""
        if self.process is None:
            return

        if isinstance(self.process, CalcJobNode):
            string = get_calcjob_report(self.process)
        elif isinstance(self.process, WorkChainNode):
            string = get_workchain_report(self.process, self.levelname, self.indent_size, self.max_depth)
        elif isinstance(self.process, (CalcFunctionNode, WorkFunctionNode)):
            string = get_process_function_report(self.process)
        else:
            string = 'Nothing to show for node type {}'.format(self.process.__class__)
        self.value = string.replace('\n', '<br/>')
예제 #3
0
def process_report(processes, levelname, indent_size, max_depth):
    """Show the log report for one or multiple processes."""
    from aiida.cmdline.utils.common import get_calcjob_report, get_workchain_report, get_process_function_report
    from aiida.orm import CalcJobNode, WorkChainNode, CalcFunctionNode, WorkFunctionNode

    for process in processes:
        if isinstance(process, CalcJobNode):
            echo.echo(get_calcjob_report(process))
        elif isinstance(process, WorkChainNode):
            echo.echo(
                get_workchain_report(process, levelname, indent_size,
                                     max_depth))
        elif isinstance(process, (CalcFunctionNode, WorkFunctionNode)):
            echo.echo(get_process_function_report(process))
        else:
            echo.echo(f'Nothing to show for node type {process.__class__}')
예제 #4
0
    def do_report(self, arg):  # pylint: disable=unused-argument
        """Show the report, if the node is a ProcessNode"""
        from aiida.cmdline.utils.common import get_calcjob_report, get_workchain_report, get_process_function_report
        from aiida.orm import CalcJobNode, WorkChainNode, CalcFunctionNode, WorkFunctionNode

        process = self._current_node
        if isinstance(process, CalcJobNode):
            print(get_calcjob_report(process), file=self.stdout)
        elif isinstance(process, WorkChainNode):
            print(get_workchain_report(process, arg.levelname, arg.indent_size,
                                       arg.max_depth),
                  file=self.stdout)
        elif isinstance(process, (CalcFunctionNode, WorkFunctionNode)):
            print(get_process_function_report(process), file=self.stdout)
        else:
            print('Nothing to show for node type {}'.format(process.__class__),
                  file=self.stdout)