User facing APIs to control AiiDA from the verdi cli, scripts or plugins
Connect to an existing PostgreSQL cluster as the postgres superuser and execute SQL commands.
separate package that can then be tested on multiple OS / postgres setups. Therefore, please keep this
module entirely AiiDA-agnostic.
Provides an API for postgres database maintenance tasks.
This API creates and drops postgres users and databases used by the
verdi quicksetup commandline tool. It allows convenient access to this
functionality from within python without knowing details about how postgres is
installed by default on various systems. If the postgres setup is not the
default installation, additional information needs to be provided.
Adds convenience functions to pgsu.PGSU.
postgres = Postgres()
if not postgres.db_exists('dbname'):
See documentation of pgsu.PGSU.__init__().
Looks up if a database with the name exists, prompts for using or creating a differently named one.
dbname (str) – Name of the database to be created or reused.
tuple (dbname, created)
Looks up if a given user already exists, prompts for using or creating a differently named one.
dbuser (str) – Name of the user to be created or reused.
tuple (dbuser, created)
Create a database in postgres
dbuser (str) – Name of the user which should own the db.
dbname (str) – Name of the database.
Create a database user in postgres
dbuser (str) – Name of the user to be created.
dbpass (str) – Password the user should be given.
psycopg2.errors.DuplicateObject if user already exists and
self.connection_mode == PostgresConnectionMode.PSYCOPG
Create DB and user + grant privileges.
Prompts when reusing existing users / databases.
Check wether a postgres database with dbname exists
dbname (str) – Name of the database to check for
(bool), True if database exists, False otherwise
Alias for Postgres.dsn.
Find out if postgres user with name dbuser exists
dbuser (str) – database user to check for
(bool) True if user exists, False otherwise
Drop a database in postgres
Drop a database user in postgres
dbuser (str) – Name of the user to be dropped.
Create Postgres instance with dbinfo from AiiDA profile data.
profile – AiiDA profile instance
kwargs – keyword arguments forwarded to PGSU constructor
Postgres instance pre-populated with data from AiiDA profile
Return correct host for psycopg2 connection (as required by regular AiiDA operation).
Return port for psycopg2 connection (as required by regular AiiDA operation).
Describe mode of connecting to postgres.
Components to communicate tasks to RabbitMQ.
alias of concurrent.futures._base.TimeoutError
Failed to deliver a message
list of weak references to the object (if defined)
A sub class of plumpy.ProcessLauncher to launch a Process.
It overrides the _continue method to make sure the node corresponding to the task can be loaded and
that if it is already marked as terminated, it is not continued but the future is reconstructed and returned
Continue the task.
Note that the task may already have been completed, as indicated from the corresponding the node, in which
case it is not continued, but the corresponding future is reconstructed and returned. This scenario may
occur when the Process was already completed by another worker that however failed to send the acknowledgment.
communicator – the communicator that called this method
pid – the pid of the process to continue
nowait – if True don’t wait for the process to finish, just return the pid, otherwise wait and
return the results
tag – the tag of the checkpoint to continue from
Handle exception raised in _continue call.
If the process state of the node has not yet been put to excepted, the exception was raised before the process
instance could be reconstructed, for example when the process class could not be loaded, thereby circumventing
the exception handling of the state machine. Raising this exception will then acknowledge the process task with
RabbitMQ leaving an uncleaned node in the CREATED state for ever. Therefore we have to perform the node
exception – the exception object
message – string message to use for the log message
An exception occurred at the remote end of the call