aiida.plugins package

Submodules

Cached information for each plugin.

This module and the RegistryEntry class should be the sole location for the (implicit) definition of the registry format.

exception aiida.plugins.entry.InvalidPluginEntryError(msg='')[source]

Bases: exceptions.Exception

__init__(msg='')[source]

x.__init__(…) initializes x; see help(type(x)) for signature

__module__ = 'aiida.plugins.entry'
__weakref__

list of weak references to the object (if defined)

class aiida.plugins.entry.RegistryEntry(**kwargs)[source]

Bases: object

Can be created from an entry in the online aiida plugin registry. An instance will be created and cached for each entry on update.

__dict__ = dict_proxy({'__module__': 'aiida.plugins.entry', 'entry_point_categories': <property object>, 'description': <property object>, 'package_name': <property object>, 'tags': <property object>, 'installed': <property object>, '__dict__': <attribute '__dict__' of 'RegistryEntry' objects>, 'extras_requirements': <property object>, 'install_requirements': <property object>, 'cli_apps': <property object>, '__weakref__': <attribute '__weakref__' of 'RegistryEntry' objects>, '__init__': <function __init__>, 'entry_points': <property object>, 'format_info': <function format_info>, 'gui_apps': <property object>, 'install': <function install>, 'author': <property object>, 'author_email': <property object>, 'version': <property object>, 'entry_points_raw': <property object>, 'load_setup_info': <function load_setup_info>, 'test_installed': <function test_installed>, 'home_url': <property object>, '__doc__': '\n Can be created from an entry in the online aiida plugin registry.\n An instance will be created and cached for each entry on update.\n '})
__init__(**kwargs)[source]

stores registry entry keys and loads the setup_info from the url given in plugin_info

__module__ = 'aiida.plugins.entry'
__weakref__

list of weak references to the object (if defined)

author
author_email
cli_apps

A list of cli apps installed by this plugin

description
entry_point_categories

A list of categories for which this plugin exposes entry points

entry_points

A dict of entry point names by category

entry_points_raw

The full entry point spec in setuptools.setup() format

extras_requirements
format_info(**kwargs)[source]

format and return a datastructure containing all known information about the plugin

Parameters:
  • format – str, one of [tabulate | dict] tabulate: use tabulate to create and return a table of properties as a string dict: create a dict of properties
  • as_str – bool format=’dict’ and as_str=True: return a pretty printed string version of the dict format=’dict’ and as_str=False: return a dictionary format=’tabulate’: as_str is ignored
gui_apps

A list of GUI apps installed by this plugin

home_url
install(**opts)[source]

Call on pip to install the package if not yet installed

install_requirements
installed
load_setup_info(info_url)[source]

Load setup kwargs from the link in the registry

package_name

The name used to import the package

tags
test_installed()[source]

Return wether the plugin is installed

First, this checks wether the package_name can be imported. If not, we know that at least no new style plugin with that name is installed.

Secondly, tests wether all the entry points are currently found by the plugin loader. If not, it is considered not installed.

potential failures:
  • loading of the entry points is not tested
  • not properly uninstalled plugins might show up as
    installed if the entry points are still around.
  • it does not distinguish between not installed and
    an old version is installed
version

The version of the plugin package

class aiida.plugins.entry_point.EntryPointFormat[source]

Bases: enum.Enum

Enum to distinguish between the various possible entry point string formats. An entry point string is fully qualified by its group and name concatenated by the entry point string separator character. The group in AiiDA has the prefix aiida. and the separator character is the colon :.

Under these definitions a potentially valid entry point string may have the following formats:

  • FULL: prefixed group plus entry point name aiida.calculations:job
  • PARTIAL: unprefixed group plus entry point name calculations:job
  • MINIMAL: no group but only entry point name: job

Note that the MINIMAL format can potentially lead to ambiguity if the name appears in multiple entry point groups.

FULL = 1
INVALID = 0
MINIMAL = 3
PARTIAL = 2
__module__ = 'aiida.plugins.entry_point'
aiida.plugins.entry_point.format_entry_point_string(group, name, fmt=<EntryPointFormat.FULL: 1>)[source]

