aiida.cmdline.commands package#

Sub commands of the verdi command line interface.

The commands need to be imported here for them to be registered with the top-level command group.

Subpackages#

Submodules#

verdi archive command.

class aiida.cmdline.commands.cmd_archive.ExtrasImportCode(value)[source]#

Bases: Enum

Exit codes for the verdi command line.

__module__ = 'aiida.cmdline.commands.cmd_archive'#
keep_existing = ('k', 'c', 'l')#
mirror = ('n', 'c', 'u')#
none = ('k', 'n', 'l')#
update_existing = ('k', 'c', 'u')#
aiida.cmdline.commands.cmd_archive._echo_exception(msg: str, exception, warn_only: bool = False)[source]#

Correctly report and exception.

Parameters:
  • msg – The message prefix

  • exception – the exception raised

  • warn_only – If True only print a warning, otherwise calls sys.exit with a non-zero exit status

aiida.cmdline.commands.cmd_archive._gather_imports(archives, webpages) List[Tuple[str, bool]][source]#

Gather archives to import and sort into local files and URLs.

Returns:

list of (archive path, whether it is web based)

aiida.cmdline.commands.cmd_archive._import_archive_and_migrate(ctx: Context, archive: str, web_based: bool, import_kwargs: dict, try_migration: bool)[source]#

Perform the archive import.

Parameters:
  • archive – the path or URL to the archive

  • web_based – If the archive needs to be downloaded first

  • import_kwargs – keyword arguments to pass to the import function

  • try_migration – whether to try a migration if the import raises IncompatibleStorageSchema

verdi calcjob commands.

aiida.cmdline.commands.cmd_calcjob.get_remote_and_path(calcjob, path=None)[source]#

Return the remote folder output node and process the path argument.

Parameters:
  • calcjob – The CalcJobNode whose remote_folder to be returned.

  • path – The relative path of file. If not defined, it is attempted to determine the default output file from the node options or otherwise from the associated process class. If neither are defined, a ValueError is raised.

Returns:

A tuple of the RemoteData and the path of the output file to be used.

Raises:

ValueError – If path is not defined and no default output file is defined on the node nor its associated process class.

verdi code command.

aiida.cmdline.commands.cmd_code.create_code(ctx: Context, cls, non_interactive: bool, **kwargs)[source]#

Create a new Code instance.

aiida.cmdline.commands.cmd_code.get_computer_name(ctx)[source]#
aiida.cmdline.commands.cmd_code.get_default(key, ctx)[source]#

Get the default argument using a user instance property :param value: The name of the property to use :param ctx: The click context (which will be used to get the user) :return: The default value, or None

aiida.cmdline.commands.cmd_code.get_on_computer(ctx)[source]#
aiida.cmdline.commands.cmd_code.set_code_builder(ctx, param, value)[source]#

Set the code spec for defaults of following options.

verdi computer command.

class aiida.cmdline.commands.cmd_computer.LazyConfigureGroup(name: str | None = None, commands: MutableMapping[str, Command] | Sequence[Command] | None = None, **attrs: Any)[source]#

Bases: VerdiCommandGroup

A click group that will lazily load the subcommands for each transport plugin.

__annotations__ = {}#
__module__ = 'aiida.cmdline.commands.cmd_computer'#
get_command(ctx, name)[source]#

Return the command that corresponds to the requested cmd_name.

This method is overridden from the base class in order to two functionalities:

  • If the command is found, automatically add the verbosity option.

  • If the command is not found, attempt to provide a list of suggestions with existing commands that resemble the requested command name.

Note that if the command is not found and resilient_parsing is set to True on the context, then the latter feature is disabled because most likely we are operating in tab-completion mode.

list_commands(ctx)[source]#

Returns a list of subcommand names in the order they should appear.

aiida.cmdline.commands.cmd_computer._computer_create_temp_file(transport, scheduler, authinfo, computer)[source]#

Internal test to check if it is possible to create a temporary file and then delete it in the work directory

