aiida.cmdline documentation


class aiida.cmdline.baseclass.VerdiCommand[source]

This command has no documentation yet.

complete(subargs_idx, subargs)[source]

Method called when the user asks for the bash completion. Print a list of valid keywords. Returning without printing will use standard bash completion.

  • subargs_idx – the index of the subargs where the TAB key was pressed (0 is the first element of subargs)
  • subargs – a list of subarguments to this command
classmethod get_command_name()[source]

Return the name of the verdi command associated to this class. By default, the lower-case version of the class name.


Return the current command name. Also tries to get the subcommand name.

Parameters:with_exec_name – if True, return the full string, including the executable name (‘verdi’). If False, omit it.

Method executed when the command is called from the command line.

class aiida.cmdline.baseclass.VerdiCommandWithSubcommands[source]

Used for commands with subcommands. Just define, in the __init__, the self.valid_subcommands dictionary, in the format:

self.valid_subcommands = {
    'uploadfamily': (self.uploadfamily, self.complete_auto),
    'listfamilies': (self.listfamilies, self.complete_none),

where the key is the subcommand name to give on the command line, and the value is a tuple of length 2, the first is the function to call on execution, the second is the function to call on complete.

This class already defined the complete_auto and complete_none commands, that respectively call the default bash completion for filenames/folders, or do not give any completion suggestion. Other functions can of course be defined.


Improve the docstrings for commands with subcommands.

get_full_command_name(*args, **kwargs)[source]

Return the current command name. Also tries to get the subcommand name.

Also tries to see if the caller function was one specific submethod.

Parameters:with_exec_name – if True, return the full string, including the executable name (‘verdi’). If False, omit it.

Verdi lib

Command line commands for the main executable ‘verdi’ of aiida

If you want to define a new command line parameter, just define a new class inheriting from VerdiCommand, and define a run(self,*args) method accepting a variable-length number of parameters args (the command-line parameters), which will be invoked when this executable is called as verdi NAME

Don’t forget to add the docstring to the class: the first line will be the short description, the following ones the long description.

class aiida.cmdline.verdilib.Completion[source]

Manage bash completion

Return a list of available commands, separated by spaces. Calls the correct function of the command if the TAB has been pressed after the first command.

Returning without printing will use the default bash completion.

class aiida.cmdline.verdilib.CompletionCommand[source]

Return the bash completion function to put in ~/.bashrc

This command prints on screen the function to be inserted in your .bashrc command. You can copy and paste the output, or simply add eval “verdi completioncommand” to your .bashrc, AFTER having added the aiida/bin directory to the path.


I put the documentation here, and I don’t print it, so we don’t clutter too much the .bashrc.

  • “${THE_WORDS[@]}” (with the @) puts each element as a different parameter; note that the variable expansion etc. is performed
  • I add a ‘x’ at the end and then remove it; in this way, $( ) will not remove trailing spaces
  • If the completion command did not print anything, we use the default bash completion for filenames
  • If instead the code prints something empty, thanks to the workaround above $OUTPUT is not empty, so we do go the the ‘else’ case and then, no substitution is suggested.
class aiida.cmdline.verdilib.Help[source]

Describe a specific command

Pass a further argument to get a description of a given command.

class aiida.cmdline.verdilib.Install[source]

Install/setup aiida for the current user

This command creates the ~/.aiida folder in the home directory of the user, interactively asks for the database settings and the repository location, does a setup of the daemon and runs a migrate command to create/setup the database.

complete(subargs_idx, subargs)[source]

No completion after ‘verdi install’.

class aiida.cmdline.verdilib.ListParams[source]

List available commands

List available commands and their short description. For the long description, use the ‘help’ command.

class aiida.cmdline.verdilib.Run[source]

Execute an AiiDA script

class aiida.cmdline.verdilib.Runserver[source]

Run the AiiDA webserver on localhost

This command runs the webserver on the default port. Further command line options are passed to the Django manage runserver command

class aiida.cmdline.verdilib.Shell[source]

Run the interactive shell with the AiiDA environment loaded.

This command opens an ipython shell with the AiiDA environment loaded.


The main function to be called. Pass as paramater the sys.argv.


A function that prints on stderr a list of similar commands


Return a string with the list of parameters, to be printed

The advantage of this function is that the calling routine can choose to print it on stdout or stderr, depending on the needs.

aiida.cmdline.verdilib.update_environment(*args, **kwds)[source]

Used as a context manager, changes sys.argv with the new_argv argument, and restores it upon exit.


class aiida.cmdline.commands.daemon.Daemon[source]

Manage the AiiDA daemon

This command allows to interact with the AiiDA daemon. Valid subcommands are:

  • start: start the daemon
  • stop: restart the daemon
  • restart: restart the aiida daemon, waiting for it to cleanly exit before restarting it.
  • status: inquire the status of the Daemon.
  • logshow: show the log in a continuous fashion, similar to the ‘tail -f’ command. Press CTRL+C to exit.

A dictionary with valid commands and functions to be called: start, stop, status and restart.


Configure the user that can run the daemon.


Show the log of the daemon, press CTRL+C to quit.


Restart the daemon. Before restarting, wait for the daemon to really shut down.


Start the daemon


Print the status of the daemon

daemon_stop(*args, **kwargs)[source]

Stop the daemon.

Parameters:wait_for_death – If True, also verifies that the process was already killed. It attempts at most max_retries times, with sleep_between_retries seconds between one attempt and the following one (both variables are for the time being hardcoded in the function).
Returns:None if wait_for_death is False. True/False if the process was actually dead or after all the retries it was still alive.

Return the daemon pid, as read from the file. Return None if no pid is found (or the pid is not valid).


This is the actual call that kills the daemon.

There are some print statements inside, but no sys.exit, so it is safe to be called from other parts of the code.


Return True if the user is the current daemon user, False otherwise.