Exemple #1
0
    def test_get_node_info_multiple_call_links(self):
        """Test the `get_node_info` utility.

        Regression test for #2868:
            Verify that all `CALL` links are included in the formatted string even if link labels are identical.
        """
        from aiida.cmdline.utils.common import get_node_info

        workflow = orm.WorkflowNode().store()
        node_one = orm.CalculationNode()
        node_two = orm.CalculationNode()

        node_one.add_incoming(workflow,
                              link_type=LinkType.CALL_CALC,
                              link_label='CALL_IDENTICAL')
        node_two.add_incoming(workflow,
                              link_type=LinkType.CALL_CALC,
                              link_label='CALL_IDENTICAL')
        node_one.store()
        node_two.store()

        node_info = get_node_info(workflow)
        self.assertTrue('CALL_IDENTICAL' in node_info)
        self.assertTrue(str(node_one.pk) in node_info)
        self.assertTrue(str(node_two.pk) in node_info)
Exemple #2
0
def node_show(nodes, print_groups):
    """Show generic information on one or more nodes."""
    from aiida.cmdline.utils.common import get_node_info

    for node in nodes:
        # pylint: disable=fixme
        # TODO: Add a check here on the node type, otherwise it might try to access
        # attributes such as code which are not necessarily there
        echo.echo(get_node_info(node))

        if print_groups:
            from aiida.orm.querybuilder import QueryBuilder
            from aiida.orm.groups import Group
            from aiida.orm import Node  # pylint: disable=redefined-outer-name

            # pylint: disable=invalid-name
            qb = QueryBuilder()
            qb.append(Node, tag='node', filters={'id': {'==': node.pk}})
            qb.append(Group, tag='groups', with_node='node', project=['id', 'label', 'type_string'])

            echo.echo('#### GROUPS:')

            if qb.count() == 0:
                echo.echo('Node {} does not belong to any group'.format(node.pk))
            else:
                echo.echo('Node {} belongs to the following groups:'.format(node.pk))
                res = qb.iterdict()
                table = [(gr['groups']['id'], gr['groups']['label'], gr['groups']['type_string']) for gr in res]
                table.sort()

                echo.echo(tabulate.tabulate(table, headers=['PK', 'Label', 'Group type']))
Exemple #3
0
def show(nodes, print_groups):
    """Show generic information on node(s)."""
    from aiida.cmdline.utils.common import get_node_info

    for node in nodes:
        # pylint: disable=fixme
        #TODO: Add a check here on the node type, otherwise it might try to access
        # attributes such as code which are not necessarily there
        echo.echo(get_node_info(node))

        if print_groups:
            from aiida.orm.querybuilder import QueryBuilder
            from aiida.orm.group import Group
            from aiida.orm.node import Node  # pylint: disable=redefined-outer-name

            # pylint: disable=invalid-name
            qb = QueryBuilder()
            qb.append(Node, tag='node', filters={'id': {'==': node.pk}})
            qb.append(Group,
                      tag='groups',
                      group_of='node',
                      project=['id', 'name'])

            echo.echo("#### GROUPS:")

            if qb.count() == 0:
                echo.echo("No groups found containing node {}".format(node.pk))
            else:
                res = qb.iterdict()
                for gr in res:
                    gr_specs = "{} {}".format(gr['groups']['name'],
                                              gr['groups']['id'])
                    echo.echo(gr_specs)
Exemple #4
0
def process_show(processes):
    """Show details for one or multiple processes."""
    from aiida.cmdline.utils.common import get_node_info

    for process in processes:
        echo.echo(get_node_info(process))
    def do_show(self, arg):  # pylint: disable=unused-argument
        """Show textual information on the current node."""
        from aiida.cmdline.utils.common import get_node_info

        print(get_node_info(self._current_node))
Exemple #6
0
def calculation_show(calculations):
    """Show a summary for one or multiple calculations."""
    from aiida.cmdline.utils.common import get_node_info

    for calculation in calculations:
        echo.echo(get_node_info(calculation))