aiida.manage.configuration.migrations package#

Methods and definitions of migrations for the configuration file of an AiiDA instance.

Submodules#

Define the current configuration version and migrations.

class aiida.manage.configuration.migrations.migrations.AbstractStorageAndProcess(*args, **kwargs)[source]#

Bases: SingleMigration

Move the storage config under a top-level “storage” key and rabbitmq config under “processing”.

This allows for different storage backends to have different configuration.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 5#

The initial oldest backwards compatible configuration version

down_revision: int = 5#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

process_keys = ('broker_protocol', 'broker_username', 'broker_password', 'broker_host', 'broker_port', 'broker_virtual_host', 'broker_parameters')#
storage_conversions = (('AIIDADB_ENGINE', 'database_engine'), ('AIIDADB_HOST', 'database_hostname'), ('AIIDADB_PORT', 'database_port'), ('AIIDADB_USER', 'database_username'), ('AIIDADB_PASS', 'database_password'), ('AIIDADB_NAME', 'database_name'), ('AIIDADB_REPOSITORY_URI', 'repository_uri'))#
up_compatible: int = 6#

The final oldest backwards compatible configuration version

up_revision: int = 6#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.AddMessageBroker(*args, **kwargs)[source]#

Bases: SingleMigration

Add the configuration for the message broker, which was not configurable up to now.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 3#

The initial oldest backwards compatible configuration version

down_revision: int = 3#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 3#

The final oldest backwards compatible configuration version

up_revision: int = 4#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.AddPrefixToStorageBackendTypes(*args, **kwargs)[source]#

Bases: SingleMigration

The storage.backend key should be prefixed with core..

At this point, it should only ever contain psql_dos which should therefore become core.psql_dos. To cover for cases where people manually added a read only sqlite_zip profile, we also migrate that.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 8#

The initial oldest backwards compatible configuration version

down_revision: int = 8#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 9#

The final oldest backwards compatible configuration version

up_revision: int = 9#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.AddProfileUuid(*args, **kwargs)[source]#

Bases: SingleMigration

Add the required values for a new default profile.

  • PROFILE_UUID

The profile uuid will be used as a general purpose identifier for the profile, in for example the RabbitMQ message queues and exchanges.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 0#

The initial oldest backwards compatible configuration version

down_revision: int = 1#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 0#

The final oldest backwards compatible configuration version

up_revision: int = 2#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.AddTestProfileKey(*args, **kwargs)[source]#

Bases: SingleMigration

Add the test_profile key.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 7#

The initial oldest backwards compatible configuration version

down_revision: int = 7#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 8#

The final oldest backwards compatible configuration version

up_revision: int = 8#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.Initial(*args, **kwargs)[source]#

Bases: SingleMigration

Base migration (no-op).

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 0#

The initial oldest backwards compatible configuration version

down_revision: int = 0#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 0#

The final oldest backwards compatible configuration version

up_revision: int = 1#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.MergeStorageBackendTypes(*args, **kwargs)[source]#

Bases: SingleMigration

django and sqlalchemy are now merged into psql_dos.

The legacy name is stored under the _v6_backend key, to allow for downgrades.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 6#

The initial oldest backwards compatible configuration version

down_revision: int = 6#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 7#

The final oldest backwards compatible configuration version

up_revision: int = 7#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.SimplifyDefaultProfiles(*args, **kwargs)[source]#

Bases: SingleMigration

Replace process specific default profiles with single default profile key.

The concept of a different ‘process’ for a profile has been removed and as such the default profiles key in the configuration no longer needs a value per process (‘verdi’, ‘daemon’). We remove the dictionary ‘default_profiles’ and replace it with a simple value ‘default_profile’.

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
down_compatible: int = 0#

The initial oldest backwards compatible configuration version

down_revision: int = 2#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 3#

The final oldest backwards compatible configuration version

up_revision: int = 3#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.SimplifyOptions(*args, **kwargs)[source]#

Bases: SingleMigration

Remove unnecessary difference between file/internal representation of options

__abstractmethods__ = frozenset({})#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

_abc_impl = <_abc._abc_data object>#
_is_protocol = False#
conversions = (('runner_poll_interval', 'runner.poll.interval'), ('daemon_default_workers', 'daemon.default_workers'), ('daemon_timeout', 'daemon.timeout'), ('daemon_worker_process_slots', 'daemon.worker_process_slots'), ('db_batch_size', 'db.batch_size'), ('verdi_shell_auto_import', 'verdi.shell.auto_import'), ('logging_aiida_log_level', 'logging.aiida_loglevel'), ('logging_db_log_level', 'logging.db_loglevel'), ('logging_plumpy_log_level', 'logging.plumpy_loglevel'), ('logging_kiwipy_log_level', 'logging.kiwipy_loglevel'), ('logging_paramiko_log_level', 'logging.paramiko_loglevel'), ('logging_alembic_log_level', 'logging.alembic_loglevel'), ('logging_sqlalchemy_loglevel', 'logging.sqlalchemy_loglevel'), ('logging_circus_log_level', 'logging.circus_loglevel'), ('user_email', 'autofill.user.email'), ('user_first_name', 'autofill.user.first_name'), ('user_last_name', 'autofill.user.last_name'), ('user_institution', 'autofill.user.institution'), ('show_deprecations', 'warnings.showdeprecations'), ('task_retry_initial_interval', 'transport.task_retry_initial_interval'), ('task_maximum_attempts', 'transport.task_maximum_attempts'))#
down_compatible: int = 3#

The initial oldest backwards compatible configuration version

down_revision: int = 4#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int = 5#