Note:

exceptions could be raised

Parameters:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

  • authinfo – the AuthInfo object (from which one can get computer and aiidauser)

Returns:

tuple of boolean indicating success or failure and an optional string message

aiida.cmdline.commands.cmd_computer._computer_get_remote_username(transport, scheduler, authinfo, computer)[source]#

Internal test to check if it is possible to determine the username on the remote.

Parameters:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

  • authinfo – the AuthInfo object

Returns:

tuple of boolean indicating success or failure and an optional string message

aiida.cmdline.commands.cmd_computer._computer_test_get_jobs(transport, scheduler, authinfo, computer)[source]#

Internal test to check if it is possible to check the queue state.

Parameters:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

  • authinfo – the AuthInfo object (from which one can get computer and aiidauser)

Returns:

tuple of boolean indicating success or failure and an optional string message

aiida.cmdline.commands.cmd_computer._computer_test_no_unexpected_output(transport, scheduler, authinfo, computer)[source]#

Test that there is no unexpected output from the connection.

This can happen if e.g. there is some spurious command in the .bashrc or .bash_profile that is not guarded in case of non-interactive shells.

Parameters:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

  • authinfo – the AuthInfo object (from which one can get computer and aiidauser)

Returns:

tuple of boolean indicating success or failure and an optional string message

aiida.cmdline.commands.cmd_computer._computer_use_login_shell_performance(transport, scheduler, authinfo, computer)[source]#

Execute a command over the transport with and without the use_login_shell option enabled.

By default, AiiDA uses a login shell when connecting to a computer in order to operate in the same environment as a user connecting to the computer. However, loading the login scripts of the shell can take time, which can significantly slow down all commands executed by AiiDA and impact the throughput of calculation jobs. This test executes a simple command both with and without using a login shell and emits a warning if the login shell is slower by at least 100 ms. If the computer is already configured to avoid using a login shell, the test is skipped and the function returns a successful test result.

aiida.cmdline.commands.cmd_computer.get_computer_names()[source]#

Retrieve the list of computers in the DB.

aiida.cmdline.commands.cmd_computer.get_parameter_default(parameter, ctx)[source]#

Get the value for a specific parameter from the computer_builder or the default value of that option

Parameters:
  • parameter – parameter name

  • ctx – click context of the command

Returns:

parameter default value, or None

aiida.cmdline.commands.cmd_computer.prompt_for_computer_configuration(computer)[source]#
aiida.cmdline.commands.cmd_computer.set_computer_builder(ctx, param, value)[source]#

Set the computer spec for defaults of following options.

aiida.cmdline.commands.cmd_computer.time_use_login_shell(authinfo, auth_params, use_login_shell: bool, iterations: int = 3) float[source]#

Execute the whoami over the transport for the given use_login_shell and report the time taken.

Parameters:
  • authinfo – The AuthInfo instance to use.

  • auth_params – The base authentication parameters.

  • use_login_shell – Whether to use a login shell or not.

  • iterations – The number of iterations of the command to call. Command will return the average call time.

Returns:

The average call time of the Transport.whoami command.

verdi config command.

verdi daemon commands.

aiida.cmdline.commands.cmd_daemon.execute_client_command(command: str, daemon_not_running_ok: bool = False, **kwargs) dict[str, Any] | None[source]#

Execute a command of the aiida.engine.daemon.client.DaemonClient and echo whether it failed or not.

Parameters:
  • command – The name of hte method.

  • daemon_not_running_ok – If True, the command raising an exception because the daemon was not running is not treated as a failure.

  • kwargs – Keyword arguments that are passed to the client method.

aiida.cmdline.commands.cmd_daemon.validate_daemon_workers(ctx, param, value)[source]#

Validate the value for the number of daemon workers to start with default set by config.

verdi database commands.

verdi devel commands.

aiida.cmdline.commands.cmd_devel.prepare_localhost()[source]#

Prepare and return the localhost as Computer.