Format an entry point string for a given entry point group and name, based on the specified format

Parameters:
  • group – the entry point group
  • name – the name of the entry point
  • fmt – the desired output format
Raises:
  • TypeError – if fmt is not instance of EntryPointFormat
  • ValueError – if fmt value is invalid
aiida.plugins.entry_point.get_entry_point(group, name)[source]

Return an entry point with a given name within a specific group

Parameters:
  • group – the entry point group
  • name – the name of the entry point
Returns:

the entry point if it exists else None

Raises:
aiida.plugins.entry_point.get_entry_point_from_class(class_module, class_name)[source]

Given the module and name of a class, attempt to obtain the corresponding entry point if it exists

Parameters:
  • class_module – module of the class
  • class_name – name of the class
Returns:

a tuple of the corresponding group and entry point or None if not found

aiida.plugins.entry_point.get_entry_point_from_string(entry_point_string)[source]

Return an entry point for the given entry point string

Parameters:

entry_point_string – the entry point string

Returns:

the entry point if it exists else None

Raises:
  • TypeError – if the entry_point_string is not a string type
  • ValueError – if the entry_point_string cannot be split into two parts on the entry point string separator
  • MissingEntryPointError – entry point was not registered
  • MultipleEntryPointError – entry point could not be uniquely resolved
aiida.plugins.entry_point.get_entry_point_groups()[source]

Return a list of all the recognized entry point groups

Returns:a list of valid entry point groups
aiida.plugins.entry_point.get_entry_point_names(group, sort=True)[source]

Return a list of all the entry point names within a specific group

Parameters:
  • group – the entry point group
  • sort – if True, the returned list will be sorted alphabetically
Returns:

a list of entry point names

aiida.plugins.entry_point.get_entry_point_string_format(entry_point_string)[source]

Determine the format of an entry point string. Note that it does not validate the actual entry point string and it may not correspond to any actual entry point. This will only assess the string format

Parameters:entry_point_string – the entry point string
Returns:the entry point type
Return type:EntryPointFormat
aiida.plugins.entry_point.get_entry_point_string_from_class(class_module, class_name)[source]

Given the module and name of a class, attempt to obtain the corresponding entry point if it exists and return the entry point string which will be the entry point group and entry point name concatenated by the entry point string separator

entry_point_string = ‘{group:}:{entry_point_name:}’

This ensures that given the entry point string, one can load the corresponding class by splitting on the separator, which will give the group and entry point, which should the corresponding factory to uniquely determine and load the class

Parameters:
  • class_module – module of the class
  • class_name – name of the class
Returns:

the corresponding entry point string or None

aiida.plugins.entry_point.get_entry_points(group)[source]

Return a list of all the entry points within a specific group

Parameters:group – the entry point group
Returns:a list of entry points
aiida.plugins.entry_point.is_valid_entry_point_string(entry_point_string)[source]

Verify whether the given entry point string is a valid one. For the string to be valid means that it is composed of two strings, the entry point group and name, concatenated by the entry point string separator. If that is the case, the group name will be verified to see if it is known. If the group can be retrieved and it is known, the string is considered to be valid. It is invalid otherwise

Parameters:entry_point_string – the entry point string, generated by get_entry_point_string_from_class
Returns:True if the string is considered valid, False otherwise
aiida.plugins.entry_point.load_entry_point(group, name)[source]

Load the class registered under the entry point for a given name and group

Parameters:
  • group – the entry point group
  • name – the name of the entry point
Returns:

class registered at the given entry point

Raises:
  • TypeError – if the entry_point_string is not a string type
  • ValueError – if the entry_point_string cannot be split into two parts on the entry point string separator
  • MissingEntryPointError – entry point was not registered
  • MultipleEntryPointError – entry point could not be uniquely resolved
  • LoadingEntryPointError – entry point could not be loaded
aiida.plugins.entry_point.load_entry_point_from_string(entry_point_string)[source]