The final oldest backwards compatible configuration version

up_revision: int = 5#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

class aiida.manage.configuration.migrations.migrations.SingleMigration(*args, **kwargs)[source]#

Bases: Protocol

A single migration of the configuration.

__abstractmethods__ = frozenset({})#
__annotations__ = {'down_compatible': <class 'int'>, 'down_revision': <class 'int'>, 'up_compatible': <class 'int'>, 'up_revision': <class 'int'>}#
__dict__ = mappingproxy({'__module__': 'aiida.manage.configuration.migrations.migrations', '__annotations__': {'down_revision': <class 'int'>, 'down_compatible': <class 'int'>, 'up_revision': <class 'int'>, 'up_compatible': <class 'int'>}, '__doc__': 'A single migration of the configuration.', 'upgrade': <function SingleMigration.upgrade>, 'downgrade': <function SingleMigration.downgrade>, '__dict__': <attribute '__dict__' of 'SingleMigration' objects>, '__weakref__': <attribute '__weakref__' of 'SingleMigration' objects>, '__parameters__': (), '_is_protocol': True, '__subclasshook__': <function Protocol.__init_subclass__.<locals>._proto_hook>, '__init__': <function _no_init_or_replace_init>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>})#
__init__(*args, **kwargs)#
__module__ = 'aiida.manage.configuration.migrations.migrations'#
__parameters__ = ()#
__subclasshook__()#

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__#

list of weak references to the object (if defined)

_abc_impl = <_abc._abc_data object>#
_is_protocol = True#
down_compatible: int#

The initial oldest backwards compatible configuration version

down_revision: int#

The initial configuration version.

downgrade(config: Dict[str, Any]) None[source]#

Downgrade the configuration in-place.

up_compatible: int#

The final oldest backwards compatible configuration version

up_revision: int#

The final configuration version.

upgrade(config: Dict[str, Any]) None[source]#

Migrate the configuration in-place.

aiida.manage.configuration.migrations.migrations.check_and_migrate_config(config, filepath: str | None = None)[source]#

Checks if the config needs to be migrated, and performs the migration if needed.

Parameters:
  • config – the configuration dictionary

  • filepath – the path to the configuration file (optional, for error reporting)

Returns:

the migrated configuration dictionary

aiida.manage.configuration.migrations.migrations.config_needs_migrating(config, filepath: str | None = None)[source]#

Checks if the config needs to be migrated.

If the oldest compatible version of the configuration is higher than the current configuration version defined in the code, the config cannot be used and so the function will raise.

Parameters:

filepath – the path to the configuration file (optional, for error reporting)

Returns:

True if the configuration has an older version and needs to be migrated, False otherwise

Raises:

aiida.common.ConfigurationVersionError – if the config’s oldest compatible version is higher than the current

aiida.manage.configuration.migrations.migrations.downgrade_config(config: ~typing.Dict[str, ~typing.Any], target: int, migrations: ~typing.Iterable[~typing.Type[~aiida.manage.configuration.migrations.migrations.SingleMigration]] = (<class 'aiida.manage.configuration.migrations.migrations.Initial'>, <class 'aiida.manage.configuration.migrations.migrations.AddProfileUuid'>, <class 'aiida.manage.configuration.migrations.migrations.SimplifyDefaultProfiles'>, <class 'aiida.manage.configuration.migrations.migrations.AddMessageBroker'>, <class 'aiida.manage.configuration.migrations.migrations.SimplifyOptions'>, <class 'aiida.manage.configuration.migrations.migrations.AbstractStorageAndProcess'>, <class 'aiida.manage.configuration.migrations.migrations.MergeStorageBackendTypes'>, <class 'aiida.manage.configuration.migrations.migrations.AddTestProfileKey'>, <class 'aiida.manage.configuration.migrations.migrations.AddPrefixToStorageBackendTypes'>)) Dict[str, Any][source]#

Run the registered configuration migrations down to the target version.

Parameters:

config – the configuration dictionary

Returns:

the migrated configuration dictionary

aiida.manage.configuration.migrations.migrations.get_current_version(config)[source]#

Return the current version of the config.

Returns:

current config version or 0 if not defined

aiida.manage.configuration.migrations.migrations.get_oldest_compatible_version(config)[source]#

Return the current oldest compatible version of the config.

Returns:

current oldest compatible config version or 0 if not defined

aiida.manage.configuration.migrations.migrations.upgrade_config(config: ~typing.Dict[str, ~typing.Any], target: int = 9, migrations: ~typing.Iterable[~typing.Type[~aiida.manage.configuration.migrations.migrations.SingleMigration]] = (<class 'aiida.manage.configuration.migrations.migrations.Initial'>, <class 'aiida.manage.configuration.migrations.migrations.AddProfileUuid'>, <class 'aiida.manage.configuration.migrations.migrations.SimplifyDefaultProfiles'>, <class 'aiida.manage.configuration.migrations.migrations.AddMessageBroker'>, <class 'aiida.manage.configuration.migrations.migrations.SimplifyOptions'>, <class 'aiida.manage.configuration.migrations.migrations.AbstractStorageAndProcess'>, <class 'aiida.manage.configuration.migrations.migrations.MergeStorageBackendTypes'>, <class 'aiida.manage.configuration.migrations.migrations.AddTestProfileKey'>, <class 'aiida.manage.configuration.migrations.migrations.AddPrefixToStorageBackendTypes'>)) Dict[str, Any][source]#

Run the registered configuration migrations up to the target version.

Parameters:

config – the configuration dictionary

Returns:

the migrated configuration dictionary