aiida.plugins package#

Classes and functions to load and interact with plugin classes accessible through defined entry points.

Submodules#

Module to manage loading entrypoints.

class aiida.plugins.entry_point.EntryPointFormat(value)[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.transports:core.ssh

  • PARTIAL: unprefixed group plus entry point name transports:core.ssh

  • MINIMAL: no group but only entry point name: core.ssh

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.convert_potentially_deprecated_entry_point(group: str, name: str) str[source]#

Check whether the specified entry point is deprecated, in which case print warning and convert to new name.

For aiida-core==2.0 all existing entry points where properly prefixed with core. and the old entry points were deprecated. To provide a smooth transition these deprecated entry points are detected in get_entry_point, which is the lowest function that tries to resolve an entry point string, by calling this function.

If the entry point corresponds to a deprecated one, a warning is raised and the new corresponding entry point name is returned.

This method should be removed in aiida-core==3.0.

aiida.plugins.entry_point.eps()[source]#
aiida.plugins.entry_point.format_entry_point_string(group: str, name: str, fmt: aiida.plugins.entry_point.EntryPointFormat = EntryPointFormat.FULL) str[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: str, name: str) importlib_metadata.EntryPoint[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.common.MissingEntryPointError – entry point was not registered

aiida.plugins.entry_point.get_entry_point_from_class(class_module: str, class_name: str) Tuple[Optional[str], Optional[importlib_metadata.EntryPoint]][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: str) importlib_metadata.EntryPoint[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
aiida.plugins.entry_point.get_entry_point_groups() Set[str][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: str, sort: bool = True) List[str][source]#

Return the entry points within a group.

aiida.plugins.entry_point.get_entry_point_string_format(entry_point_string: str) aiida.plugins.entry_point.EntryPointFormat[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

aiida.plugins.entry_point.get_entry_point_string_from_class(class_module: str, class_name: str) Optional[str][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: str) importlib_metadata.EntryPoints[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_registered_entry_point(class_module: str, class_name: str, groups: Optional[Sequence[str]] = None) bool[source]#

Verify whether the class with the given module and class name is a registered entry point.

Note

this function only checks whether the class has a registered entry point. It does explicitly not verify if the corresponding class is also importable. Use load_entry_point for this purpose instead.

Parameters
  • class_module – the module of the class

  • class_name – the name of the class

  • groups – optionally consider only these entry point groups to look for the class

Returns

True if the class is a registered entry point, False otherwise.

aiida.plugins.entry_point.is_valid_entry_point_string(entry_point_string: str) bool[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: str, name: str) Any[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
aiida.plugins.entry_point.load_entry_point_from_string(entry_point_string: str) Any[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
aiida.plugins.entry_point.parse_entry_point(group: str, spec: str) importlib_metadata.EntryPoint[source]#

Return an entry point, given its group and spec (as formatted in the setup)

aiida.plugins.entry_point.parse_entry_point_string(entry_point_string: str) Tuple[str, str][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.entry_point.validate_registered_entry_points() None[source]#

Validate all registered entry points by loading them with the corresponding factory.

Raises

EntryPointError – if any of the registered entry points cannot be loaded. This can happen if: * The entry point cannot uniquely be resolved * The resource registered at the entry point cannot be imported * The resource’s type is incompatible with the entry point group that it is defined in.

Definition of factories to load classes from the various plugin groups.

aiida.plugins.factories.BaseFactory(group: str, name: str, load: bool = True) Union[importlib_metadata.EntryPoint, Any][source]#

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

Parameters
  • group – entry point group

  • name – entry point name

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

the plugin class

Raises
aiida.plugins.factories.CalcJobImporterFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, CalcJobImporter]][source]#

Return the plugin registered under the given entry point.

Parameters

entry_point_name – the entry point name.

Returns

the loaded CalcJobImporter plugin.

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.CalculationFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, CalcJob, Callable]][source]#

Return the CalcJob sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of CalcJob

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.DataFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, Data]][source]#

Return the Data sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of Data

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.DbImporterFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, DbImporter]][source]#

Return the DbImporter sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of DbImporter

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.GroupFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, Group]][source]#

Return the Group sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of Group

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.OrbitalFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, Orbital]][source]#

Return the Orbital sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of Orbital

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.ParserFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, Parser]][source]#

Return the Parser sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of Parser

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.SchedulerFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, Scheduler]][source]#

Return the Scheduler sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of Scheduler

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.StorageFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, StorageBackend]][source]#

Return the StorageBackend sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of StorageBackend.

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.TransportFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, Type[Transport]]][source]#

Return the Transport sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.WorkflowFactory(entry_point_name: str, load: bool = True) Optional[Union[importlib_metadata.EntryPoint, WorkChain, Callable]][source]#

Return the WorkChain sub class registered under the given entry point.

Parameters
  • entry_point_name – the entry point name.

  • load – if True, load the matched entry point and return the loaded resource instead of the entry point itself.

Returns

sub class of WorkChain or a workfunction

Raises

aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.

aiida.plugins.factories.raise_invalid_type_error(entry_point_name: str, entry_point_group: str, valid_classes: Tuple[Any, ...]) None[source]#

Raise an InvalidEntryPointTypeError with formatted message.

Parameters
  • entry_point_name – name of the entry point

  • entry_point_group – name of the entry point group

  • valid_classes – tuple of valid classes for the given entry point group

Raises

aiida.common.InvalidEntryPointTypeError – always

Utilities dealing with plugins and entry points.

class aiida.plugins.utils.PluginVersionProvider[source]#

Bases: object

Utility class that determines version information about a given plugin resource.

__dict__ = mappingproxy({'__module__': 'aiida.plugins.utils', '__doc__': 'Utility class that determines version information about a given plugin resource.', '__init__': <function PluginVersionProvider.__init__>, 'logger': <property object>, 'get_version_info': <function PluginVersionProvider.get_version_info>, '__dict__': <attribute '__dict__' of 'PluginVersionProvider' objects>, '__weakref__': <attribute '__weakref__' of 'PluginVersionProvider' objects>, '__annotations__': {'_cache': 'dict[type, dict[t.Any, dict[t.Any, t.Any]]]', '_logger': 'Logger'}})#
__init__()[source]#
__module__ = 'aiida.plugins.utils'#
__weakref__#

list of weak references to the object (if defined)

get_version_info(plugin: str | type) dict[t.Any, dict[t.Any, t.Any]][source]#

Get the version information for a given plugin.

Note

This container will keep a cache, so if this method was already called for the given plugin before for this instance, the result computed at the last invocation will be returned.

Parameters

plugin – A class, function, or an entry point string. If the type is string, it will be assumed to be an entry point string and the class will attempt to load it first. It should be a full entry point string, including the entry point group.

Returns

Dictionary with the version.core and optionally version.plugin if it could be determined.

Raises
  • EntryPointError – If plugin is a string but could not be loaded as a valid entry point.

  • TypeError – If plugin (or the resource pointed to it in the case of an entry point) is not a class or a function.

property logger: logging.Logger#