aiida.backends package

Module for implementations of database backends.

Subpackages

Submodules

Module for implementations of database backends.

Deprecated since version 1.0.0: Will be removed in v1.1.0, use aiida.backends instead.

class aiida.backends.testbase.AiidaPostgresTestCase(methodName='runTest')[source]

Bases: aiida.backends.testbase.AiidaTestCase

__module__ = 'aiida.backends.testbase'
classmethod setUpClass(*args, **kwargs)[source]

Setup the PGTest postgres test cluster.

classmethod tearDownClass(*args, **kwargs)[source]

Close the PGTest postgres test cluster.

class aiida.backends.testbase.AiidaTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

This is the base class for AiiDA tests, independent of the backend.

Internally it loads the AiidaTestImplementation subclass according to the current backend

_AiidaTestCase__backend_instance = None
__module__ = 'aiida.backends.testbase'
_class_was_setup = False
assertClickResultNoException(cli_result)[source]
assertClickSuccess(cli_result)[source]
backend = None
classmethod clean_db()[source]

Clean up database and reset caches.

Resets AiiDA manager cache, which could otherwise be left in an inconsistent state when cleaning the database.

classmethod clean_repository()[source]

Cleans up file repository.

computer

A class that, when used as a decorator, works as if the two decorators @property and @classmethod where applied together (i.e., the object works as a property, both for the Class and for any of its instance; and is called with the class cls rather than with the instance as its first argument).

classmethod create_computer()[source]
classmethod create_user()[source]
classmethod get_backend_class()[source]
classmethod insert_data()[source]

This method setups the database (by creating a default user) and inserts default data into the database (which is for the moment a default computer).

reset_database()[source]

Reset the database to the default state deleting any content currently stored

setUp()[source]

Hook method for setting up the test fixture before exercising it.

classmethod setUpClass(*args, **kwargs)[source]

Hook method for setting up class fixture before running tests in the class.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

classmethod tearDownClass(*args, **kwargs)[source]

Hook method for deconstructing the class fixture after running all tests in the class.

user_email

A class that, when used as a decorator, works as if the two decorators @property and @classmethod where applied together (i.e., the object works as a property, both for the Class and for any of its instance; and is called with the class cls rather than with the instance as its first argument).

aiida.backends.testbase.check_if_tests_can_run()[source]

Verify that the currently loaded profile is a test profile, otherwise raise TestsNotAllowedError.

aiida.backends.testbase.run_aiida_db_tests(tests_to_run, verbose=False)[source]

Run all tests specified in tests_to_run. Return the list of test results.

class aiida.backends.testimplbase.AiidaTestImplementation[source]

Bases: object

For each implementation, define what to do at setUp and tearDown.

Each subclass must reimplement two standard methods (i.e., not classmethods), called respectively setUpClass_method and tearDownClass_method. It is also required to implement setUp_method and tearDown_method to be run for each single test They can set local properties (e.g. self.xxx = yyy) but remember that xxx is not visible to the upper (calling) Test class.

Moreover, it is required that they define in the setUpClass_method the two properties:

  • self.computer that must be a Computer object

  • self.user_email that must be a string

These two are then exposed by the self.get_computer() and self.get_user_email() methods.

__abstractmethods__ = frozenset({'clean_db', 'setUpClass_method', 'tearDownClass_method'})
__dict__ = mappingproxy({'__module__': 'aiida.backends.testimplbase', '__doc__': '\n For each implementation, define what to do at setUp and tearDown.\n\n Each subclass must reimplement two *standard* methods (i.e., *not* classmethods), called\n respectively ``setUpClass_method`` and ``tearDownClass_method``.\n It is also required to implement setUp_method and tearDown_method to be run for each single test\n They can set local properties (e.g. ``self.xxx = yyy``) but remember that ``xxx``\n is not visible to the upper (calling) Test class.\n\n Moreover, it is required that they define in the setUpClass_method the two properties:\n\n - ``self.computer`` that must be a Computer object\n - ``self.user_email`` that must be a string\n\n These two are then exposed by the ``self.get_computer()`` and ``self.get_user_email()``\n methods.\n ', 'backend': None, 'computer': None, 'user': None, 'user_email': None, 'setUpClass_method': <function AiidaTestImplementation.setUpClass_method>, 'setUp_method': <function AiidaTestImplementation.setUp_method>, 'tearDown_method': <function AiidaTestImplementation.tearDown_method>, 'tearDownClass_method': <function AiidaTestImplementation.tearDownClass_method>, 'clean_db': <function AiidaTestImplementation.clean_db>, 'insert_data': <function AiidaTestImplementation.insert_data>, 'create_user': <function AiidaTestImplementation.create_user>, 'create_computer': <function AiidaTestImplementation.create_computer>, 'get_computer': <function AiidaTestImplementation.get_computer>, 'get_user_email': <function AiidaTestImplementation.get_user_email>, '__dict__': <attribute '__dict__' of 'AiidaTestImplementation' objects>, '__weakref__': <attribute '__weakref__' of 'AiidaTestImplementation' objects>, '__abstractmethods__': frozenset({'setUpClass_method', 'clean_db', 'tearDownClass_method'}), '_abc_impl': <_abc_data object>})
__module__ = 'aiida.backends.testimplbase'
__weakref__