Load the class registered for a given entry point string that determines group and name

Parameters:

entry_point_string – the entry point string

Returns:

class registered at the given entry point

Raises:
  • TypeError – if the entry_point_string is not a string type
  • ValueError – if the entry_point_string cannot be split into two parts on the entry point string separator
  • MissingEntryPointError – entry point was not registered
  • MultipleEntryPointError – entry point could not be uniquely resolved
  • LoadingEntryPointError – entry point could not be loaded
aiida.plugins.entry_point.parse_entry_point_string(entry_point_string)[source]

Validate the entry point string and attempt to parse the entry point group and name

Parameters:

entry_point_string – the entry point string

Returns:

the entry point group and name if the string is valid

Raises:
  • TypeError – if the entry_point_string is not a string type
  • ValueError – if the entry_point_string cannot be split into two parts on the entry point string separator
aiida.plugins.factory.BaseFactory(group, name)[source]

Return the plugin class registered under a given entry point group and name

Parameters:
  • group – entry point group
  • name – entry point name
Returns:

the plugin class

aiida.plugins.factory.TransportFactory(entry_point)[source]

Return the Transport plugin class for a given entry point

Parameters:entry_point – the entry point name of the Transport plugin

Utilities for high-level querying of available plugins.

These tools read information from the cached registry. The plugin registry (in cache) is expected to be a dict where the keys are base entry point names of plugins (unique for registered plugins)

example registry:

registry = {
    'quantumespresso': {
        'name': 'aiida-quantumespresso',
        'package_name': 'aiida_quantumespresso',
        'pip_url': 'git+https://...',
        'other_key': 'other_value'
    }
    'vasp': {
        'name': aiida-vasp',
        'package_name': 'aiida_vasp',
        '...': '...'
    }
}
aiida.plugins.info.entry_point_from_tpstr(typestring)[source]
aiida.plugins.info.find_by_name(plugin_key)[source]

returns the pickled RegistryEntry object for a given plugin_key

aiida.plugins.info.find_by_pattern(pattern, ranking=False)[source]

returns a list of RegistryEntry objects for all matches

aiida.plugins.info.find_for_typestring(typestring)[source]

find the plugin with the base entry point name of the given typestring

Returns:dict with plugin keys if found, None if not found
aiida.plugins.info.plugin_ep_iterator()[source]

return an iterator over the plugin entrypoint base strings

class aiida.plugins.loader.EntryPoint(group, base_class)

Bases: tuple

__dict__ = dict_proxy({'base_class': <property object>, '__module__': 'aiida.plugins.loader', '__getstate__': <function __getstate__>, 'group': <property object>, '__new__': <staticmethod object>, '_make': <classmethod object>, '_replace': <function _replace>, '__slots__': (), '_asdict': <function _asdict>, '__repr__': <function __repr__>, '__dict__': <property object>, '_fields': ('group', 'base_class'), '__getnewargs__': <function __getnewargs__>, '__doc__': 'EntryPoint(group, base_class)'})
__getnewargs__()

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

__getstate__()

Exclude the OrderedDict from pickling

__module__ = 'aiida.plugins.loader'
static __new__(_cls, group, base_class)

Create new instance of EntryPoint(group, base_class)

__repr__()

Return a nicely formatted representation string

__slots__ = ()
_asdict()

Return a new OrderedDict which maps field names to their values

_fields = ('group', 'base_class')
classmethod _make(iterable, new=<built-in method __new__ of type object at 0x906d60>, len=<built-in function len>)

Make a new EntryPoint object from a sequence or iterable

_replace(**kwds)

Return a new EntryPoint object replacing specified fields with new values

base_class

Alias for field number 1

group

Alias for field number 0

aiida.plugins.loader.get_plugin_type_from_type_string(type_string)[source]

Take the type string of a Node and create the loadable plugin type string

Parameters:type_string – the value from the ‘type’ column of the Node table
Returns:the type string that can be used to load the plugin
aiida.plugins.loader.get_query_type_from_type_string(type_string)[source]

