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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]#

基类: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)[源代码]#

Correctly report and exception.

参数:
  • 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]][源代码]#

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

返回:

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)[源代码]#

Perform the archive import.

参数:
  • 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)[源代码]#

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

参数:
  • 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.

返回:

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

抛出:

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)[源代码]#

Create a new Code instance.

aiida.cmdline.commands.cmd_code.get_computer_name(ctx)[源代码]#
aiida.cmdline.commands.cmd_code.get_default(key, ctx)[源代码]#

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)[源代码]#
aiida.cmdline.commands.cmd_code.set_code_builder(ctx, param, value)[源代码]#

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)[源代码]#

基类: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)[源代码]#

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)[源代码]#

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)[源代码]#

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

参数:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

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

返回:

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)[源代码]#

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

参数:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

  • authinfo – the AuthInfo object

返回:

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)[源代码]#

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

参数:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

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

返回:

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)[源代码]#

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.

参数:
  • transport – an open transport

  • scheduler – the corresponding scheduler class

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

返回:

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)[源代码]#

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()[源代码]#

Retrieve the list of computers in the DB.

aiida.cmdline.commands.cmd_computer.get_parameter_default(parameter, ctx)[源代码]#

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

参数:
  • parameter – parameter name

  • ctx – click context of the command

返回:

parameter default value, or None

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

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[源代码]#

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

参数:
  • 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.

返回:

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[源代码]#

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

参数:
  • 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)[源代码]#

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()[源代码]#

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.

返回:

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)[源代码]#

Show the attributes or extras of one or more nodes.

Command for verdi plugins.

verdi process command.

aiida.cmdline.commands.cmd_process.default_projections()[源代码]#

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()[源代码]#

Return the most recent process node.

返回:

The ProcessNode with the latest ctime.

aiida.cmdline.commands.cmd_process.valid_projections()[源代码]#

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)[源代码]#

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)[源代码]#

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

参数:
  • 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[源代码]#

Echo the response of a request.

参数:
  • 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'>)[源代码]#

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)[源代码]#

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)[源代码]#

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)[源代码]#

Store the default user settings if not already present.

The verdi shell command

verdi status command.

class aiida.cmdline.commands.cmd_status.ServiceStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]#

基类:IntEnum

Describe status of services for ‘verdi status’ command.

DOWN = 3#
ERROR = 1#
UP = 0#
WARNING = 2#
__format__(format_spec, /)#

Default object formatter.

__module__ = 'aiida.cmdline.commands.cmd_status'#
__new__(value)#
aiida.cmdline.commands.cmd_status.print_status(status, service, msg='', exception=None, print_traceback=False)[源代码]#

Print status message.

Includes colored indicator.

参数:
  • status – a ServiceStatus code

  • service – string for service name

  • msg – message string

verdi storage commands.

verdi user command.

The main verdi click group.