Example #1
0
    def setUpClass(cls, *args, **kwargs):
        """
        Create some code to test the DataParamType parameter type for the command line infrastructure
        We create an initial code with a random name and then on purpose create two code with a name
        that matches exactly the ID and UUID, respectively, of the first one. This allows us to test
        the rules implemented to solve ambiguities that arise when determing the identifier type
        """
        super(TestDataParamType, cls).setUpClass(*args, **kwargs)

        cls.param = DataParamType()
        cls.entity_01 = Data().store()
        cls.entity_02 = Data().store()
        cls.entity_03 = Data().store()

        cls.entity_01.label = 'data_01'
        cls.entity_02.label = str(cls.entity_01.pk)
        cls.entity_03.label = str(cls.entity_01.uuid)
Example #2
0
            'failed to automatically detect an SSSP family: install it with `aiida-sssp install`.'
        )


SSSP_FAMILY = OverridableOption(
    '-F',
    '--sssp-family',
    type=GroupParamType(sub_classes=('aiida.groups:sssp.family', )),
    required=False,
    callback=default_sssp_family,
    help='Select an SSSP family.')

STRUCTURE = OverridableOption(
    '-S',
    '--structure',
    type=DataParamType(sub_classes=('aiida.data:structure', )),
    help='Filter for elements of the given structure.')

VERSION = OverridableOption(
    '-v',
    '--version',
    type=click.STRING,
    required=False,
    help='Select the version of the SSSP configuration.')

FUNCTIONAL = OverridableOption(
    '-f',
    '--functional',
    type=click.STRING,
    required=False,
    help='Select the functional of the SSSP configuration.')
Example #3
0
                         }})

    if not query.count():
        echo.echo("No Gaussian Pseudopotentials found.")
        return

    echo.echo_report("{} Gaussian Pseudopotentials found:\n".format(
        query.count()))
    echo.echo(_formatted_table_list(pseudo for [pseudo] in query.iterall()))
    echo.echo("")


# fmt: off
@cli.command('dump')
@arguments.DATA(
    type=DataParamType(sub_classes=("aiida.data:gaussian.pseudo", )))
@click.option('-s',
              '--sym',
              type=str,
              default=None,
              help="filter by a specific element")
@click.option('-n', '--name', type=str, default=None, help="filter by name")
@click.option(
    'tags',
    '--tag',
    '-t',
    multiple=True,
    help="filter by a tag (all tags must be present if specified multiple times)"
)
@click.option('output_format',
              '-f',
Example #4
0
    """
    DiffParameters = DataFactory("diff")

    qb = QueryBuilder()
    qb.append(DiffParameters)
    results = qb.all()

    s = ""
    for result in results:
        obj = result[0]
        s += f"{str(obj)}, pk: {obj.pk}\n"
    sys.stdout.write(s)


@data_cli.command("export")
@click.argument("node", metavar="IDENTIFIER", type=DataParamType())
@click.option(
    "--outfile",
    "-o",
    type=click.Path(dir_okay=False),
    help="Write output to file (default: print to stdout).",
)
@decorators.with_dbenv()
def export(node, outfile):
    """Export a DiffParameters node (identified by PK, UUID or label) to plain text."""
    string = str(node)

    if outfile:
        with open(outfile, "w") as f:
            f.write(string)
    else:
Example #5
0
    from aiida.plugins import DataFactory
    DiffParameters = DataFactory('ce')

    qb = QueryBuilder()
    qb.append(DiffParameters)
    results = qb.all()

    s = ""
    for result in results:
        obj = result[0]
        s += "{}, pk: {}\n".format(str(obj), obj.pk)
    sys.stdout.write(s)


@data_cli.command('export')
@click.argument('node', metavar='IDENTIFIER', type=DataParamType())
@click.option('--outfile',
              '-o',
              type=click.Path(dir_okay=False),
              help='Write output to file (default: print to stdout).')
@decorators.with_dbenv()
def export(node, outfile):
    """Export a DiffParameters node (identified by PK, UUID or label) to plain text."""
    string = str(node)

    if outfile:
        with open(outfile, 'w') as f:
            f.write(string)
    else:
        click.echo(string)
Example #6
0
            structure = fleurinps[j][0].get_structuredata_ncf()
            formula = structure.get_formula()
            entry.append(formula)
        for i in range(len(entry), len(list_project_headers)):
            entry.append(None)
        counter += 1
    fleurinp_list_data.extend(data_fleurinp)
    if raw:
        echo.echo(tabulate(fleurinp_list_data, tablefmt='plain'))
    else:
        echo.echo(tabulate(fleurinp_list_data, headers='firstrow'))
        echo.echo('\nTotal results: {}\n'.format(counter))


@cmd_fleurinp.command('cat')
@arguments.NODE('node', type=DataParamType(sub_classes=('aiida.data:fleur.fleurinp',)))
@click.option('-f',
              '--filename',
              'filename',
              default='inp.xml',
              show_default=True,
              help='Disply the file content of the given filename.')
def cat_file(node, filename):
    """
    Dumb the content of a file contained in given fleurinpdata, per default dump
    inp.xml
    """
    echo.echo(node.get_content(filename=filename))


'''
Example #7
0
    if tags:
        query.add_filter(BasisSet, {'attributes.tags': {'contains': tags}})

    if not query.count():
        echo.echo("No Gaussian Basis Sets found.")
        return

    echo.echo_report("{} Gaussian Basis Sets found:\n".format(query.count()))
    echo.echo(_formatted_table_list(bs for [bs] in query.iterall()))
    echo.echo("")


# fmt: off
@cli.command('dump')
@arguments.DATA(
    type=DataParamType(sub_classes=("aiida.data:gaussian.basisset", )))
@click.option('-s',
              '--sym',
              type=str,
              default=None,
              help="filter by a specific element")
@click.option('-n', '--name', type=str, default=None, help="filter by name")
@click.option(
    'tags',
    '--tag',
    '-t',
    multiple=True,
    help="filter by a tag (all tags must be present if specified multiple times)"
)
@click.option('output_format',
              '-f',
Example #8
0
            formula = structure.get_formula()
            entry.append(formula)
        for i in range(len(entry), len(list_project_headers)):
            entry.append(None)
        counter += 1
    fleurinp_list_data.extend(data_fleurinp)
    if raw:
        echo.echo(tabulate(fleurinp_list_data, tablefmt='plain'))
    else:
        echo.echo(tabulate(fleurinp_list_data, headers='firstrow'))
        echo.echo('\nTotal results: {}\n'.format(counter))


@cmd_fleurinp.command('cat')
@arguments.NODE('node',
                type=DataParamType(sub_classes=('aiida.data:fleur.fleurinp', ))
                )
@click.option('-f',
              '--filename',
              'filename',
              default='inp.xml',
              show_default=True,
              help='Disply the file content of the given filename.')
def cat_file(node, filename):
    """
    Dumb the content of a file contained in given fleurinpdata, per default dump
    inp.xml
    """
    echo.echo(node.get_content(filename=filename))