Storage#
Each AiiDA profile defines a storage which is where all data in the provenance graph is stored. Typically, a storage consists of a database and a repository. The provenance graph data itself is mostly persisted to the database, whereas files attached to nodes (or other binary content) are stored in the repository.
By default, the storage consists of a PostgreSQL database and a disk-objectstore container for the file repository. As of AiiDA 2.0, however, this storage can be customized through plugins, meaning other databases and file stores can be used if desired. AiiDA ships itself with a number of storage plugins that each have their own strengths and weaknesses. This section gives an overview of these storage plugins with suggestions of when to use them.
Note
The following features of the QueryBuilder
are known to not be supported for SQLite-based storages:
Use of
contains
infilters
The
get_creation_statistics
method
core.psql_dos
#
The core.psql_dos
storage plugin is the default and is recommended for all production work.
It uses PostgreSQL for the database and the disk-objectstore for the file repository.
To create a profile using this storage plugin, run:
verdi profile setup core.psql_dos
The command requires the PostgreSQL database to already exist and to be able to connect to it.
Tip
Try the verdi quicksetup
command to have the PostgreSQL database automatically created.
Certain systems require root access to do so, causing the command to fail if it cannot obtain root access.
In this case, the database should be created manually (see Creating the database for details).
Once created, a profile can be created using the database with the command verdi profile setup core.psql_dos
.
core.sqlite_dos
#
The core.sqlite_dos
storage plugin is an alternative to the core.psql_dos
storage for use cases where performance is not critical.
Instead of a PostgreSQL database, it uses SQLite.
This makes it easier to set up as it does not require a running service, as the SQLite database is just a file on disk.
A fully operational profile using this storage plugin can be created with a single command:
verdi profile setup core.sqlite_dos -n --profile <PROFILE_NAME> --email <EMAIL>
replacing <PROFILE_NAME>
with the desired name for the profile and <EMAIL>
with the email for the default user.
The SQLite database and disk-objectstore container are both stored in the directory specified by the --filepath
option of the verdi profile setup core.sqlite_dos
command.
By default, this is a folder inside the directory defined by the $AIIDA_PATH/repository
of the form sqlite_dos_{UUID}
, where the suffix is randomly generated hexadecimal UUID.
An example of an automated generated directory is .aiida/repository/sqlite_dos_962e87af09b746c985335cb77acaa553
.
Note
The $AIIDA_PATH
environment variable determines the location of the configuration directory, and defaults to .aiida
in the user’s home folder
core.sqlite_zip
#
The core.sqlite_zip
is a storage plugin that is used to create export archives.
It functions more or less identical to the core.sqlite_dos
plugin, as it uses an SQLite database and a disk-objectstore container, except everything is bundled up in a zip archive.
The storage plugin is not suited for normal use, because once the archive is created, it becomes read-only. However, since otherwise it functions like normal storage plugins, a profile can be created with it that make it easy to explore its contents:
verdi profile setup core.sqlite_zip -n --profile <PROFILE_NAME> --filepath <ARCHIVE>
replacing <PROFILE_NAME>
with the desired name for the profile and <ARCHIVE>
the path to the archive file.
The created profile can now be loaded like any other profile, and the contents of the provenance graph can be explored as usual.
core.sqlite_temp
#
The core.sqlite_temp
storage plugin utilises an in-memory SQLite database and sandbox folder to store data.
The data is automatically destroyed as soon as the profile is garbage collected, which is either when it is unloaded, or the Python interpreter is shut down.
This makes this storage plugin primarily useful for demonstration and testing purposes, whereby no persistent storage is required.
A new temporary profile can be created and loaded as follows:
from aiida import load_profile
from aiida.storage.sqlite_temp import SqliteTempBackend
temp_profile = SqliteTempBackend.create_profile('temp-profile')
load_profile(temp_profile, allow_switch=True)