Esempio n. 1
0
# -*- coding: utf-8 -*-
# yapf: disable
"""
Module to make available commonly used click arguments.
"""

import click

from aiida.cmdline.params import types
from aiida.cmdline.params.arguments.overridable import OverridableArgument

CALCULATION = OverridableArgument('calculation', type=types.CalculationParamType())

CALCULATIONS = OverridableArgument('calculations', nargs=-1, type=types.CalculationParamType())

CODE = OverridableArgument('code', type=types.CodeParamType())

CODES = OverridableArgument('codes', nargs=-1, type=types.CodeParamType())

COMPUTER = OverridableArgument('computer', type=types.ComputerParamType())

COMPUTERS = OverridableArgument('computers', nargs=-1, type=types.ComputerParamType())

DATUM = OverridableArgument('datum', type=types.DataParamType())

DATA = OverridableArgument('data', nargs=-1, type=types.DataParamType())

GROUP = OverridableArgument('group', type=types.GroupParamType())

GROUPS = OverridableArgument('groups', nargs=-1, type=types.GroupParamType())
Esempio n. 2
0
LIST_CMDLINE_PROJECT_DEFAULT = get_property('verdishell.calculation_list')
LIST_CMDLINE_PROJECT_CHOICES = ('pk', 'state', 'ctime', 'job_state',
                                'calculation_state', 'scheduler_state',
                                'computer', 'type', 'description', 'label',
                                'uuid', 'mtime', 'user', 'sealed')


@verdi.group('calculation')
def verdi_calculation():
    """Inspect and manage calculations."""
    pass


@verdi_calculation.command('gotocomputer')
@arguments.CALCULATION(
    type=types.CalculationParamType(sub_classes=('aiida.calculations:job',
                                                 'aiida.calculations:inline')))
def calculation_gotocomputer(calculation):
    """
    Open a shell and go to the calculation folder on the computer

    This command opens a ssh connection to the folder on the remote
    computer on which the calculation is being/has been executed.
    """
    from aiida.common.exceptions import NotExistent

    try:
        transport = calculation._get_transport()
    except NotExistent as exception:
        echo.echo_critical(exception.message)

    remote_workdir = calculation._get_remote_workdir()
Esempio n. 3
0
import click

from aiida.cmdline.params import options as options_core
from aiida.cmdline.params import types
from aiida.cmdline.utils import decorators

from ..utils import launch
from ..utils import options
from . import cmd_launch


@cmd_launch.command('epw')
@options_core.CODE(required=True,
                   type=types.CodeParamType(entry_point='quantumespresso.epw'))
@click.option('--pw-nscf-parent',
              type=types.CalculationParamType(),
              help='The parent pw.x nscf calculation.')
@click.option('--ph-parent',
              type=types.CalculationParamType(),
              help='The parent ph.x calculation.')
@options.KPOINTS_MESH(default=[6, 6, 6])
@options.QPOINTS_MESH(default=[2, 2, 2])
@options.KFPOINTS_MESH(default=[6, 6, 6])
@options.QFPOINTS_MESH(default=[2, 2, 2])
@options.MAX_NUM_MACHINES()
@options.MAX_WALLCLOCK_SECONDS()
@options.WITH_MPI()
@options.DAEMON()
@decorators.with_dbenv()
def launch_calculation(code, kpoints_mesh, qpoints_mesh, kfpoints_mesh,
                       qfpoints_mesh, pw_nscf_parent, ph_parent,
Esempio n. 4
0
    projected = builder.get_projected(query_set, projections=project)

    headers = projected.pop(0)

    if raw:
        tabulated = tabulate(projected, tablefmt='plain')
        echo.echo(tabulated)
    else:
        tabulated = tabulate(projected, headers=headers)
        echo.echo(tabulated)
        echo.echo('\nTotal results: {}\n'.format(len(projected)))
        print_last_process_state_change(process_type='work')


@verdi_work.command('report')
@arguments.CALCULATIONS(type=types.CalculationParamType(
    sub_classes=('aiida.calculations:work', 'aiida.calculations:function')))
@click.option('-i',
              '--indent-size',
              type=int,
              default=2,
              help='set the number of spaces to indent each level by')
@click.option('-l',
              '--levelname',
              type=click.Choice(LOG_LEVELS.keys()),
              default='REPORT',
              help='filter the results by name of the log level')
@click.option('-m',
              '--max-depth',
              'max_depth',
              type=int,
              default=None,
Esempio n. 5
0
# -*- coding: utf-8 -*-
"""Command line scripts to launch a `EpwCalculation` for testing and demonstration purposes."""
import click

from aiida.cmdline.params import options, types
from aiida.cmdline.utils import decorators

from ..utils import launch
from ..utils import options as options_qe
from . import cmd_launch


@cmd_launch.command('epw')
@options.CODE(required=True, type=types.CodeParamType(entry_point='quantumespresso.epw'))
@click.option('--pw-nscf-parent', type=types.CalculationParamType(), help='The parent pw.x nscf calculation.')
@click.option('--ph-parent', type=types.CalculationParamType(), help='The parent ph.x calculation.')
@options_qe.KPOINTS_MESH(default=[6, 6, 6])
@options_qe.QPOINTS_MESH(default=[2, 2, 2])
@options_qe.KFPOINTS_MESH(default=[6, 6, 6])
@options_qe.QFPOINTS_MESH(default=[2, 2, 2])
@options_qe.MAX_NUM_MACHINES()
@options_qe.MAX_WALLCLOCK_SECONDS()
@options_qe.WITH_MPI()
@options_qe.DAEMON()
@decorators.with_dbenv()
def launch_calculation(
    code, kpoints_mesh, qpoints_mesh, kfpoints_mesh, qfpoints_mesh, pw_nscf_parent, ph_parent, max_num_machines,
    max_wallclock_seconds, with_mpi, daemon
):
    """Run a EpwCalculation."""
    from aiida import orm
Esempio n. 6
0
    return tuple(state for state in calc_states)


def active_process_states():
    """Return a list of process states that are considered active."""
    from plumpy import ProcessState
    return ([
        ProcessState.CREATED.value,
        ProcessState.WAITING.value,
        ProcessState.RUNNING.value,
    ])


CALCULATION = OverridableOption(
    '-C', '--calculation', 'calculation',
    type=types.CalculationParamType(),
    help='A single calculation identified by its ID or UUID.')

CALCULATIONS = OverridableOption(
    '-C', '--calculations', 'calculations',
    type=types.CalculationParamType(), cls=MultipleValueOption,
    help='One or multiple calculations identified by their ID or UUID.')

CODE = OverridableOption(
    '-X', '--code', 'code',
    type=types.CodeParamType(),
    help='A single code identified by its ID, UUID or label.')

CODES = OverridableOption(
    '-X', '--codes', 'codes',
    type=types.CodeParamType(), cls=MultipleValueOption,