aiida.backends package¶
Module for implementations of database backends.
Subpackages¶
- aiida.backends.djsite package
- aiida.backends.general package
- aiida.backends.sqlalchemy package
- aiida.backends.tests package
- Subpackages
- aiida.backends.tests.cmdline package
- aiida.backends.tests.common package
- aiida.backends.tests.engine package
- aiida.backends.tests.manage package
- aiida.backends.tests.orm package
- aiida.backends.tests.parsers package
- aiida.backends.tests.plugins package
- aiida.backends.tests.restapi package
- aiida.backends.tests.tools package
- aiida.backends.tests.utils package
- Submodules
- 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'¶
-
-
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¶
-
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.
-
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
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
-
classmethod
setUpClass
(*args, **kwargs)[source]¶ Hook method for setting up class fixture before running tests in the class.
-
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
andtearDownClass_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 thatxxx
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 objectself.user_email
that must be a string
These two are then exposed by the
self.get_computer()
andself.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', 'tearDownClass_method', 'clean_db'}), '_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¶
-
computer
= None¶
-
create_user
()[source]¶ This method creates and stores the default user. It has the same effect as the verdi setup.
-
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.
-
abstract
tearDownClass_method
()[source]¶ Backend-specific tasks for tearing down the test environment.
-
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
-
-
aiida.backends.utils.
get_db_schema_generation
()[source]¶ Get the schema generation of the current database.
-
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