def CalculationFactory(entry_point_name): """Return the `CalcJob` sub class registered under the given entry point. :param entry_point_name: the entry point name :return: sub class of :py:class:`~aiida.engine.processes.calcjobs.calcjob.CalcJob` :raises aiida.common.InvalidEntryPointTypeError: if the type of the loaded entry point is invalid. """ from aiida.engine import CalcJob, calcfunction, is_process_function from aiida.orm import CalcFunctionNode entry_point_group = 'aiida.calculations' entry_point = BaseFactory(entry_point_group, entry_point_name) valid_classes = (CalcJob, calcfunction) if isclass(entry_point) and issubclass(entry_point, CalcJob): return entry_point if is_process_function(entry_point) and entry_point.node_class is CalcFunctionNode: return entry_point raise_invalid_type_error(entry_point_name, entry_point_group, valid_classes)
def WorkflowFactory(entry_point_name): """Return the `WorkChain` sub class registered under the given entry point. :param entry_point_name: the entry point name :return: sub class of :py:class:`~aiida.engine.processes.workchains.workchain.WorkChain` or a `workfunction` :raises aiida.common.InvalidEntryPointTypeError: if the type of the loaded entry point is invalid. """ from aiida.engine import WorkChain, is_process_function, workfunction from aiida.orm import WorkFunctionNode entry_point_group = 'aiida.workflows' entry_point = BaseFactory(entry_point_group, entry_point_name) valid_classes = (WorkChain, workfunction) if isclass(entry_point) and issubclass(entry_point, WorkChain): return entry_point if is_process_function(entry_point) and entry_point.node_class is WorkFunctionNode: return entry_point raise_invalid_type_error(entry_point_name, entry_point_group, valid_classes)