aiida.manage package#
Managing an AiiDA instance:
configuration file
profiles
databases
repositories
external components (such as Postgres, RabbitMQ)
Note
Modules in this sub package may require the database environment to be loaded
Subpackages#
- aiida.manage.configuration package
_merge_deprecated_cache_yaml()
create_default_user()
create_profile()
get_config()
get_config_option()
get_config_path()
get_profile()
load_config()
load_profile()
profile_context()
reset_config()
- Subpackages
- Submodules
Config
Config.KEY_DEFAULT_PROFILE
Config.KEY_OPTIONS
Config.KEY_PROFILES
Config.KEY_SCHEMA
Config.KEY_VERSION
Config.KEY_VERSION_CURRENT
Config.KEY_VERSION_OLDEST_COMPATIBLE
Config.__dict__
Config.__eq__()
Config.__hash__
Config.__init__()
Config.__module__
Config.__ne__()
Config.__weakref__
Config._atomic_write()
Config._backup()
Config.add_profile()
Config.create_profile()
Config.default_profile_name
Config.delete_profile()
Config.dictionary
Config.dirpath
Config.filepath
Config.from_file()
Config.get_option()
Config.get_options()
Config.get_profile()
Config.handle_invalid()
Config.options
Config.profile_names
Config.profiles
Config.remove_profile()
Config.set_default_profile()
Config.set_default_user_email()
Config.set_option()
Config.store()
Config.unset_option()
Config.update_profile()
Config.validate()
Config.validate_profile()
Config.version
Config.version_oldest_compatible
Config.version_settings
ConfigSchema
ConfigSchema.CONFIG_VERSION
ConfigSchema.__abstractmethods__
ConfigSchema.__annotations__
ConfigSchema.__class_vars__
ConfigSchema.__dict__
ConfigSchema.__module__
ConfigSchema.__private_attributes__
ConfigSchema.__pydantic_complete__
ConfigSchema.__pydantic_core_schema__
ConfigSchema.__pydantic_custom_init__
ConfigSchema.__pydantic_decorators__
ConfigSchema.__pydantic_extra__
ConfigSchema.__pydantic_fields_set__
ConfigSchema.__pydantic_generic_metadata__
ConfigSchema.__pydantic_parent_namespace__
ConfigSchema.__pydantic_post_init__
ConfigSchema.__pydantic_private__
ConfigSchema.__pydantic_serializer__
ConfigSchema.__pydantic_validator__
ConfigSchema.__signature__
ConfigSchema.__weakref__
ConfigSchema._abc_impl
ConfigSchema.default_profile
ConfigSchema.model_computed_fields
ConfigSchema.model_config
ConfigSchema.model_fields
ConfigSchema.options
ConfigSchema.profiles
ConfigVersionSchema
ConfigVersionSchema.CURRENT
ConfigVersionSchema.OLDEST_COMPATIBLE
ConfigVersionSchema.__abstractmethods__
ConfigVersionSchema.__annotations__
ConfigVersionSchema.__class_vars__
ConfigVersionSchema.__dict__
ConfigVersionSchema.__module__
ConfigVersionSchema.__private_attributes__
ConfigVersionSchema.__pydantic_complete__
ConfigVersionSchema.__pydantic_core_schema__
ConfigVersionSchema.__pydantic_custom_init__
ConfigVersionSchema.__pydantic_decorators__
ConfigVersionSchema.__pydantic_extra__
ConfigVersionSchema.__pydantic_fields_set__
ConfigVersionSchema.__pydantic_generic_metadata__
ConfigVersionSchema.__pydantic_parent_namespace__
ConfigVersionSchema.__pydantic_post_init__
ConfigVersionSchema.__pydantic_private__
ConfigVersionSchema.__pydantic_serializer__
ConfigVersionSchema.__pydantic_validator__
ConfigVersionSchema.__weakref__
ConfigVersionSchema._abc_impl
ConfigVersionSchema.model_computed_fields
ConfigVersionSchema.model_config
ConfigVersionSchema.model_fields
GlobalOptionsSchema
GlobalOptionsSchema.__abstractmethods__
GlobalOptionsSchema.__annotations__
GlobalOptionsSchema.__class_vars__
GlobalOptionsSchema.__dict__
GlobalOptionsSchema.__module__
GlobalOptionsSchema.__private_attributes__
GlobalOptionsSchema.__pydantic_complete__
GlobalOptionsSchema.__pydantic_core_schema__
GlobalOptionsSchema.__pydantic_custom_init__
GlobalOptionsSchema.__pydantic_decorators__
GlobalOptionsSchema.__pydantic_extra__
GlobalOptionsSchema.__pydantic_fields_set__
GlobalOptionsSchema.__pydantic_generic_metadata__
GlobalOptionsSchema.__pydantic_parent_namespace__
GlobalOptionsSchema.__pydantic_post_init__
GlobalOptionsSchema.__pydantic_private__
GlobalOptionsSchema.__pydantic_serializer__
GlobalOptionsSchema.__pydantic_validator__
GlobalOptionsSchema.__signature__
GlobalOptionsSchema._abc_impl
GlobalOptionsSchema.autofill__user__email
GlobalOptionsSchema.autofill__user__first_name
GlobalOptionsSchema.autofill__user__institution
GlobalOptionsSchema.autofill__user__last_name
GlobalOptionsSchema.model_computed_fields
GlobalOptionsSchema.model_config
GlobalOptionsSchema.model_fields
GlobalOptionsSchema.rest_api__profile_switching
GlobalOptionsSchema.warnings__development_version
ProcessControlConfig
ProcessControlConfig.__abstractmethods__
ProcessControlConfig.__annotations__
ProcessControlConfig.__class_vars__
ProcessControlConfig.__dict__
ProcessControlConfig.__module__
ProcessControlConfig.__private_attributes__
ProcessControlConfig.__pydantic_complete__
ProcessControlConfig.__pydantic_core_schema__
ProcessControlConfig.__pydantic_custom_init__
ProcessControlConfig.__pydantic_decorators__
ProcessControlConfig.__pydantic_extra__
ProcessControlConfig.__pydantic_fields_set__
ProcessControlConfig.__pydantic_generic_metadata__
ProcessControlConfig.__pydantic_parent_namespace__
ProcessControlConfig.__pydantic_post_init__
ProcessControlConfig.__pydantic_private__
ProcessControlConfig.__pydantic_serializer__
ProcessControlConfig.__pydantic_validator__
ProcessControlConfig.__weakref__
ProcessControlConfig._abc_impl
ProcessControlConfig.broker_host
ProcessControlConfig.broker_parameters
ProcessControlConfig.broker_password
ProcessControlConfig.broker_port
ProcessControlConfig.broker_protocol
ProcessControlConfig.broker_username
ProcessControlConfig.broker_virtual_host
ProcessControlConfig.model_computed_fields
ProcessControlConfig.model_config
ProcessControlConfig.model_fields
ProfileOptionsSchema
ProfileOptionsSchema.__abstractmethods__
ProfileOptionsSchema.__annotations__
ProfileOptionsSchema.__class_vars__
ProfileOptionsSchema.__dict__
ProfileOptionsSchema.__module__
ProfileOptionsSchema.__private_attributes__
ProfileOptionsSchema.__pydantic_complete__
ProfileOptionsSchema.__pydantic_core_schema__
ProfileOptionsSchema.__pydantic_custom_init__
ProfileOptionsSchema.__pydantic_decorators__
ProfileOptionsSchema.__pydantic_extra__
ProfileOptionsSchema.__pydantic_fields_set__
ProfileOptionsSchema.__pydantic_generic_metadata__
ProfileOptionsSchema.__pydantic_parent_namespace__
ProfileOptionsSchema.__pydantic_post_init__
ProfileOptionsSchema.__pydantic_private__
ProfileOptionsSchema.__pydantic_serializer__
ProfileOptionsSchema.__pydantic_validator__
ProfileOptionsSchema.__weakref__
ProfileOptionsSchema._abc_impl
ProfileOptionsSchema.caching__default_enabled
ProfileOptionsSchema.caching__disabled_for
ProfileOptionsSchema.caching__enabled_for
ProfileOptionsSchema.daemon__default_workers
ProfileOptionsSchema.daemon__recursion_limit
ProfileOptionsSchema.daemon__timeout
ProfileOptionsSchema.daemon__worker_process_slots
ProfileOptionsSchema.db__batch_size
ProfileOptionsSchema.logging__aiida_loglevel
ProfileOptionsSchema.logging__aiopika_loglevel
ProfileOptionsSchema.logging__alembic_loglevel
ProfileOptionsSchema.logging__circus_loglevel
ProfileOptionsSchema.logging__db_loglevel
ProfileOptionsSchema.logging__disk_objectstore_loglevel
ProfileOptionsSchema.logging__kiwipy_loglevel
ProfileOptionsSchema.logging__paramiko_loglevel
ProfileOptionsSchema.logging__plumpy_loglevel
ProfileOptionsSchema.logging__sqlalchemy_loglevel
ProfileOptionsSchema.logging__verdi_loglevel
ProfileOptionsSchema.model_computed_fields
ProfileOptionsSchema.model_config
ProfileOptionsSchema.model_fields
ProfileOptionsSchema.rmq__task_timeout
ProfileOptionsSchema.runner__poll__interval
ProfileOptionsSchema.storage__sandbox
ProfileOptionsSchema.transport__task_maximum_attempts
ProfileOptionsSchema.transport__task_retry_initial_interval
ProfileOptionsSchema.validate_caching_identifier_pattern()
ProfileOptionsSchema.verdi__shell__auto_import
ProfileOptionsSchema.warnings__rabbitmq_version
ProfileOptionsSchema.warnings__showdeprecations
ProfileSchema
ProfileSchema.__abstractmethods__
ProfileSchema.__annotations__
ProfileSchema.__class_vars__
ProfileSchema.__dict__
ProfileSchema.__module__
ProfileSchema.__private_attributes__
ProfileSchema.__pydantic_complete__
ProfileSchema.__pydantic_core_schema__
ProfileSchema.__pydantic_custom_init__
ProfileSchema.__pydantic_decorators__
ProfileSchema.__pydantic_extra__
ProfileSchema.__pydantic_fields_set__
ProfileSchema.__pydantic_generic_metadata__
ProfileSchema.__pydantic_parent_namespace__
ProfileSchema.__pydantic_post_init__
ProfileSchema.__pydantic_private__
ProfileSchema.__pydantic_serializer__
ProfileSchema.__pydantic_validator__
ProfileSchema.__weakref__
ProfileSchema._abc_impl
ProfileSchema.default_user_email
ProfileSchema.model_computed_fields
ProfileSchema.model_config
ProfileSchema.model_fields
ProfileSchema.options
ProfileSchema.process_control
ProfileSchema.serialize_dt()
ProfileSchema.storage
ProfileSchema.test_profile
ProfileSchema.uuid
ProfileStorageConfig
ProfileStorageConfig.__abstractmethods__
ProfileStorageConfig.__annotations__
ProfileStorageConfig.__class_vars__
ProfileStorageConfig.__dict__
ProfileStorageConfig.__module__
ProfileStorageConfig.__private_attributes__
ProfileStorageConfig.__pydantic_complete__
ProfileStorageConfig.__pydantic_core_schema__
ProfileStorageConfig.__pydantic_custom_init__
ProfileStorageConfig.__pydantic_decorators__
ProfileStorageConfig.__pydantic_extra__
ProfileStorageConfig.__pydantic_fields_set__
ProfileStorageConfig.__pydantic_generic_metadata__
ProfileStorageConfig.__pydantic_parent_namespace__
ProfileStorageConfig.__pydantic_post_init__
ProfileStorageConfig.__pydantic_private__
ProfileStorageConfig.__pydantic_serializer__
ProfileStorageConfig.__pydantic_validator__
ProfileStorageConfig.__weakref__
ProfileStorageConfig._abc_impl
ProfileStorageConfig.backend
ProfileStorageConfig.config
ProfileStorageConfig.model_computed_fields
ProfileStorageConfig.model_config
ProfileStorageConfig.model_fields
Option
get_option()
get_option_names()
parse_option()
Profile
Profile.KEY_DEFAULT_USER_EMAIL
Profile.KEY_OPTIONS
Profile.KEY_PROCESS
Profile.KEY_PROCESS_BACKEND
Profile.KEY_PROCESS_CONFIG
Profile.KEY_STORAGE
Profile.KEY_STORAGE_BACKEND
Profile.KEY_STORAGE_CONFIG
Profile.KEY_TEST_PROFILE
Profile.KEY_UUID
Profile.REQUIRED_KEYS
Profile.__dict__
Profile.__init__()
Profile.__module__
Profile.__repr__()
Profile.__weakref__
Profile.copy()
Profile.default_user_email
Profile.dictionary
Profile.filepaths
Profile.get_option()
Profile.is_test_profile
Profile.name
Profile.options
Profile.process_control_backend
Profile.process_control_config
Profile.repository_path
Profile.set_option()
Profile.set_process_controller()
Profile.set_storage()
Profile.storage_backend
Profile.storage_cls
Profile.storage_config
Profile.unset_option()
Profile.uuid
create_instance_directories()
get_configuration_directory()
get_configuration_directory_from_envvar()
set_configuration_directory()
- aiida.manage.external package
- Submodules
Postgres
Postgres.__init__()
Postgres.__module__
Postgres.can_user_authenticate()
Postgres.copy_db()
Postgres.create_db()
Postgres.create_dbuser()
Postgres.create_dbuser_db_safe()
Postgres.db_exists()
Postgres.dbinfo
Postgres.dbuser_exists()
Postgres.drop_db()
Postgres.drop_dbuser()
Postgres.find_new_db()
Postgres.find_new_dbuser()
Postgres.from_profile()
Postgres.host_for_psycopg2
Postgres.port_for_psycopg2
manual_setup_instructions()
- Submodules
- aiida.manage.tests package
- Submodules
EntryPointManager
aiida_caplog()
aiida_computer()
aiida_computer_local()
aiida_computer_ssh()
aiida_instance()
aiida_local_code_factory()
aiida_localhost()
aiida_manager()
aiida_profile()
aiida_profile_clean()
aiida_profile_clean_class()
aiida_profile_factory()
aiida_test_profile()
clear_database()
clear_database_after_test()
clear_database_before_test()
clear_database_before_test_class()
clear_profile()
config_psql_dos()
daemon_client()
entry_points()
postgres_cluster()
recursive_merge()
ssh_key()
started_daemon_client()
stopped_daemon_client()
submit_and_await()
suppress_deprecations()
temp_dir()
temporary_event_loop()
- Submodules
Submodules#
Definition of caching mechanism and configuration for calculations.
- class aiida.manage.caching.ConfigKeys(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
Valid keys for caching configuration.
- DEFAULT = 'caching.default_enabled'#
- DISABLED = 'caching.disabled_for'#
- ENABLED = 'caching.enabled_for'#
- __module__ = 'aiida.manage.caching'#
- class aiida.manage.caching._ContextCache[source]#
Bases:
object
Cache options, accounting for when in enable_caching or disable_caching contexts.
- __dict__ = mappingproxy({'__module__': 'aiida.manage.caching', '__doc__': 'Cache options, accounting for when in enable_caching or disable_caching contexts.', '__init__': <function _ContextCache.__init__>, 'clear': <function _ContextCache.clear>, 'enable_all': <function _ContextCache.enable_all>, 'disable_all': <function _ContextCache.disable_all>, 'enable': <function _ContextCache.enable>, 'disable': <function _ContextCache.disable>, 'get_options': <function _ContextCache.get_options>, '__dict__': <attribute '__dict__' of '_ContextCache' objects>, '__weakref__': <attribute '__weakref__' of '_ContextCache' objects>, '__annotations__': {}})#
- __module__ = 'aiida.manage.caching'#
- __weakref__#
list of weak references to the object
- aiida.manage.caching._match_wildcard(*, string: str, pattern: str) bool [source]#
Return whether a given name matches a pattern which can contain ‘*’ wildcards.
- Parameters:
string – The string to check.
pattern – The patter to match for.
- Returns:
True
ifstring
matches thepattern
,False
otherwise.
- aiida.manage.caching._validate_identifier_pattern(*, identifier: str, strict: bool = False)[source]#
Validate an caching identifier pattern.
The identifier (without wildcards) can have one of two forms:
<group_name><ENTRY_POINT_STRING_SEPARATOR><tail>
where group_name is one of the keys in ENTRY_POINT_GROUP_TO_MODULE_PATH_MAP and tail can be anything _except_ ENTRY_POINT_STRING_SEPARATOR.
a fully qualified Python name
this is a colon-separated string, where each part satisfies part.isidentifier() and not keyword.iskeyword(part)
This function checks if an identifier _with_ wildcards can possibly match one of these two forms. If it can not, a
ValueError
is raised.- Parameters:
identifier – Process type string, or a pattern with ‘*’ wildcard that matches it.
strict – When set to
True
, the function will actually try to resolve the identifier by loading it and if it fails, an exception is raised.
- Raises:
ValueError – If the identifier is an invalid identifier.
ValueError – If
strict=True
and the identifier cannot be successfully loaded.
- aiida.manage.caching.disable_caching(*, identifier: str | None = None, strict: bool = False)[source]#
Context manager to disable caching, either for a specific node class, or globally.
Warning
this does not affect the behavior of the daemon, only the local Python interpreter.
- Parameters:
identifier (str) – Process type string of the node, or a pattern with ‘*’ wildcard that matches it. If not provided, caching is disabled for all classes.
strict – When set to
True
, the function will actually try to resolve the identifier by loading it and if it fails, an exception is raised.
- aiida.manage.caching.enable_caching(*, identifier: str | None = None, strict: bool = False)[source]#
Context manager to enable caching, either for a specific node class, or globally.
Warning
this does not affect the behavior of the daemon, only the local Python interpreter.
- Parameters:
identifier (str) – Process type string of the node, or a pattern with ‘*’ wildcard that matches it. If not provided, caching is enabled for all classes.
strict – When set to
True
, the function will actually try to resolve the identifier by loading it and if it fails, an exception is raised.
- aiida.manage.caching.get_use_cache(*, identifier: str | None = None, strict: bool = False) bool [source]#
Return whether the caching mechanism should be used for the given process type according to the configuration.
- Parameters:
identifier – Process type string of the node
strict – When set to
True
, the function will actually try to resolve the identifier by loading it and if it fails, an exception is raised.
- Returns:
boolean, True if caching is enabled, False otherwise
- Raises:
~aiida.common.exceptions.ConfigurationError if the configuration is invalid, either due to a general configuration error, or by defining the class both enabled and disabled
AiiDA manager for global settings
- class aiida.manage.manager.Manager[source]#
Bases:
object
Manager singleton for globally loaded resources.
AiiDA can have the following global resources loaded:
A single configuration object that contains:
Global options overrides
The name of a default profile
A mapping of profile names to their configuration and option overrides
A single profile object that contains:
The name of the profile
The UUID of the profile
The configuration of the profile, for connecting to storage and processing resources
The option overrides for the profile
3. A single storage backend object for the profile, to connect to data storage resources 5. A single daemon client object for the profile, to connect to the AiiDA daemon 4. A single communicator object for the profile, to connect to the process control resources 6. A single process controller object for the profile, which uses the communicator to control process tasks 7. A single runner object for the profile, which uses the process controller to start and stop processes 8. A single persister object for the profile, which can persist running processes to the profile storage
- __dict__ = mappingproxy({'__module__': 'aiida.manage.manager', '__doc__': 'Manager singleton for globally loaded resources.\n\n AiiDA can have the following global resources loaded:\n\n 1. A single configuration object that contains:\n\n - Global options overrides\n - The name of a default profile\n - A mapping of profile names to their configuration and option overrides\n\n 2. A single profile object that contains:\n\n - The name of the profile\n - The UUID of the profile\n - The configuration of the profile, for connecting to storage and processing resources\n - The option overrides for the profile\n\n 3. A single storage backend object for the profile, to connect to data storage resources\n 5. A single daemon client object for the profile, to connect to the AiiDA daemon\n 4. A single communicator object for the profile, to connect to the process control resources\n 6. A single process controller object for the profile, which uses the communicator to control process tasks\n 7. A single runner object for the profile, which uses the process controller to start and stop processes\n 8. A single persister object for the profile, which can persist running processes to the profile storage\n\n ', '__init__': <function Manager.__init__>, 'get_config': <staticmethod(<function Manager.get_config>)>, 'get_profile': <function Manager.get_profile>, 'load_profile': <function Manager.load_profile>, 'reset_profile': <function Manager.reset_profile>, 'reset_profile_storage': <function Manager.reset_profile_storage>, 'reset_broker': <function Manager.reset_broker>, 'reset_runner': <function Manager.reset_runner>, 'unload_profile': <function Manager.unload_profile>, 'set_default_user_email': <function Manager.set_default_user_email>, 'profile_storage_loaded': <property object>, 'get_option': <function Manager.get_option>, 'get_backend': <function Manager.get_backend>, 'get_profile_storage': <function Manager.get_profile_storage>, 'get_broker': <function Manager.get_broker>, 'get_persister': <function Manager.get_persister>, 'get_communicator': <function Manager.get_communicator>, 'get_daemon_client': <function Manager.get_daemon_client>, 'get_process_controller': <function Manager.get_process_controller>, 'get_runner': <function Manager.get_runner>, 'set_runner': <function Manager.set_runner>, 'create_runner': <function Manager.create_runner>, 'create_daemon_runner': <function Manager.create_daemon_runner>, 'check_version': <function Manager.check_version>, '__dict__': <attribute '__dict__' of 'Manager' objects>, '__weakref__': <attribute '__weakref__' of 'Manager' objects>, '__annotations__': {'_broker': "Optional['Broker']", '_profile': "Optional['Profile']", '_profile_storage': "Optional['StorageBackend']", '_daemon_client': "Optional['DaemonClient']", '_process_controller': "Optional['RemoteProcessThreadController']", '_persister': "Optional['AiiDAPersister']", '_runner': "Optional['Runner']"}})#
- __module__ = 'aiida.manage.manager'#
- __weakref__#
list of weak references to the object
- check_version()[source]#
Check the currently installed version of
aiida-core
and warn if it is a post release development version.The
aiida-core
package maintains the protocol that themain
branch will use a post release version number. This means it will always append .post0 to the version of the latest release. This should mean that if this protocol is maintained properly, this method will print a warning if the currently installed version is a post release development branch and not an actual release.
- create_daemon_runner(loop: 'asyncio.AbstractEventLoop' | None = None) Runner [source]#
Create and return a new daemon runner.
This is used by workers when the daemon is running and in testing.
- Parameters:
loop – the (optional) asyncio event loop to use
- Returns:
a runner configured to work in the daemon configuration
- create_runner(with_persistence: bool = True, **kwargs: Any) Runner [source]#
Create and return a new runner
- Parameters:
with_persistence – create a runner with persistence enabled
- Returns:
a new runner instance
- get_backend() StorageBackend [source]#
Return the current profile’s storage backend, loading it if necessary.
Deprecated: use get_profile_storage instead.
- get_broker() 'Broker' | None [source]#
Return an instance of
aiida.brokers.broker.Broker
if the profile defines a broker.- Returns:
The broker of the profile, or
None
if the profile doesn’t define one.
- get_communicator() RmqThreadCommunicator [source]#
Return the communicator
- Returns:
a global communicator instance
- static get_config(create=False) Config [source]#
Return the current config.
- Returns:
current loaded config instance
- Raises:
aiida.common.ConfigurationError – if the configuration file could not be found, read or deserialized
- get_daemon_client() DaemonClient [source]#
Return the daemon client for the current profile.
- Returns:
the daemon client
- Raises:
aiida.common.MissingConfigurationError – if the configuration file cannot be found
aiida.common.ProfileConfigurationError – if the given profile does not exist
- get_option(option_name: str) Any [source]#
Return the value of a configuration option.
In order of priority, the option is returned from:
The current profile, if loaded and the option specified
The current configuration, if loaded and the option specified
The default value for the option
- Parameters:
option_name – the name of the option to return
- Returns:
the value of the option
- Raises:
aiida.common.exceptions.ConfigurationError – if the option is not found
- get_persister() AiiDAPersister [source]#
Return the persister
- Returns:
the current persister instance
- get_process_controller() RemoteProcessThreadController [source]#
Return the process controller
- Returns:
the process controller instance
- get_profile() 'Profile' | None [source]#
Return the current loaded profile, if any
- Returns:
current loaded profile instance
- get_profile_storage() StorageBackend [source]#
Return the current profile’s storage backend, loading it if necessary.
- get_runner(**kwargs) Runner [source]#
Return a runner that is based on the current profile settings and can be used globally by the code.
- Returns:
the global runner
- load_profile(profile: None | str | 'Profile' = None, allow_switch=False) Profile [source]#
Load a global profile, unloading any previously loaded profile.
Note
If a profile is already loaded and no explicit profile is specified, nothing will be done.
- Parameters:
profile – the name of the profile to load, by default will use the one marked as default in the config
allow_switch – if True, will allow switching to a different profile when storage is already loaded
- Returns:
the loaded Profile instance
- Raises:
aiida.common.exceptions.InvalidOperation – if another profile has already been loaded and allow_switch is False
- property profile_storage_loaded: bool#
Return whether a storage backend has been loaded.
- Returns:
boolean, True if database backend is currently loaded, False otherwise
- reset_profile_storage() None [source]#
Reset the profile storage.
This will close any connections to the services used by the storage, such as database connections.
- set_default_user_email(profile: Profile, user_email: str) None [source]#
Set the default user for the given profile.
- Parameters:
profile – The profile to update.
user_email – The email of the user to set as the default user.
Module for the ProfileAccessManager that tracks process access to the profile.
- class aiida.manage.profile_access.ProfileAccessManager(profile: Profile)[source]#
Bases:
object
Class to manage access to a profile.
Any process that wants to request access for a given profile, should first call:
ProfileAccessManager(profile).request_access()
If this returns normally, the profile can be used safely. It will raise if it is locked, in which case the profile should not be used. If a process wants to request exclusive access to the profile, it should use
lock
:- with ProfileAccessManager(profile).lock():
pass
If the profile is already locked or is currently in use, an exception is raised.
Access and locks of the profile will be recorded in a directory with files with a
.pid
and.lock
extension, respectively. In principle then, at any one time, there can either be a number of pid files, or just a single lock file. If there is a mixture or there are more than one lock files, we are in an inconsistent state.- __dict__ = mappingproxy({'__module__': 'aiida.manage.profile_access', '__doc__': 'Class to manage access to a profile.\n\n Any process that wants to request access for a given profile, should first call:\n\n ProfileAccessManager(profile).request_access()\n\n If this returns normally, the profile can be used safely. It will raise if it is locked, in which case the profile\n should not be used. If a process wants to request exclusive access to the profile, it should use ``lock``:\n\n with ProfileAccessManager(profile).lock():\n pass\n\n If the profile is already locked or is currently in use, an exception is raised.\n\n Access and locks of the profile will be recorded in a directory with files with a ``.pid`` and ``.lock`` extension,\n respectively. In principle then, at any one time, there can either be a number of pid files, or just a single lock\n file. If there is a mixture or there are more than one lock files, we are in an inconsistent state.\n ', '__init__': <function ProfileAccessManager.__init__>, 'request_access': <function ProfileAccessManager.request_access>, 'lock': <function ProfileAccessManager.lock>, 'is_locked': <function ProfileAccessManager.is_locked>, 'is_active': <function ProfileAccessManager.is_active>, 'clear_locks': <function ProfileAccessManager.clear_locks>, '_clear_stale_pid_files': <function ProfileAccessManager._clear_stale_pid_files>, '_get_tracking_files': <function ProfileAccessManager._get_tracking_files>, '_raise_if_locked': <function ProfileAccessManager._raise_if_locked>, '_raise_if_active': <function ProfileAccessManager._raise_if_active>, '__dict__': <attribute '__dict__' of 'ProfileAccessManager' objects>, '__weakref__': <attribute '__weakref__' of 'ProfileAccessManager' objects>, '__annotations__': {}})#
- __init__(profile: Profile)[source]#
Class that manages access and locks to the given profile.
- Parameters:
profile – the profile whose access to manage.
- __module__ = 'aiida.manage.profile_access'#
- __weakref__#
list of weak references to the object
- _get_tracking_files(ext_string: str, exclude_self: bool = False) List[Path] [source]#
Return a list of all files that track the accessing and locking of the profile.
- Parameters:
ext_string – To get the files that track locking use .lock, to get the files that track access use .pid.
exclude_self – If true removes from the returned list any tracking to the current process.
- _raise_if_active(message_start)[source]#
Raise a
LockingProfileError
if the profile is being accessed.- Parameters:
message_start – Text to use as the start of the exception message.
- Raises:
LockingProfileError – if the profile is active.
- _raise_if_locked(message_start)[source]#
Raise a
LockedProfileError
if the profile is locked.- Parameters:
message_start – Text to use as the start of the exception message.
- Raises:
LockedProfileError – if the profile is locked.
- clear_locks() None [source]#
Clear all locks on this profile.
Warning
This should only be used if the profile is currently still incorrectly locked because the lock was not automatically released after the
lock
contextmanager exited its scope.
- lock()[source]#
Request a lock on the profile for exclusive access.
This context manager should be used if exclusive access to the profile is required. Access will be granted if the profile is currently not in use, nor locked by another process. During the context, the profile will be locked, which will be lifted automatically as soon as the context exits.
- Raises:
LockingProfileError – if there are currently active processes using the profile.
LockedProfileError – if there currently already is a lock on the profile.
- request_access() None [source]#
Request access to the profile.
If the profile is locked, a
LockedProfileError
is raised. Otherwise a PID file is created for this process and the function returnsNone
. The PID file contains the command of the process.- Raises:
LockedProfileError – if the profile is locked.