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

Submodules

Definition of caching mechanism and configuration for calculations.

aiida.manage.caching.disable_caching(*, identifier=None)[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.

aiida.manage.caching.enable_caching(*, identifier=None)[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.

aiida.manage.caching.get_use_cache(*, identifier=None)[source]

Return whether the caching mechanism should be used for the given process type according to the configuration.

Parameters

identifier (str) – Process type string of the node

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

Testing infrastructure for easy testing of AiiDA plugins.

aiida.manage.fixtures.FixtureManager

alias of aiida.manage.tests.TestManager

class aiida.manage.fixtures.PluginTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Set up a complete temporary AiiDA environment for plugin tests.

Note: This test class needs to be run through the TestRunner and will not work simply with python -m unittest discover.

Usage example:

MyTestCase(aiida.manage.tests.unittest_classes.PluginTestCase):

    def setUp(self):
        # load my tests data

    # optionally extend setUpClass / tearDownClass / tearDown if needed

    def test_my_plugin(self):
        # execute tests
__module__ = 'aiida.manage.tests.unittest_classes'
backend = None
classmethod setUpClass()[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.

aiida.manage.fixtures.fixture_manager(backend='django', profile_name=None, pgtest=None)

Context manager for TestManager objects.

Sets up temporary AiiDA environment for testing or reuses existing environment, if AIIDA_TEST_PROFILE environment variable is set.

Example pytest fixture:

def aiida_profile():
    with test_manager(backend) as test_mgr:
        yield fixture_mgr

Example unittest test runner:

with test_manager(backend) as test_mgr:
    # ready for tests
# everything cleaned up
Parameters
  • backend – database backend, either BACKEND_SQLA or BACKEND_DJANGO

  • profile_name – name of test profile to be used or None (to use temporary profile)

  • pgtest – a dictionary of arguments to be passed to PGTest() for starting the postgresql cluster, e.g. {‘pg_ctl’: ‘/somepath/pg_ctl’}. Should usually not be necessary.

AiiDA manager for global settings

aiida.manage.manager.get_manager() → aiida.manage.manager.Manager[source]
aiida.manage.manager.reset_manager()None[source]