list of weak references to the object (if defined)

_abc_impl = <_abc_data object>
backend = None
abstract clean_db()[source]

This method implements the logic to fully clean the DB.

computer = None
create_computer()[source]

This method creates and stores a computer.

create_user()[source]

This method creates and stores the default user. It has the same effect as the verdi setup.

get_computer()[source]

A ORM Computer object present in the DB

get_user_email()[source]

A string with the email of the User

insert_data()[source]
abstract setUpClass_method()[source]

This class prepares the database (cleans it up and installs some basic entries). You have also to set a self.computer and a self.user_email as explained in the docstring of the AiidaTestImplemention docstring.

setUp_method()[source]
abstract tearDownClass_method()[source]

Backend-specific tasks for tearing down the test environment.

tearDown_method()[source]
user = None
user_email = None
class aiida.backends.utils.Setting(key, value, description, time)

Bases: tuple

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__module__ = 'aiida.backends.utils'
static __new__(_cls, key, value, description, time)

Create new instance of Setting(key, value, description, time)

__repr__()

Return a nicely formatted representation string

__slots__ = ()
_asdict()

Return a new OrderedDict which maps field names to their values.

_fields = ('key', 'value', 'description', 'time')
_fields_defaults = {}
classmethod _make(iterable)

Make a new Setting object from a sequence or iterable

_replace(**kwds)

Return a new Setting object replacing specified fields with new values

property description

Alias for field number 2

property key

Alias for field number 0

property time

Alias for field number 3

property value

Alias for field number 1

class aiida.backends.utils.SettingsManager[source]

Bases: object

Class to get, set and delete settings from the DbSettings table.

__dict__ = mappingproxy({'__module__': 'aiida.backends.utils', '__doc__': 'Class to get, set and delete settings from the `DbSettings` table.', 'get': <function SettingsManager.get>, 'set': <function SettingsManager.set>, 'delete': <function SettingsManager.delete>, '__dict__': <attribute '__dict__' of 'SettingsManager' objects>, '__weakref__': <attribute '__weakref__' of 'SettingsManager' objects>})
__module__ = 'aiida.backends.utils'
__weakref__

list of weak references to the object (if defined)

abstract delete(key)[source]

Delete the setting with the given key.

Parameters

key – the key identifying the setting

Raises

~aiida.common.exceptions.NotExistent if the settings does not exist

abstract get(key)[source]

Return the setting with the given key.

Parameters

key – the key identifying the setting

Returns

Setting

Raises

~aiida.common.exceptions.NotExistent if the settings does not exist

abstract set(key, value, description=None)[source]

Return the settings with the given key.

Parameters
  • key – the key identifying the setting

  • value – the value for the setting

  • description – optional setting description

aiida.backends.utils._load_dbenv_noschemacheck(profile=None, *args, **kwargs)[source]
aiida.backends.utils.delete_nodes_and_connections(pks)[source]
aiida.backends.utils.get_settings_manager()[source]
aiida.backends.utils.load_dbenv(profile=None, *args, **kwargs)[source]
aiida.backends.utils.validate_attribute_key(key)[source]

Validate the key string to check if it is valid (e.g., if it does not contain the separator symbol.).

Returns

None if the key is valid

Raises

aiida.common.ValidationError – if the key is not valid