If it doesn’t already exist, the computer will be created, using core.local and core.direct as the entry points for the transport and scheduler type, respectively. In that case, the safe transport interval and the minimum job poll interval will both be set to 0 seconds in order to guarantee a throughput that is as fast as possible.

Returns:

The localhost configured as a Computer.

verdi group commands

Command for verdi help.

verdi node command.

aiida.cmdline.commands.cmd_node.echo_node_dict(nodes, keys, fmt, identifier, raw, use_attrs=True)[source]#

Show the attributes or extras of one or more nodes.

Command for verdi plugins.

verdi process command.

aiida.cmdline.commands.cmd_process.default_projections()[source]#

Return list of default projections for the --project option of verdi process list.

This indirection is necessary to prevent loading the imported module which slows down tab-completion.

aiida.cmdline.commands.cmd_process.get_most_recent_node()[source]#

Return the most recent process node.

Returns:

The ProcessNode with the latest ctime.

aiida.cmdline.commands.cmd_process.valid_projections()[source]#

Return list of valid projections for the --project option of verdi process list.

This indirection is necessary to prevent loading the imported module which slows down tab-completion.

verdi profile command.

aiida.cmdline.commands.cmd_profile._strip_private_keys(dct: dict)[source]#

Remove private keys (starting _) from the dictionary.

aiida.cmdline.commands.cmd_profile.command_create_profile(ctx: Context, storage_cls, non_interactive: bool, profile: Profile, set_as_default: bool = True, **kwargs)[source]#

Create a new profile, initialise its storage and create a default user.

Parameters:
  • ctx – The context of the CLI command.

  • storage_cls – The storage class obtained through loading the entry point from aiida.storage group.

  • non_interactive – Whether the command was invoked interactively or not.

  • profile – The profile instance. This is an empty Profile instance created by the command line argument which currently only contains the selected profile name for the profile that is to be created.

  • set_as_default – Whether to set the created profile as the new default.

  • kwargs – Arguments to initialise instance of the selected storage implementation.

verdi devel rabbitmq commands.

aiida.cmdline.commands.cmd_rabbitmq.echo_response(response: requests.Response, exit_on_error: bool = True) None[source]#

Echo the response of a request.

Parameters:
  • response – The response to the request.

  • exit_on_error – Boolean, if True, call sys.exit with the status code of the response.

aiida.cmdline.commands.cmd_rabbitmq.with_client(wrapper=None, enabled=None, adapter=None, proxy=<class 'FunctionWrapper'>)[source]#

Decorate a function injecting a aiida.brokers.rabbitmq.client.RabbitmqManagementClient.

This allows to hook-up the AiiDA built-in RESTful API. Main advantage of doing this by means of a verdi command is that different profiles can be selected at hook-up (-p flag).

verdi run command.

aiida.cmdline.commands.cmd_run.update_environment(argv)[source]#

Context manager that temporarily replaces sys.argv with argv and adds current working dir to the path.

aiida.cmdline.commands.cmd_run.validate_entry_point_strings(_, __, value)[source]#

Validate that value is a valid entrypoint string.

The verdi setup and verdi quicksetup commands.

aiida.cmdline.commands.cmd_setup._store_default_user_settings(config, email, first_name, last_name, institution)[source]#

Store the default user settings if not already present.

The verdi shell command

verdi status command.

class aiida.cmdline.commands.cmd_status.ServiceStatus(value)[source]#

Bases: IntEnum

Describe status of services for ‘verdi status’ command.

DOWN = 3#
ERROR = 1#
UP = 0#
WARNING = 2#
__module__ = 'aiida.cmdline.commands.cmd_status'#
aiida.cmdline.commands.cmd_status.print_status(status, service, msg='', exception=None, print_traceback=False)[source]#

Print status message.

Includes colored indicator.

Parameters:
  • status – a ServiceStatus code

  • service – string for service name

  • msg – message string

verdi storage commands.

verdi user command.

The main verdi click group.