Modules related to the configuration of an AiiDA instance.
aiida.manage.configuration.
Config
Bases: object
object
Object that represents the configuration file of an AiiDA instance.
KEY_DEFAULT_PROFILE
KEY_OPTIONS
KEY_PROFILES
KEY_VERSION
KEY_VERSION_CURRENT
KEY_VERSION_OLDEST_COMPATIBLE
__dict__
__eq__
Two configurations are considered equal, when their dictionaries are equal.
__hash__
__init__
Instantiate a configuration object from a configuration dictionary and its filepath.
If an empty dictionary is passed, the constructor will create the skeleton configuration dictionary.
filepath – the absolute filepath of the configuration file
config – the content of the configuration file in dictionary form
__module__
__ne__
Two configurations are considered unequal, when their dictionaries are unequal.
__weakref__
list of weak references to the object (if defined)
_backup
Create a backup of the configuration file with the given filepath.
filepath – absolute path to the configuration file to backup
the absolute path of the created backup
_write
Write the contents of self.dictionary to the given file handle.
filelike – the filelike object to write the current configuration to
add_profile
Add a profile to the configuration.
profile – the profile configuration dictionary
self
current_profile
Return the currently loaded profile.
the current profile or None if not defined
default_profile_name
Return the default profile name.
the default profile name or None if not defined
dictionary
Return the dictionary representation of the config as it would be written to file.
dictionary representation of config as it should be written to file
dirpath
filepath
from_file
Instantiate a configuration object from the contents of a given file.
Note
if the filepath does not exist an empty file will be created with the current default configuration and will be written to disk. If the filepath does already exist but contains a configuration with an outdated schema, the content will be migrated and then written to disk.
filepath – the absolute path to the configuration file
Config instance
get_option
Get a configuration option for a certain scope.
option_name – the name of the configuration option
scope – get the option for this profile or globally if not specified
default – boolean, If True will return the option default, even if not defined within the given scope
the option value or None if not set for the given scope
get_profile
Return the profile for the given name or the default one if not specified.
the profile instance or None if it does not exist
aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
handle_invalid
Handle an incoming invalid configuration dictionary.
The current content of the configuration file will be written to a backup file.
message – a string message to echo with describing the infraction
options
profile_names
Return the list of profile names.
list of profile names
profiles
Return the list of profiles.
the profiles
list of Profile instances
remove_profile
Remove a profile from the configuration.
name – the name of the profile to remove
aiida.common.ProfileConfigurationError – if the given profile does not exist
set_default_profile
Set the given profile as the new default.
name – name of the profile to set as new default
overwrite – when True, set the profile as the new default even if a default profile is already defined
set_option
Set a configuration option for a certain scope.
option_value – the option value
scope – set the option for this profile or globally if not specified
override – boolean, if False, will not override the option if it already exists
store
Write the current config to file.
if the configuration file already exists on disk and its contents differ from those in memory, a backup of the original file on disk will be created before overwriting it.
unset_option
Unset a configuration option for a certain scope.
scope – unset the option for this profile or globally if not specified
update_profile
Update a profile in the configuration.
profile – the profile instance to update
validate_profile
Validate that a profile exists.
name – name of the profile:
version
version_oldest_compatible
version_settings
Return a configuration option.configuration
the configuration option
ValueError – if the configuration option does not exist
get_option_names
Return a list of available option names.
list of available option names
parse_option
Parse and validate a value for a configuration option.
a tuple of the option and the parsed value
Profile
Class that models a profile as it is stored in the configuration file of an AiiDA instance.
KEY_DATABASE_BACKEND
KEY_DATABASE_ENGINE
KEY_DATABASE_HOSTNAME
KEY_DATABASE_NAME
KEY_DATABASE_PASSWORD
KEY_DATABASE_PORT
KEY_DATABASE_USERNAME
KEY_DEFAULT_USER
KEY_REPOSITORY_URI
KEY_UUID
RMQ_PREFIX
Initialize self. See help(type(self)) for accurate signature.
_map_config_to_internal
_parse_repository_uri
This function validates the REPOSITORY_URI, that should be in the format protocol://address
At the moment, only the file protocol is supported.
a tuple (protocol, address).
configure_repository
Validates the configured repository and in the case of a file system repo makes sure the folder exists.
contains_unknown_keys
Return whether the profile dictionary contains any unsupported keys.
dictionary – a profile dictionary
boolean, True when the dictionay contains unsupported keys
database_backend
database_engine
database_hostname
database_name
database_password
database_port
database_username
default_user
Return the profile attributes as a dictionary with keys as it is stored in the config
the profile configuration dictionary
filepaths
Return the filepaths used by this profile.
a dictionary of filepaths
is_test_profile
Return whether the profile is a test profile
boolean, True if test profile, False otherwise
name
Return the profile name.
the profile name
repository_path
Return the absolute path of the repository configured for this profile.
absolute filepath of the profile’s file repository
repository_uri
rmq_prefix
Return the prefix that should be used for RMQ resources
the rmq prefix string
option_key – the key of the configuration option
uuid
Return the profile uuid.
string UUID
get_config
Return the current configuration.
the configuration is loaded using load_config
load_config
the global CONFIG variable is set
the configuration object is returned
Note: This function will except if no configuration file can be found. Only call this function, if you need information from the configuration file.
create (bool) – if True, will create the configuration file if it does not already exist
the config
aiida.common.ConfigurationError – if the configuration file could not be found, read or deserialized
get_config_option
Return the value for the given configuration option.
This function will attempt to load the value of the option as defined for the current profile or otherwise as defined configuration wide. If no configuration is yet loaded, this function will fall back on the default that may be defined for the option itself. This is useful for options that need to be defined at loading time of AiiDA when no configuration is yet loaded or may not even yet exist. In cases where one expects a profile to be loaded, preference should be given to retrieving the option through the Config instance and its get_option method.
option_name (str) – the name of the configuration option
option value as specified for the profile/configuration if loaded, otherwise option default
get_config_path
Returns path to .aiida configuration directory.
load_profile
Load a profile.
if a profile is already loaded and no explicit profile is specified, nothing will be done
profile (str) – the name of the profile to load, by default will use the one marked as default in the config
the loaded Profile instance
aiida.common.exceptions.InvalidOperation – if the backend of another profile has already been loaded
reset_config
Reset the globally loaded config.
Warning
This is experimental functionality and should for now be used only internally. If the reset is unclean weird unknown side-effects may occur that end up corrupting or destroying data.
Module that defines the configuration file of an AiiDA instance and functions to create and load it.
aiida.manage.configuration.config.
Definition of known configuration options and methods to parse and get option values.
aiida.manage.configuration.options.
AiiDA profile related code
aiida.manage.configuration.profile.
Base settings required for the configuration of an AiiDA instance.
aiida.manage.configuration.settings.
create_directory
Attempt to create the configuration folder at the given path skipping if it already exists
path – an absolute path to create a directory at
create_instance_directories
Create the base directories required for a new AiiDA instance.
This will create the base AiiDA directory defined by the AIIDA_CONFIG_FOLDER variable, unless it already exists. Subsequently, it will create the daemon directory within it and the daemon log directory.
set_configuration_directory
Determine the location of the configuration directory and set the related global variables.
The location of the configuration folder will be determined and optionally created following these heuristics:
If the AIIDA_PATH variable is set, all the paths will be checked to see if they contain a configuration folder. The first one to be encountered will be set as AIIDA_CONFIG_FOLDER. If none of them contain one, a configuration folder will be created in the last path considered. If the AIIDA_PATH variable is not set the DEFAULT_AIIDA_PATH value will be used as base path and if it does not yet contain a configuration folder, one will be created.
If the AIIDA_PATH variable is set, all the paths will be checked to see if they contain a configuration folder. The first one to be encountered will be set as AIIDA_CONFIG_FOLDER. If none of them contain one, a configuration folder will be created in the last path considered.
If the AIIDA_PATH variable is not set the DEFAULT_AIIDA_PATH value will be used as base path and if it does not yet contain a configuration folder, one will be created.
In principle then, a configuration folder should always be found or automatically created.
Module that defines methods required to setup a new AiiDA instance.
aiida.manage.configuration.setup.
delete_db
Delete an AiiDA database associated with an AiiDA profile.
profile (aiida.manage.configuration.profile.Profile) – AiiDA Profile
aiida.manage.configuration.profile.Profile
non_interactive (bool) – do not prompt for configuration values, fail if not all values are given as kwargs.
verbose (bool) – if True, print parameters of DB connection
delete_from_config
Delete an AiiDA profile from the config file.
delete_profile
Delete an AiiDA profile and AiiDA user.
profile (aiida.manage.configuration.profile.Profile) – AiiDA profile
non_interactive – do not prompt for configuration values, fail if not all values are given as kwargs.
include_db (bool) – Include deletion of associated database
include_repository (bool) – Include deletion of associated file repository
include_config (bool) – Include deletion of entry from AiiDA configuration file
delete_repository
Delete an AiiDA file repository associated with an AiiDA profile.