Take the type string of a Node and create the queryable type string

Parameters:type_string – the plugin_type_string attribute of a Node
Returns:the type string that can be used to query for
aiida.plugins.loader.get_type_string_from_class(class_module, class_name)[source]

Given the module and name of a class, determine the orm_class_type string, which codifies the orm class that is to be used. The returned string will always have a terminating period, which is required to query for the string in the database

Parameters:
  • class_module – module of the class
  • class_name – name of the class
aiida.plugins.loader.get_type_string_from_class_path(class_path)[source]

From a fully qualified orm class path, derive the orm class base string, which essentially means stripping the aiida.orm. and implementation.* prefixes. For the base node node.Node. the returned base string will be the empty string

Parameters:class_path – the full path of the orm class
Returns:the base string of the orm class
aiida.plugins.loader.load_plugin(plugin_type, safe=False)[source]

Load a plugin class from its plugin type, which is essentially its ORM type string minus the trailing period

Parameters:
  • plugin_type – the plugin type string
  • safe – when set to True, will always attempt to return the base class closest to the plugin_type if the actual entry point is not recognized
Returns:

the plugin class

Raises:
aiida.plugins.loader.strip_prefix(string, prefix)[source]

Strip the prefix from the given string and return it. If the prefix is not present the original string will be returned unaltered

Parameters:
  • string – the string from which to remove the prefix
  • prefix – the prefix to remove
Returns:

the string with prefix removed

Utilities for low-level querying of plugins.

Interface for operations that have to connect the registry online and that operate on the cache folder.

aiida.plugins.registry.cleanup_info(registry=None)[source]

delete any plugin info files that do not correspond to a registry entry

aiida.plugins.registry.load_cached()[source]

load the registry from the local cache if the local cache is not readable, create or update it

aiida.plugins.registry.load_online(errorhandler=None)[source]

loads the registry file and returns the list of plugins

aiida.plugins.registry.registry_cache_exists()[source]

check if the registry cache exists

Return bool:True if exists, False if not
aiida.plugins.registry.registry_cache_file_name()[source]

return the name of the registry cache file

aiida.plugins.registry.registry_cache_file_path()[source]

return the path to the cache file

aiida.plugins.registry.registry_cache_openable()[source]

return true if the registry cache file can be opened

aiida.plugins.registry.registry_file_url()[source]

return the url for the plugins.json file

aiida.plugins.registry.update(with_info=True, registry_err_handler=None, info_err_handler=None)[source]

Load the registry from its online location and pickle it.

Creates the cache file if necessary. By default updates the entry details cache for each entry as well.

Parameters:
  • with_info – default: True, update info cache for each entry as well
  • registry_err_handler – callable(exception) -> dict. Must either raise or return a registry dict
  • info_err_handler – callable(exception, plugin, data) -> None. Can raise or just print an error / warning.

If none of the error handlers are given, the function will stop execution if any broken links are encountered.

aiida.plugins.registry.update_info(registry=None, errorhandler=None)[source]

iterate through plugins, download setup info and return as dict

utilities for:

  • managing the registry cache folder
  • downloading json files
  • pickling to the registry cache folder
aiida.plugins.utils.load_json_from_url(url, errorhandler=None)[source]

downloads a json file and returns the corresponding python dict

aiida.plugins.utils.pickle_to_registry_cache_folder(obj, fname)[source]

pickles a python object to the registry cache folder

aiida.plugins.utils.registry_cache_folder_exists()[source]

return True if the cache folder exists, False if not

aiida.plugins.utils.registry_cache_folder_name()[source]

return the name of the subfolder of aiida_dir where registry caches are stored.

aiida.plugins.utils.registry_cache_folder_path()[source]

return the fully resolved path to the cache folder

aiida.plugins.utils.safe_create_registry_cache_folder()[source]

creates the registry cache folder if it does not exist

aiida.plugins.utils.unpickle_from_registry_cache_folder(fname)[source]

looks for fname in the registry cache folder and tries to unpickle from it

aiida.plugins.utils.value_error_msg(e)[source]