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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
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 inget_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() EntryPoints [source]#
Cache around entry_points()
This call takes around 50ms! NOTE: For faster lookups, we sort the
EntryPoints
alphabetically by the group name so that ‘aiida.’ groups come up first. Unfortunately, this does not help with the entry_points.select() filter, which will always iterate over all entry points since it looks for possible duplicate entries.
- aiida.plugins.entry_point.eps_select(group: str, name: str | None = None) EntryPoints [source]#
A thin wrapper around entry_points.select() calls, which are expensive so we want to cache them.
- aiida.plugins.entry_point.format_entry_point_string(group: str, name: str, fmt: 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) 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[str | None, EntryPoint | None] [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) 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:
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.common.MissingEntryPointError – entry point was not registered
aiida.common.MultipleEntryPointError – entry point could not be uniquely resolved
- 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) 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) str | None [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) 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: Sequence[str] | None = 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:
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.common.MissingEntryPointError – entry point was not registered
aiida.common.MultipleEntryPointError – entry point could not be uniquely resolved
aiida.common.LoadingEntryPointError – entry point could not be loaded
- 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:
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.common.MissingEntryPointError – entry point was not registered
aiida.common.MultipleEntryPointError – entry point could not be uniquely resolved
aiida.common.LoadingEntryPointError – entry point could not be loaded
- aiida.plugins.entry_point.parse_entry_point(group: str, spec: str) 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) 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.common.MissingEntryPointError – entry point was not registered
aiida.common.MultipleEntryPointError – entry point could not be uniquely resolved
aiida.common.LoadingEntryPointError – entry point could not be loaded
- aiida.plugins.factories.BrokerFactory(entry_point_name: str, load: Literal[True] = True) Type['Broker'] [source]#
- aiida.plugins.factories.BrokerFactory(entry_point_name: str, load: Literal[False]) EntryPoint
Return the Broker 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
Broker
- Raises:
aiida.common.InvalidEntryPointTypeError – if the type of the loaded entry point is invalid.
- aiida.plugins.factories.CalcJobImporterFactory(entry_point_name: str, load: Literal[True] = True) Type['CalcJobImporter'] [source]#
- aiida.plugins.factories.CalcJobImporterFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['CalcJob'] | Callable [source]#
- aiida.plugins.factories.CalculationFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['Data'] [source]#
- aiida.plugins.factories.DataFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['DbImporter'] [source]#
- aiida.plugins.factories.DbImporterFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['Group'] [source]#
- aiida.plugins.factories.GroupFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['Orbital'] [source]#
- aiida.plugins.factories.OrbitalFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['Parser'] [source]#
- aiida.plugins.factories.ParserFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['Scheduler'] [source]#
- aiida.plugins.factories.SchedulerFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['StorageBackend'] [source]#
- aiida.plugins.factories.StorageFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['Transport'] [source]#
- aiida.plugins.factories.TransportFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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: Literal[True] = True) Type['WorkChain'] | Callable [source]#
- aiida.plugins.factories.WorkflowFactory(entry_point_name: str, load: Literal[False]) EntryPoint
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, ...]) NoReturn [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:
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 | FunctionType, dict[t.Any, dict[t.Any, t.Any]]]', '_logger': 'Logger'}})#
- __module__ = 'aiida.plugins.utils'#
- __weakref__#
list of weak references to the object
- get_version_info(plugin: str | type) dict[Any, dict[Any, 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.