aiida.manage.configuration package¶
Modules related to the configuration of an AiiDA instance.
-
class
aiida.manage.configuration.
Config
(filepath, dictionary)[source]¶ Bases:
object
Object that represents the configuration file of an AiiDA instance.
-
KEY_DEFAULT_PROFILE
= 'default_profile'¶
-
KEY_PROFILES
= 'profiles'¶
-
KEY_VERSION
= 'CONFIG_VERSION'¶
-
KEY_VERSION_CURRENT
= 'CURRENT'¶
-
KEY_VERSION_OLDEST_COMPATIBLE
= 'OLDEST_COMPATIBLE'¶
-
__dict__
= dict_proxy({'KEY_VERSION_CURRENT': 'CURRENT', '__module__': 'aiida.manage.configuration.config', 'update_profile': <function update_profile>, 'KEY_VERSION_OLDEST_COMPATIBLE': 'OLDEST_COMPATIBLE', 'option_unset': <function option_unset>, '_version_settings': <property object>, 'profiles': <property object>, 'dirpath': <property object>, '__dict__': <attribute '__dict__' of 'Config' objects>, 'validate_profile': <function validate_profile>, '__init__': <function __init__>, 'KEY_VERSION': 'CONFIG_VERSION', 'remove_profile': <function remove_profile>, 'get_profile': <function get_profile>, 'filepath': <property object>, 'default_profile_name': <property object>, 'KEY_DEFAULT_PROFILE': 'default_profile', 'option_get': <function option_get>, 'version': <property object>, 'option_set': <function option_set>, '__doc__': 'Object that represents the configuration file of an AiiDA instance.', 'store': <function store>, 'set_default_profile': <function set_default_profile>, '__ne__': <function __ne__>, 'dictionary': <property object>, '__eq__': <function __eq__>, '__weakref__': <attribute '__weakref__' of 'Config' objects>, 'add_profile': <function add_profile>, 'version_oldest_compatible': <property object>, 'profile_names': <property object>, 'KEY_PROFILES': 'profiles', 'current_profile': <property object>, '_get_profile_dictionary': <function _get_profile_dictionary>, '_backup': <function _backup>})¶
-
__init__
(filepath, dictionary)[source]¶ 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.
Parameters: - filepath – the absolute filepath of the configuration file
- dictionary – the content of the configuration file in dictionary form
-
__module__
= 'aiida.manage.configuration.config'¶
-
__ne__
(other)[source]¶ Two configurations are considered unequal, when their dictionaries are unequal.
-
__weakref__
¶ list of weak references to the object (if defined)
-
_get_profile_dictionary
(name)[source]¶ Return the internal profile dictionary for the given name or the default one if not specified.
Returns: the profile instance or None if it does not exist Raises: aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
-
_version_settings
¶
-
add_profile
(name, profile)[source]¶ Add a profile to the configuration.
Parameters: - name – the name of the profile to remove
- profile – the profile configuration dictionary
Returns: self
-
current_profile
¶ Return the currently loaded profile.
Returns: the current profile or None if not defined
-
default_profile_name
¶ Return the default profile name.
Returns: the default profile name or None if not defined
-
dictionary
¶
-
dirpath
¶
-
filepath
¶
-
get_profile
(name=None)[source]¶ Return the profile for the given name or the default one if not specified.
Returns: the profile instance or None if it does not exist Raises: aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
-
option_get
(option_name, scope=None, default=True)[source]¶ Get a configuration option.
Parameters: - 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
Returns: the option value or None if not set for the given scope
-
option_set
(option_name, option_value, scope=None)[source]¶ Set a configuration option.
Parameters: - option_name – the name of the configuration option
- option_value – the option value
- scope – set the option for this profile or globally if not specified
-
option_unset
(option_name, scope=None)[source]¶ Unset a configuration option.
Parameters: - option_name – the name of the configuration option
- scope – unset the option for this profile or globally if not specified
-
profile_names
¶ Return the list of profile names.
Returns: list of profile names
-
profiles
¶ Return the list of profiles.
Returns: the profiles Return type: list of Profile instances
-
remove_profile
(name)[source]¶ Remove a profile from the configuration.
Parameters: name – the name of the profile to remove Raises: aiida.common.ProfileConfigurationError – if the given profile does not exist Returns: self
-
set_default_profile
(name, overwrite=False)[source]¶ Set the given profile as the new default.
Parameters: - 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
Raises: aiida.common.ProfileConfigurationError – if the given profile does not exist
Returns: self
-
update_profile
(profile)[source]¶ Update a profile in the configuration.
Parameters: profile – the profile instance to update Returns: self
-
validate_profile
(name)[source]¶ Validate that a profile exists.
Parameters: name – name of the profile: Raises: aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
-
version
¶
-
version_oldest_compatible
¶
-
-
aiida.manage.configuration.
get_option
(option_name)[source]¶ Return a configuration option.configuration
Parameters: option_name – the name of the configuration option Returns: the configuration option Raises: ValueError – if the configuration option does not exist
-
aiida.manage.configuration.
get_option_names
()[source]¶ Return a list of available option names.
Returns: list of available option names
-
aiida.manage.configuration.
parse_option
(option_name, option_value)[source]¶ Parse and validate a value for a configuration option.
Parameters: - option_name – the name of the configuration option
- option_value – the option value
Returns: a tuple of the option and the parsed value
-
class
aiida.manage.configuration.
Profile
(name, dictionary)[source]¶ Bases:
object
Convenience class that loads the current profile name and corresponding configuration and can subsequently provide profile specific information
-
KEY_DEFAULT_USER
= 'default_user_email'¶
-
KEY_PROFILE_UUID
= 'PROFILE_UUID'¶
-
RMQ_PREFIX
= 'aiida-{uuid}'¶
-
__dict__
= dict_proxy({'RMQ_PREFIX': 'aiida-{uuid}', '__module__': 'aiida.manage.configuration.profile', 'KEY_DEFAULT_USER': 'default_user_email', 'name': <property object>, 'dictionary': <property object>, 'rmq_prefix': <property object>, 'KEY_PROFILE_UUID': 'PROFILE_UUID', 'generate_uuid': <staticmethod object>, 'is_test_profile': <property object>, '__dict__': <attribute '__dict__' of 'Profile' objects>, 'filepaths': <property object>, 'default_user_email': <property object>, '__weakref__': <attribute '__weakref__' of 'Profile' objects>, '__doc__': '\n Convenience class that loads the current profile name and corresponding configuration and\n can subsequently provide profile specific information\n ', '__init__': <function __init__>, 'uuid': <property object>})¶
-
__module__
= 'aiida.manage.configuration.profile'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
default_user_email
¶ Return the email (that is used as the username) configured during the first verdi setup.
Returns: the currently configured user email address or None if not defined Return type: str or None
-
dictionary
¶ Get the profile configuration dictionary
Returns: the profile configuration Return type: dict
-
filepaths
¶ Get the filepaths used by this profile
Returns: a dictionary of filepaths Return type: dict
-
static
generate_uuid
()[source]¶ Return a UUID for a new profile
Returns: the hexadecimal represenation of a uuid4 UUID
-
is_test_profile
¶ Is this a test profile
Returns: True if test profile, False otherwise Return type: bool
-
name
¶ Get the profile name
Returns: the profile name Return type: str
-
rmq_prefix
¶ Get the RMQ prefix
Returns: the rmq prefix string Return type: str
-
uuid
¶ Get the UUID of this profile
Returns: the profile UUID
-
-
aiida.manage.configuration.
load_config
(create=False)[source]¶ Instantiate the Config object representing the configuration file of the current AiiDA instance.
Parameters: create – when set to True, will create the configuration file if it does not already exist Returns: the config Return type: Config
Raises: aiida.common.MissingConfigurationError – if the configuration file could not be found and create=False
-
aiida.manage.configuration.
get_config
()[source]¶ Return the current configuration.
If the configuration has not been loaded yet, it will be loaded first and then returned.
Note: this function should only be called by parts of the code that expect that a complete AiiDA instance exists, i.e. an AiiDA folder exists and contains a valid configuration file.
Returns: the config Return type: Config
Raises: aiida.common.ConfigurationError – if the configuration file could not be found, read or deserialized
-
aiida.manage.configuration.
get_config_option
(option_name)[source]¶ 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 option_get method.
Parameters: option_name – the name of the configuration option Returns: option value as specified for the profile/configuration if loaded, otherwise option default
Submodules¶
Module that defines the configuration file of an AiiDA instance and functions to create and load it.
-
class
aiida.manage.configuration.config.
Config
(filepath, dictionary)[source]¶ Bases:
object
Object that represents the configuration file of an AiiDA instance.
-
KEY_DEFAULT_PROFILE
= 'default_profile'¶
-
KEY_PROFILES
= 'profiles'¶
-
KEY_VERSION
= 'CONFIG_VERSION'¶
-
KEY_VERSION_CURRENT
= 'CURRENT'¶
-
KEY_VERSION_OLDEST_COMPATIBLE
= 'OLDEST_COMPATIBLE'¶
-
__dict__
= dict_proxy({'KEY_VERSION_CURRENT': 'CURRENT', '__module__': 'aiida.manage.configuration.config', 'update_profile': <function update_profile>, 'KEY_VERSION_OLDEST_COMPATIBLE': 'OLDEST_COMPATIBLE', 'option_unset': <function option_unset>, '_version_settings': <property object>, 'profiles': <property object>, 'dirpath': <property object>, '__dict__': <attribute '__dict__' of 'Config' objects>, 'validate_profile': <function validate_profile>, '__init__': <function __init__>, 'KEY_VERSION': 'CONFIG_VERSION', 'remove_profile': <function remove_profile>, 'get_profile': <function get_profile>, 'filepath': <property object>, 'default_profile_name': <property object>, 'KEY_DEFAULT_PROFILE': 'default_profile', 'option_get': <function option_get>, 'version': <property object>, 'option_set': <function option_set>, '__doc__': 'Object that represents the configuration file of an AiiDA instance.', 'store': <function store>, 'set_default_profile': <function set_default_profile>, '__ne__': <function __ne__>, 'dictionary': <property object>, '__eq__': <function __eq__>, '__weakref__': <attribute '__weakref__' of 'Config' objects>, 'add_profile': <function add_profile>, 'version_oldest_compatible': <property object>, 'profile_names': <property object>, 'KEY_PROFILES': 'profiles', 'current_profile': <property object>, '_get_profile_dictionary': <function _get_profile_dictionary>, '_backup': <function _backup>})¶
-
__init__
(filepath, dictionary)[source]¶ 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.
Parameters: - filepath – the absolute filepath of the configuration file
- dictionary – the content of the configuration file in dictionary form
-
__module__
= 'aiida.manage.configuration.config'¶
-
__ne__
(other)[source]¶ Two configurations are considered unequal, when their dictionaries are unequal.
-
__weakref__
¶ list of weak references to the object (if defined)
-
_get_profile_dictionary
(name)[source]¶ Return the internal profile dictionary for the given name or the default one if not specified.
Returns: the profile instance or None if it does not exist Raises: aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
-
_version_settings
¶
-
add_profile
(name, profile)[source]¶ Add a profile to the configuration.
Parameters: - name – the name of the profile to remove
- profile – the profile configuration dictionary
Returns: self
-
current_profile
¶ Return the currently loaded profile.
Returns: the current profile or None if not defined
-
default_profile_name
¶ Return the default profile name.
Returns: the default profile name or None if not defined
-
dictionary
¶
-
dirpath
¶
-
filepath
¶
-
get_profile
(name=None)[source]¶ Return the profile for the given name or the default one if not specified.
Returns: the profile instance or None if it does not exist Raises: aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
-
option_get
(option_name, scope=None, default=True)[source]¶ Get a configuration option.
Parameters: - 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
Returns: the option value or None if not set for the given scope
-
option_set
(option_name, option_value, scope=None)[source]¶ Set a configuration option.
Parameters: - option_name – the name of the configuration option
- option_value – the option value
- scope – set the option for this profile or globally if not specified
-
option_unset
(option_name, scope=None)[source]¶ Unset a configuration option.
Parameters: - option_name – the name of the configuration option
- scope – unset the option for this profile or globally if not specified
-
profile_names
¶ Return the list of profile names.
Returns: list of profile names
-
profiles
¶ Return the list of profiles.
Returns: the profiles Return type: list of Profile instances
-
remove_profile
(name)[source]¶ Remove a profile from the configuration.
Parameters: name – the name of the profile to remove Raises: aiida.common.ProfileConfigurationError – if the given profile does not exist Returns: self
-
set_default_profile
(name, overwrite=False)[source]¶ Set the given profile as the new default.
Parameters: - 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
Raises: aiida.common.ProfileConfigurationError – if the given profile does not exist
Returns: self
-
update_profile
(profile)[source]¶ Update a profile in the configuration.
Parameters: profile – the profile instance to update Returns: self
-
validate_profile
(name)[source]¶ Validate that a profile exists.
Parameters: name – name of the profile: Raises: aiida.common.ProfileConfigurationError – if the name is not found in the configuration file
-
version
¶
-
version_oldest_compatible
¶
-
Definition of known configuration options and methods to parse and get option values.
-
aiida.manage.configuration.options.
get_option
(option_name)[source]¶ Return a configuration option.configuration
Parameters: option_name – the name of the configuration option Returns: the configuration option Raises: ValueError – if the configuration option does not exist
-
aiida.manage.configuration.options.
get_option_names
()[source]¶ Return a list of available option names.
Returns: list of available option names
-
aiida.manage.configuration.options.
parse_option
(option_name, option_value)[source]¶ Parse and validate a value for a configuration option.
Parameters: - option_name – the name of the configuration option
- option_value – the option value
Returns: a tuple of the option and the parsed value
AiiDA profile related code
-
class
aiida.manage.configuration.profile.
Profile
(name, dictionary)[source]¶ Bases:
object
Convenience class that loads the current profile name and corresponding configuration and can subsequently provide profile specific information
-
KEY_DEFAULT_USER
= 'default_user_email'¶
-
KEY_PROFILE_UUID
= 'PROFILE_UUID'¶
-
RMQ_PREFIX
= 'aiida-{uuid}'¶
-
__dict__
= dict_proxy({'RMQ_PREFIX': 'aiida-{uuid}', '__module__': 'aiida.manage.configuration.profile', 'KEY_DEFAULT_USER': 'default_user_email', 'name': <property object>, 'dictionary': <property object>, 'rmq_prefix': <property object>, 'KEY_PROFILE_UUID': 'PROFILE_UUID', 'generate_uuid': <staticmethod object>, 'is_test_profile': <property object>, '__dict__': <attribute '__dict__' of 'Profile' objects>, 'filepaths': <property object>, 'default_user_email': <property object>, '__weakref__': <attribute '__weakref__' of 'Profile' objects>, '__doc__': '\n Convenience class that loads the current profile name and corresponding configuration and\n can subsequently provide profile specific information\n ', '__init__': <function __init__>, 'uuid': <property object>})¶
-
__module__
= 'aiida.manage.configuration.profile'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
default_user_email
¶ Return the email (that is used as the username) configured during the first verdi setup.
Returns: the currently configured user email address or None if not defined Return type: str or None
-
dictionary
¶ Get the profile configuration dictionary
Returns: the profile configuration Return type: dict
-
filepaths
¶ Get the filepaths used by this profile
Returns: a dictionary of filepaths Return type: dict
-
static
generate_uuid
()[source]¶ Return a UUID for a new profile
Returns: the hexadecimal represenation of a uuid4 UUID
-
is_test_profile
¶ Is this a test profile
Returns: True if test profile, False otherwise Return type: bool
-
name
¶ Get the profile name
Returns: the profile name Return type: str
-
rmq_prefix
¶ Get the RMQ prefix
Returns: the rmq prefix string Return type: str
-
uuid
¶ Get the UUID of this profile
Returns: the profile UUID
-
Base settings required for the configuration of an AiiDA instance.
Module that defines methods required to setup a new AiiDA instance.
-
aiida.manage.configuration.setup.
create_instance_directories
()[source]¶ 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.
-
aiida.manage.configuration.setup.
delete_db
(profile, non_interactive=True, verbose=False)[source]¶ Delete an AiiDA database associated with an AiiDA profile.
Parameters: - profile (
aiida.manage.configuration.profile.Profile
) – AiiDA 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
- profile (
-
aiida.manage.configuration.setup.
delete_from_config
(profile, non_interactive=True)[source]¶ Delete an AiiDA profile from the config file.
Parameters: - profile (
aiida.manage.configuration.profile.Profile
) – AiiDA Profile - non_interactive (bool) – do not prompt for configuration values, fail if not all values are given as kwargs.
- profile (
-
aiida.manage.configuration.setup.
delete_profile
(profile, non_interactive=True, include_db=True, include_repository=True, include_config=True)[source]¶ Delete an AiiDA profile and AiiDA user.
Parameters: - 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
- profile (
-
aiida.manage.configuration.setup.
delete_repository
(profile, non_interactive=True)[source]¶ Delete an AiiDA file repository associated with an AiiDA profile.
Parameters: - profile (
aiida.manage.configuration.profile.Profile
) – AiiDA Profile - non_interactive (bool) – do not prompt for configuration values, fail if not all values are given as kwargs.
- profile (
-
aiida.manage.configuration.setup.
setup_profile
(profile_name, only_config, set_default=False, non_interactive=False, **kwargs)[source]¶ Setup an AiiDA profile and AiiDA user (and the AiiDA default user).
Parameters: - profile_name – Profile name
- only_config – do not create a new user
- set_default – set the new profile as the default
- non_interactive – do not prompt for configuration values, fail if not all values are given as kwargs.
- backend – one of ‘django’, ‘sqlalchemy’
- email – valid email address for the user
- db_host – hostname for the database
- db_port – port to connect to the database
- db_user – name of the db user
- db_pass – password of the db user
Definition of known configuration options and methods to parse and get option values.
-
aiida.manage.configuration.utils.
load_config
(create=False)[source]¶ Instantiate the Config object representing the configuration file of the current AiiDA instance.
Parameters: create – when set to True, will create the configuration file if it does not already exist Returns: the config Return type: Config
Raises: aiida.common.MissingConfigurationError – if the configuration file could not be found and create=False