def main(): # Log to the console console = logging.StreamHandler() console.setFormatter(logging.Formatter("[%(levelname)s] %(name)s : %(message)s")) logging.getLogger("add").addHandler(console) logging.getLogger("add").setLevel(logging.DEBUG) code = load_code(label="add@localhost") calculation = CalculationFactory("add.calculation") builder = calculation.get_builder() builder.code = code builder.x = Float(3.0) builder.y = Float(3.5) builder.metadata.options = {"resources": {"num_machines": 1}} results, node = run.get_node(builder) print(results, node, sep="\n")
# pylint: disable=unused-argument,redefined-outer-name """Performance benchmark tests for local processes. The purpose of these tests is to benchmark and compare processes, which are executed *via* both a local runner and the daemon. """ import asyncio import pytest from aiida.engine import run_get_node, submit, while_, WorkChain from aiida.manage.manager import get_manager from aiida.orm import Code, Int from aiida.plugins.factories import CalculationFactory ArithmeticAddCalculation = CalculationFactory('arithmetic.add') class WorkchainLoop(WorkChain): """A basic Workchain to run a looped step n times.""" @classmethod def define(cls, spec): super().define(spec) spec.input('iterations', required=True) spec.input('code', required=False) spec.outline(cls.init_loop, while_(cls.terminate_loop)(cls.run_task)) def init_loop(self): self.ctx.iter = self.inputs.iterations.value self.ctx.counter = 0