From 2774f568f66660e1e6d81a4e2df23e566368bd5d Mon Sep 17 00:00:00 2001 From: superstar54 Date: Sun, 18 Aug 2024 13:59:01 +0200 Subject: [PATCH 1/5] Add "awatiable_builder" decorator --- aiida_workgraph/decorator.py | 17 +++++++ aiida_workgraph/engine/utils.py | 76 +++++++++++++++++++++++++++++ aiida_workgraph/engine/workgraph.py | 40 ++++++++++++--- 3 files changed, 127 insertions(+), 6 deletions(-) diff --git a/aiida_workgraph/decorator.py b/aiida_workgraph/decorator.py index 68c53fdb..00ffa515 100644 --- a/aiida_workgraph/decorator.py +++ b/aiida_workgraph/decorator.py @@ -663,6 +663,23 @@ def decorator(func): return decorator + @staticmethod + @nonfunctional_usage + def awaitable_builder(**kwargs: Any) -> Callable: + def decorator(func): + # Then, apply task decorator + task_decorated = build_task_from_callable( + func, + inputs=kwargs.get("inputs", []), + outputs=kwargs.get("outputs", []), + ) + task_decorated.node_type = "awaitable_builder" + func.identifier = "awaitable_builder" + func.task = func.node = task_decorated + return func + + return decorator + # Making decorator_task accessible as 'task' task = decorator_task diff --git a/aiida_workgraph/engine/utils.py b/aiida_workgraph/engine/utils.py index 90b4d89c..3e146ff0 100644 --- a/aiida_workgraph/engine/utils.py +++ b/aiida_workgraph/engine/utils.py @@ -1,6 +1,19 @@ +from __future__ import annotations from aiida_workgraph.orm.serializer import serialize_to_aiida_nodes from aiida import orm from aiida.common.extendeddicts import AttributeDict +from aiida.engine.utils import instantiate_process, prepare_inputs +from aiida.manage import manager +from aiida.engine import run_get_node +from aiida.common import InvalidOperation +from aiida.common.log import AIIDA_LOGGER +from aiida.engine.processes import Process, ProcessBuilder +from aiida.orm import ProcessNode +import typing as t +import time + +TYPE_SUBMIT_PROCESS = t.Union[Process, t.Type[Process], ProcessBuilder] +LOGGER = AIIDA_LOGGER.getChild("engine.launch") def prepare_for_workgraph_task(task: dict, kwargs: dict) -> tuple: @@ -142,3 +155,66 @@ def prepare_for_shell_task(task: dict, kwargs: dict) -> dict: "metadata": metadata or {}, } return inputs + + +# modified from aiida.engine.submit +# do not check the scope of the process +def submit( + process: TYPE_SUBMIT_PROCESS, + inputs: dict[str, t.Any] | None = None, + *, + wait: bool = False, + wait_interval: int = 5, + **kwargs: t.Any, +) -> ProcessNode: + """Submit the process with the supplied inputs to the daemon immediately returning control to the interpreter. + + .. warning: this should not be used within another process. Instead, there one should use the ``submit`` method of + the wrapping process itself, i.e. use ``self.submit``. + + .. warning: submission of processes requires ``store_provenance=True``. + + :param process: the process class, instance or builder to submit + :param inputs: the input dictionary to be passed to the process + :param wait: when set to ``True``, the submission will be blocking and wait for the process to complete at which + point the function returns the calculation node. + :param wait_interval: the number of seconds to wait between checking the state of the process when ``wait=True``. + :param kwargs: inputs to be passed to the process. This is an alternative to the positional ``inputs`` argument. + :return: the calculation node of the process + """ + inputs = prepare_inputs(inputs, **kwargs) + + runner = manager.get_manager().get_runner() + assert runner.persister is not None, "runner does not have a persister" + assert runner.controller is not None, "runner does not have a controller" + + process_inited = instantiate_process(runner, process, **inputs) + + # If a dry run is requested, simply forward to `run`, because it is not compatible with `submit`. We choose for this + # instead of raising, because in this way the user does not have to change the launcher when testing. The same goes + # for if `remote_folder` is present in the inputs, which means we are importing an already completed calculation. + if process_inited.metadata.get("dry_run", False) or "remote_folder" in inputs: + _, node = run_get_node(process_inited) + return node + + if not process_inited.metadata.store_provenance: + raise InvalidOperation("cannot submit a process with `store_provenance=False`") + + runner.persister.save_checkpoint(process_inited) + process_inited.close() + + # Do not wait for the future's result, because in the case of a single worker this would cock-block itself + runner.controller.continue_process(process_inited.pid, nowait=False, no_reply=True) + node = process_inited.node + + if not wait: + return node + + while not node.is_terminated: + LOGGER.report( + f"Process<{node.pk}> has not yet terminated, current state is `{node.process_state}`. " + f"Waiting for {wait_interval} seconds." + ) + time.sleep(wait_interval) + + return node diff --git a/aiida_workgraph/engine/workgraph.py b/aiida_workgraph/engine/workgraph.py index 866daa0b..d41714d2 100644 --- a/aiida_workgraph/engine/workgraph.py +++ b/aiida_workgraph/engine/workgraph.py @@ -40,7 +40,8 @@ __all__ = "WorkGraph" -MAX_NUMBER_AWAITABLES_MSG = "The maximum number of subprocesses has been reached: {}. Cannot launch the job: {}." +MAX_NUMBER_AWAITABLES_MSG = "The maximum number of subprocesses has been reached: {}.\ +Waiting for other jobs to finish before launching the {}." @auto_persist("_awaitables") @@ -289,6 +290,9 @@ def _do_step(self) -> t.Any: else: finished, result = self.is_workgraph_finished() + if self._awaitables: + return Wait(self._do_step, "Waiting before next step") + # If the workgraph is finished or the result is an ExitCode, we exit by returning if finished: if isinstance(result, ExitCode): @@ -296,9 +300,6 @@ def _do_step(self) -> t.Any: else: return self.finalize() - if self._awaitables: - return Wait(self._do_step, "Waiting before next step") - return Continue(self._do_step) def _store_nodes(self, data: t.Any) -> None: @@ -390,7 +391,10 @@ def _on_awaitable_finished(self, awaitable: Awaitable) -> None: # node finished, update the task state and result # udpate the task state - self.update_task_state(awaitable.key) + if awaitable.key in self.ctx._tasks: + self.update_task_state(awaitable.key) + else: + self.report(f"Awaitable {awaitable.key} finished.") # try to resume the workgraph, if the workgraph is already resumed # by other awaitable, this will not work try: @@ -870,9 +874,10 @@ def run_tasks(self, names: t.List[str], continue_workgraph: bool = True) -> None "WORKGRAPH", "PYTHONJOB", "SHELLJOB", + "AWAITABLE_BUILDER", ]: if len(self._awaitables) >= self.ctx._max_number_awaitables: - print( + self.report( MAX_NUMBER_AWAITABLES_MSG.format( self.ctx._max_number_awaitables, name ) @@ -1066,6 +1071,29 @@ def run_tasks(self, names: t.List[str], continue_workgraph: bool = True) -> None self.set_task_state_info(name, "state", "FINISHED") self.update_parent_task_state(name) self.continue_workgraph() + elif task["metadata"]["node_type"].upper() in ["AWAITABLE_BUILDER"]: + # create the awaitable + for key in self.ctx._tasks[name]["metadata"]["args"]: + kwargs.pop(key, None) + results = self.run_executor( + executor, args, kwargs, var_args, var_kwargs + ) + if not isinstance(results, dict): + self.report("The results of the awaitable builder must be a dict.") + for key, value in results.items(): + if not isinstance(value, ProcessNode): + self.report( + f"The value of key {key} is not an instance of ProcessNode." + ) + self.set_task_state_info(name, "state", "Failed") + self.set_task_state_info(name, "state", "Failed") + self.report(f"Task: {name} failed.") + else: + self.set_task_state_info(name, "state", "FINISHED") + self.to_context(**results) + self.report(f"Task: {name} finished.") + self.update_parent_task_state(name) + self.continue_workgraph() elif task["metadata"]["node_type"].upper() in ["NORMAL"]: # normal function does not have a process if "context" in task["metadata"]["kwargs"]: From 0ba9c4fdf4a61db788f13091536a79e4a7630f18 Mon Sep 17 00:00:00 2001 From: superstar54 Date: Mon, 19 Aug 2024 09:47:01 +0200 Subject: [PATCH 2/5] While zone evaludate the condition tasks --- aiida_workgraph/engine/workgraph.py | 69 +++++++++++++++++++---------- aiida_workgraph/utils/analysis.py | 4 +- tests/test_while.py | 40 +++++++---------- 3 files changed, 63 insertions(+), 50 deletions(-) diff --git a/aiida_workgraph/engine/workgraph.py b/aiida_workgraph/engine/workgraph.py index 866daa0b..f77310f2 100644 --- a/aiida_workgraph/engine/workgraph.py +++ b/aiida_workgraph/engine/workgraph.py @@ -560,7 +560,7 @@ def reset_task( if reset_process: self.set_task_state_info(name, "process", None) self.remove_executed_task(name) - self.report(f"Task {name} action: RESET.") + # self.report(f"Task {name} action: RESET.") # if the task is a while task, reset its child tasks if self.ctx._tasks[name]["metadata"]["node_type"].upper() == "WHILE": if reset_execution_count: @@ -667,15 +667,17 @@ def update_while_task_state(self, name: str) -> None: finished, _ = self.are_childen_finished(name) if finished: - should_run = self.should_run_while_task(name) - if should_run: - # Run the next loop. - # Do not reset the execution count - self.reset_task(name, reset_execution_count=False) - else: - self.set_task_state_info(name, "state", "FINISHED") - self.update_parent_task_state(name) - self.report(f"Task: {name} finished.") + self.report( + f"Wihle Task {name}: this iteration finished. Try to reset for the next iteration." + ) + # reset the condition tasks + for input in self.ctx._tasks[name]["inputs"]: + if input["name"].upper() == "CONDITIONS": + for link in input["links"]: + self.reset_task(link["from_node"], recursive=False) + # reset the task and all its children, so that the task can run again + # do not reset the execution count + self.reset_task(name, reset_execution_count=False) def update_zone_task_state(self, name: str) -> None: """Update zone task state.""" @@ -688,15 +690,29 @@ def update_zone_task_state(self, name: str) -> None: def should_run_while_task(self, name: str) -> tuple[bool, t.Any]: """Check if the while task should run.""" # check the conditions of the while task - task = self.ctx._tasks[name] not_excess_max_iterations = ( self.ctx._tasks[name]["execution_count"] < self.ctx._tasks[name]["properties"]["max_iterations"]["value"] ) conditions = [not_excess_max_iterations] - for condition in task["properties"]["conditions"]["value"]: - value = get_nested_dict(self.ctx, condition) - conditions.append(value) + _, kwargs, _, _, _ = self.get_inputs(name) + if isinstance(kwargs["conditions"], list): + for condition in kwargs["conditions"]: + value = get_nested_dict(self.ctx, condition) + conditions.append(value) + elif isinstance(kwargs["conditions"], dict): + for _, value in kwargs["conditions"].items(): + conditions.append(value) + else: + conditions.append(kwargs["conditions"]) + should_run = False not in conditions + if not should_run: + self.set_task_state_info(name, "state", "FINISHED") + self.set_tasks_state(self.ctx._tasks[name]["children"], "SKIPPED") + self.update_parent_task_state(name) + self.report( + f"While Task {name}: Condition not fullilled, task finished. Skip all its children." + ) return False not in conditions def should_run_if_task(self, name: str) -> tuple[bool, t.Any]: @@ -1034,14 +1050,8 @@ def run_tasks(self, names: t.List[str], continue_workgraph: bool = True) -> None self.to_context(**{name: process}) elif task["metadata"]["node_type"].upper() in ["WHILE"]: # check the conditions of the while task - should_run = self.should_run_while_task(name) - if should_run: - task["execution_count"] += 1 - self.set_task_state_info(name, "state", "RUNNING") - else: - self.set_tasks_state(task["children"], "FINISHED") - self.update_while_task_state(name) - self.continue_workgraph() + task["execution_count"] += 1 + self.set_task_state_info(name, "state", "RUNNING") elif task["metadata"]["node_type"].upper() in ["IF"]: should_run = self.should_run_if_task(name) if should_run: @@ -1218,8 +1228,8 @@ def is_task_ready_to_run(self, name: str) -> t.Tuple[bool, t.Optional[str]]: For task inside a zone, we need to check if the zone (parent task) is ready. """ parent_task = self.ctx._tasks[name]["parent_task"] - # input_tasks, parent_task - parent_states = [True, True] + # input_tasks, parent_task, conditions + parent_states = [True, True, True] # if the task belongs to a parent zone if parent_task[0]: state = self.get_task_state_info(parent_task[0], "state") @@ -1235,6 +1245,15 @@ def is_task_ready_to_run(self, name: str) -> t.Tuple[bool, t.Optional[str]]: ]: parent_states[0] = False break + # check the conditions of the while zone + if self.ctx._tasks[name]["metadata"]["node_type"].upper() == "WHILE": + # only if the parent task is ready, we check the conditions + if parent_states[0] and parent_states[1]: + should_run = self.should_run_while_task(name) + if not should_run: + parent_states[2] = False + else: + parent_states[2] = False return all(parent_states), parent_states @@ -1250,6 +1269,8 @@ def set_tasks_state( """Set tasks state""" for name in tasks: self.set_task_state_info(name, "state", value) + if "children" in self.ctx._tasks[name]: + self.set_tasks_state(self.ctx._tasks[name]["children"], value) def run_executor( self, diff --git a/aiida_workgraph/utils/analysis.py b/aiida_workgraph/utils/analysis.py index 405ee153..d6d364a5 100644 --- a/aiida_workgraph/utils/analysis.py +++ b/aiida_workgraph/utils/analysis.py @@ -63,8 +63,8 @@ def save(self) -> None: - If in database, analyze the difference, save accordingly. """ self.build_task_link() - self.build_connectivity() self.assign_zone() + self.build_connectivity() self.update_parent_task() self.find_all_zones_inputs() if self.exist_in_db() or self.restart_process is not None: @@ -103,7 +103,6 @@ def build_task_link(self) -> None: def assign_zone(self) -> None: """Assign zone for each task.""" - self.wgdata["connectivity"]["zone"] = {} # assign parent_task for each task for name, task in self.wgdata["tasks"].items(): for child_task in task["children"]: @@ -314,3 +313,4 @@ def build_connectivity(self) -> None: self.wgdata["nodes"] = self.wgdata["tasks"] nc = ConnectivityAnalysis(self.wgdata) self.wgdata["connectivity"] = nc.build_connectivity() + self.wgdata["connectivity"]["zone"] = {} diff --git a/tests/test_while.py b/tests/test_while.py index 6ffc6a89..c47ab75d 100644 --- a/tests/test_while.py +++ b/tests/test_while.py @@ -3,7 +3,6 @@ from aiida import orm -@pytest.mark.usefixtures("started_daemon_client") def test_while_task(decorated_add, decorated_compare): """Test nested while task. Also test the max_iteration parameter.""" @@ -40,63 +39,56 @@ def raw_python_code(): wg = WorkGraph("test_while_task") # set a context variable before running. wg.context = { - "should_run1": True, - "should_run2": True, - "should_run3": True, "m": 1, "l": 1, } add1 = wg.add_task(decorated_add, name="add1", x=1, y=1) add1.set_context({"result": "n"}) # --------------------------------------------------------------------- - while1 = wg.add_task("While", name="while1", conditions=["should_run1"]) + # the `result` of compare1 taskis used as condition + compare1 = wg.add_task(decorated_compare, name="compare1", x="{{m}}", y=10) + while1 = wg.add_task("While", name="while1", conditions=compare1.outputs["result"]) add11 = wg.add_task(decorated_add, name="add11", x=1, y=1) # --------------------------------------------------------------------- - while2 = wg.add_task("While", name="while2", conditions=["should_run2"]) + compare2 = wg.add_task(decorated_compare, name="compare2", x="{{n}}", y=5) + while2 = wg.add_task("While", name="while2", conditions=compare2.outputs["result"]) add21 = wg.add_task( decorated_add, name="add21", x="{{n}}", y=add11.outputs["result"] ) add21.waiting_on.add("add1") add22 = wg.add_task(decorated_add, name="add22", x=add21.outputs["result"], y=1) add22.set_context({"result": "n"}) - compare2 = wg.add_task( - decorated_compare, name="compare2", x=add22.outputs["result"], y=5 - ) - compare2.set_context({"result": "should_run2"}) - while2.children.add(["add21", "add22", "compare2"]) + while2.children.add(["add21", "add22"]) # --------------------------------------------------------------------- + compare3 = wg.add_task(decorated_compare, name="compare3", x="{{l}}", y=5) while3 = wg.add_task( - "While", name="while3", max_iterations=1, conditions=["should_run3"] + "While", name="while3", max_iterations=1, conditions=compare3.outputs["result"] ) add31 = wg.add_task(decorated_add, name="add31", x="{{l}}", y=1) add31.waiting_on.add("add22") add32 = wg.add_task(decorated_add, name="add32", x=add31.outputs["result"], y=1) add32.set_context({"result": "l"}) - compare3 = wg.add_task( - decorated_compare, name="compare3", x=add32.outputs["result"], y=5 - ) - compare3.set_context({"result": "should_run3"}) - while3.children.add(["add31", "add32", "compare3"]) + while3.children.add(["add31", "add32"]) # --------------------------------------------------------------------- add12 = wg.add_task( decorated_add, name="add12", x="{{m}}", y=add32.outputs["result"] ) add12.set_context({"result": "m"}) - compare1 = wg.add_task( - decorated_compare, name="compare1", x=add12.outputs["result"], y=10 - ) - compare1.set_context({"result": "should_run1"}) - while1.children.add(["add11", "while2", "while3", "add12", "compare1"]) - # the `result` of compare1 taskis used as condition + while1.children.add(["add11", "while2", "while3", "add12", "compare2", "compare3"]) # --------------------------------------------------------------------- add2 = wg.add_task( decorated_add, name="add2", x=add12.outputs["result"], y=add31.outputs["result"] ) # wg.submit(wait=True, timeout=100) wg.run() - assert add2.outputs["result"].value == raw_python_code() + # print out the node labels and the results for debugging + for link in wg.process.base.links.get_outgoing().all(): + if isinstance(link.node, orm.ProcessNode): + print(link.node.label, link.node.outputs.result) + assert add2.outputs["result"].value.value == raw_python_code().value +@pytest.mark.usefixtures("started_daemon_client") def test_while_workgraph(decorated_add, decorated_multiply, decorated_compare): # Create a WorkGraph will repeat itself based on the conditions wg = WorkGraph("while_workgraph") From 62b891fd322bfd49fe176148b3ff37299e474987 Mon Sep 17 00:00:00 2001 From: superstar54 Date: Mon, 19 Aug 2024 13:06:11 +0200 Subject: [PATCH 3/5] fix test --- aiida_workgraph/engine/workgraph.py | 3 ++- tests/test_workgraph.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/aiida_workgraph/engine/workgraph.py b/aiida_workgraph/engine/workgraph.py index f77310f2..77901956 100644 --- a/aiida_workgraph/engine/workgraph.py +++ b/aiida_workgraph/engine/workgraph.py @@ -560,7 +560,7 @@ def reset_task( if reset_process: self.set_task_state_info(name, "process", None) self.remove_executed_task(name) - # self.report(f"Task {name} action: RESET.") + # self.logger.debug(f"Task {name} action: RESET.") # if the task is a while task, reset its child tasks if self.ctx._tasks[name]["metadata"]["node_type"].upper() == "WHILE": if reset_execution_count: @@ -1052,6 +1052,7 @@ def run_tasks(self, names: t.List[str], continue_workgraph: bool = True) -> None # check the conditions of the while task task["execution_count"] += 1 self.set_task_state_info(name, "state", "RUNNING") + self.continue_workgraph() elif task["metadata"]["node_type"].upper() in ["IF"]: should_run = self.should_run_if_task(name) if should_run: diff --git a/tests/test_workgraph.py b/tests/test_workgraph.py index fdf45546..b984847a 100644 --- a/tests/test_workgraph.py +++ b/tests/test_workgraph.py @@ -71,7 +71,8 @@ def test_reset_message(wg_calcjob): wg.save() wg.wait() report = get_workchain_report(wg.process, "REPORT") - assert "Task add2 action: RESET." in report + print(report) + assert "Action: reset. {'add2'}" in report def test_restart(wg_calcfunction): From 3654c71caf2ee9de3fc8af6cc7e69425351814c5 Mon Sep 17 00:00:00 2001 From: superstar54 Date: Mon, 19 Aug 2024 13:25:08 +0200 Subject: [PATCH 4/5] move while condition check logic to run_tasks --- aiida_workgraph/engine/workgraph.py | 34 +++++++++++------------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/aiida_workgraph/engine/workgraph.py b/aiida_workgraph/engine/workgraph.py index 77901956..b807d4cb 100644 --- a/aiida_workgraph/engine/workgraph.py +++ b/aiida_workgraph/engine/workgraph.py @@ -705,14 +705,6 @@ def should_run_while_task(self, name: str) -> tuple[bool, t.Any]: conditions.append(value) else: conditions.append(kwargs["conditions"]) - should_run = False not in conditions - if not should_run: - self.set_task_state_info(name, "state", "FINISHED") - self.set_tasks_state(self.ctx._tasks[name]["children"], "SKIPPED") - self.update_parent_task_state(name) - self.report( - f"While Task {name}: Condition not fullilled, task finished. Skip all its children." - ) return False not in conditions def should_run_if_task(self, name: str) -> tuple[bool, t.Any]: @@ -1050,9 +1042,18 @@ def run_tasks(self, names: t.List[str], continue_workgraph: bool = True) -> None self.to_context(**{name: process}) elif task["metadata"]["node_type"].upper() in ["WHILE"]: # check the conditions of the while task - task["execution_count"] += 1 - self.set_task_state_info(name, "state", "RUNNING") - self.continue_workgraph() + should_run = self.should_run_while_task(name) + if not should_run: + self.set_task_state_info(name, "state", "FINISHED") + self.set_tasks_state(self.ctx._tasks[name]["children"], "SKIPPED") + self.update_parent_task_state(name) + self.report( + f"While Task {name}: Condition not fullilled, task finished. Skip all its children." + ) + else: + task["execution_count"] += 1 + self.set_task_state_info(name, "state", "RUNNING") + self.continue_workgraph() elif task["metadata"]["node_type"].upper() in ["IF"]: should_run = self.should_run_if_task(name) if should_run: @@ -1230,7 +1231,7 @@ def is_task_ready_to_run(self, name: str) -> t.Tuple[bool, t.Optional[str]]: """ parent_task = self.ctx._tasks[name]["parent_task"] # input_tasks, parent_task, conditions - parent_states = [True, True, True] + parent_states = [True, True] # if the task belongs to a parent zone if parent_task[0]: state = self.get_task_state_info(parent_task[0], "state") @@ -1246,15 +1247,6 @@ def is_task_ready_to_run(self, name: str) -> t.Tuple[bool, t.Optional[str]]: ]: parent_states[0] = False break - # check the conditions of the while zone - if self.ctx._tasks[name]["metadata"]["node_type"].upper() == "WHILE": - # only if the parent task is ready, we check the conditions - if parent_states[0] and parent_states[1]: - should_run = self.should_run_while_task(name) - if not should_run: - parent_states[2] = False - else: - parent_states[2] = False return all(parent_states), parent_states From 8e0d8db191ab6462c9992575e163d24c8eaf0980 Mon Sep 17 00:00:00 2001 From: superstar54 Date: Mon, 19 Aug 2024 13:44:21 +0200 Subject: [PATCH 5/5] update docs --- aiida_workgraph/tasks/builtins.py | 3 +- .../howto/html/while_graph_builder.html | 6 +- docs/source/howto/html/while_task.html | 6 +- docs/source/howto/while.ipynb | 1512 +++++++++-------- 4 files changed, 781 insertions(+), 746 deletions(-) diff --git a/aiida_workgraph/tasks/builtins.py b/aiida_workgraph/tasks/builtins.py index b78a151b..48f7e386 100644 --- a/aiida_workgraph/tasks/builtins.py +++ b/aiida_workgraph/tasks/builtins.py @@ -49,7 +49,8 @@ def create_sockets(self) -> None: inp.link_limit = 100000 inp = self.inputs.new("node_graph.int", "max_iterations") inp.add_property("node_graph.int", default=10000) - self.inputs.new("workgraph.any", "conditions") + inp = self.inputs.new("workgraph.any", "conditions") + inp.link_limit = 100000 self.outputs.new("workgraph.any", "_wait") diff --git a/docs/source/howto/html/while_graph_builder.html b/docs/source/howto/html/while_graph_builder.html index 6c18b93e..ae09e814 100644 --- a/docs/source/howto/html/while_graph_builder.html +++ b/docs/source/howto/html/while_graph_builder.html @@ -61,7 +61,7 @@ const { RenderUtils } = ReteRenderUtils; const styled = window.styled; - const workgraphData = {"name": "while_graph_builder", "uuid": "5ed48c82-59a5-11ef-be18-906584de3e5b", "state": "CREATED", "nodes": {"add1": {"label": "add1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "5edef820-59a5-11ef-be18-906584de3e5b", "node_uuid": "5edef1ea-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "5edef884-59a5-11ef-be18-906584de3e5b", "node_uuid": "5edef1ea-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}], "outputs": [{"name": "result"}], "position": [30, 30], "children": []}, "add_multiply_while1": {"label": "add_multiply_while1", "node_type": "graph_builder", "inputs": [{"name": "n", "identifier": "node_graph.any", "uuid": "5ee7731a-59a5-11ef-be18-906584de3e5b", "node_uuid": "5ee770b8-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "add1", "from_socket": "result", "from_socket_uuid": "5edef974-59a5-11ef-be18-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "n"}], "outputs": [{"name": "result"}], "position": [60, 60], "children": []}, "add2": {"label": "add2", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "5eef9f40-59a5-11ef-be18-906584de3e5b", "node_uuid": "5eef990a-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "add_multiply_while1", "from_socket": "result", "from_socket_uuid": "5ee77504-59a5-11ef-be18-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "5eef9fb8-59a5-11ef-be18-906584de3e5b", "node_uuid": "5eef990a-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [], "position": [90, 90], "children": []}}, "links": [{"from_socket": "result", "from_node": "add1", "from_socket_uuid": "5edef974-59a5-11ef-be18-906584de3e5b", "to_socket": "n", "to_node": "add_multiply_while1", "state": false}, {"from_socket": "result", "from_node": "add_multiply_while1", "from_socket_uuid": "5ee77504-59a5-11ef-be18-906584de3e5b", "to_socket": "x", "to_node": "add2", "state": false}]} + const workgraphData = {"name": "while_graph_builder", "uuid": "2d2b65dc-5e20-11ef-9a7c-906584de3e5b", "state": "CREATED", "nodes": {"add1": {"label": "add1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "2d34d1c6-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "2d34caaa-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "2d34d22a-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "2d34caaa-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}], "outputs": [{"name": "result"}], "position": [30, 30], "children": []}, "add_multiply_while1": {"label": "add_multiply_while1", "node_type": "GRAPH_BUILDER", "inputs": [{"name": "n", "identifier": "node_graph.any", "uuid": "2d3d191c-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "2d3d1656-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "add1", "from_socket": "result", "from_socket_uuid": "2d34d32e-5e20-11ef-9a7c-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "n"}], "outputs": [{"name": "result"}], "position": [60, 60], "children": []}, "add2": {"label": "add2", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "2d45c47c-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "2d45beaa-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "add_multiply_while1", "from_socket": "result", "from_socket_uuid": "2d3d1b74-5e20-11ef-9a7c-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "2d45c4e0-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "2d45beaa-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [], "position": [90, 90], "children": []}}, "links": [{"from_socket": "result", "from_node": "add1", "from_socket_uuid": "2d34d32e-5e20-11ef-9a7c-906584de3e5b", "to_socket": "n", "to_node": "add_multiply_while1", "state": false}, {"from_socket": "result", "from_node": "add_multiply_while1", "from_socket_uuid": "2d3d1b74-5e20-11ef-9a7c-906584de3e5b", "to_socket": "x", "to_node": "add2", "state": false}]} // Define Schemes to use in vanilla JS const Schemes = { @@ -148,8 +148,8 @@ console.log("Adding while zone: "); for (const nodeId in workgraphData.nodes) { const nodeData = workgraphData.nodes[nodeId]; - // if node_type is "WHILE", find all - if (nodeData['node_type'] === "WHILE" || nodeData['node_type'] === "IF") { + const node_type = nodeData['node_type']; + if (node_type === "WHILE" || node_type === "IF" || node_type === "ZONE") { // find the node const node = editor.nodeMap[nodeData.label]; const children = nodeData['children']; diff --git a/docs/source/howto/html/while_task.html b/docs/source/howto/html/while_task.html index 7715e884..b00c2eff 100644 --- a/docs/source/howto/html/while_task.html +++ b/docs/source/howto/html/while_task.html @@ -61,7 +61,7 @@ const { RenderUtils } = ReteRenderUtils; const styled = window.styled; - const workgraphData = {"name": "while_task", "uuid": "57e6660c-59a5-11ef-be18-906584de3e5b", "state": "CREATED", "nodes": {"add1": {"label": "add1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "57f0da42-59a5-11ef-be18-906584de3e5b", "node_uuid": "57f0d3da-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "57f0db00-59a5-11ef-be18-906584de3e5b", "node_uuid": "57f0d3da-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}], "outputs": [{"name": "_wait"}], "position": [30, 30], "children": []}, "add2": {"label": "add2", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "57f9c7ec-59a5-11ef-be18-906584de3e5b", "node_uuid": "57f9c274-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "57f9c846-59a5-11ef-be18-906584de3e5b", "node_uuid": "57f9c274-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "_wait"}], "outputs": [{"name": "result"}], "position": [60, 60], "children": []}, "multiply1": {"label": "multiply1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "58020326-59a5-11ef-be18-906584de3e5b", "node_uuid": "5801fdcc-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "add2", "from_socket": "result", "from_socket_uuid": "57f9c90e-59a5-11ef-be18-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "58020376-59a5-11ef-be18-906584de3e5b", "node_uuid": "5801fdcc-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [{"name": "result"}, {"name": "result"}], "position": [90, 90], "children": []}, "compare1": {"label": "compare1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "5809e9f6-59a5-11ef-be18-906584de3e5b", "node_uuid": "5809e44c-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "multiply1", "from_socket": "result", "from_socket_uuid": "58020434-59a5-11ef-be18-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "5809ea50-59a5-11ef-be18-906584de3e5b", "node_uuid": "5809e44c-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [], "position": [120, 120], "children": []}, "while5": {"label": "while5", "node_type": "WHILE", "inputs": [], "outputs": [], "position": [150, 150], "children": ["add2", "multiply1", "compare1"]}, "add3": {"label": "add3", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "581ad522-59a5-11ef-be18-906584de3e5b", "node_uuid": "581acf46-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "multiply1", "from_socket": "result", "from_socket_uuid": "58020434-59a5-11ef-be18-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "581ad57c-59a5-11ef-be18-906584de3e5b", "node_uuid": "581acf46-59a5-11ef-be18-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [], "position": [180, 180], "children": []}}, "links": [{"from_socket": "result", "from_node": "add2", "from_socket_uuid": "57f9c90e-59a5-11ef-be18-906584de3e5b", "to_socket": "x", "to_node": "multiply1", "state": false}, {"from_socket": "result", "from_node": "multiply1", "from_socket_uuid": "58020434-59a5-11ef-be18-906584de3e5b", "to_socket": "x", "to_node": "compare1", "state": false}, {"from_socket": "result", "from_node": "multiply1", "from_socket_uuid": "58020434-59a5-11ef-be18-906584de3e5b", "to_socket": "x", "to_node": "add3", "state": false}, {"from_node": "add1", "from_socket": "_wait", "to_node": "add2", "to_socket": "_wait"}]} + const workgraphData = {"name": "while_task", "uuid": "11cc817c-5e20-11ef-9a7c-906584de3e5b", "state": "CREATED", "nodes": {"add1": {"label": "add1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "11d730f4-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11d72a96-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "11d73144-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11d72a96-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}], "outputs": [{"name": "_wait"}], "position": [30, 30], "children": []}, "compare1": {"label": "compare1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "11dfbf8a-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11dfb9cc-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "11dfbfe4-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11dfb9cc-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}], "outputs": [{"name": "result"}], "position": [60, 60], "children": []}, "while3": {"label": "while3", "node_type": "WHILE", "inputs": [{"name": "conditions"}], "outputs": [], "position": [90, 90], "children": ["add2", "multiply1"]}, "add2": {"label": "add2", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "11f043be-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11f03e0a-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "11f04418-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11f03e0a-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "_wait"}], "outputs": [{"name": "result"}], "position": [120, 120], "children": []}, "multiply1": {"label": "multiply1", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "11f84e9c-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11f8485c-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "add2", "from_socket": "result", "from_socket_uuid": "11f044e0-5e20-11ef-9a7c-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "11f84f00-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "11f8485c-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [{"name": "result"}], "position": [150, 150], "children": []}, "add3": {"label": "add3", "node_type": "CALCFUNCTION", "inputs": [{"name": "x", "identifier": "workgraph.any", "uuid": "1204244c-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "1204186c-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [{"from_node": "multiply1", "from_socket": "result", "from_socket_uuid": "11f84fc8-5e20-11ef-9a7c-906584de3e5b"}], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "y", "identifier": "workgraph.any", "uuid": "12042546-5e20-11ef-9a7c-906584de3e5b", "node_uuid": "1204186c-5e20-11ef-9a7c-906584de3e5b", "type": "INPUT", "link_limit": 1, "links": [], "serialize": {"path": "node_graph.serializer", "name": "serialize_pickle"}, "deserialize": {"path": "node_graph.serializer", "name": "deserialize_pickle"}}, {"name": "x"}], "outputs": [], "position": [180, 180], "children": []}}, "links": [{"from_socket": "result", "from_node": "compare1", "from_socket_uuid": "11dfc0b6-5e20-11ef-9a7c-906584de3e5b", "to_socket": "conditions", "to_node": "while3", "state": false}, {"from_socket": "result", "from_node": "add2", "from_socket_uuid": "11f044e0-5e20-11ef-9a7c-906584de3e5b", "to_socket": "x", "to_node": "multiply1", "state": false}, {"from_socket": "result", "from_node": "multiply1", "from_socket_uuid": "11f84fc8-5e20-11ef-9a7c-906584de3e5b", "to_socket": "x", "to_node": "add3", "state": false}, {"from_node": "add1", "from_socket": "_wait", "to_node": "add2", "to_socket": "_wait"}]} // Define Schemes to use in vanilla JS const Schemes = { @@ -148,8 +148,8 @@ console.log("Adding while zone: "); for (const nodeId in workgraphData.nodes) { const nodeData = workgraphData.nodes[nodeId]; - // if node_type is "WHILE", find all - if (nodeData['node_type'] === "WHILE" || nodeData['node_type'] === "IF") { + const node_type = nodeData['node_type']; + if (node_type === "WHILE" || node_type === "IF" || node_type === "ZONE") { // find the node const node = editor.nodeMap[nodeData.label]; const children = nodeData['children']; diff --git a/docs/source/howto/while.ipynb b/docs/source/howto/while.ipynb index c6e14d02..1330679d 100644 --- a/docs/source/howto/while.ipynb +++ b/docs/source/howto/while.ipynb @@ -26,14 +26,12 @@ "The `While` task in WorkGraph is designed to run a set of tasks multiple times within a loop. You can add a `While` task to your WorkGraph and configure it with specific conditions and tasks to be executed repeatedly.\n", "\n", "- **max_iterations**: Specifies the maximum number of iterations the loop should execute to prevent infinite loops.\n", - "- **conditions**: A list of boolean expressions derived from the `context` variables. The loop will terminate when any condition evaluates to `False`.\n", - "- **tasks**: Names of the tasks that will execute repeatedly within the loop.\n", + "- **conditions**: The loop will terminate when any condition evaluates to `False`. This input can be the outputs of other tasks, or a list of boolean expressions derived from the `context` variables. \n", "\n", "Here's a simple example to add a `While` task to a WorkGraph:\n", "```python\n", "while_task = wg.add_task(\"While\", name=\"while_loop\",\n", - " max_iterations=100,\n", - " conditions=[\"should_run\"])\n", + " max_iterations=100)\n", "```\n", "\n", "### Adding tasks to the While loop\n", @@ -47,33 +45,25 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "8f5e7642", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Result: uuid: b457616b-5797-45f4-a7d6-d8a1c2104078 (pk: 106923) value: 63\n" - ] - } - ], + "outputs": [], "source": [ - "from aiida.engine import calcfunction\n", + "from aiida_workgraph import WorkGraph, task\n", "from aiida import load_profile\n", "\n", "load_profile()\n", "\n", - "@calcfunction\n", + "@task.calcfunction()\n", "def compare(x, y):\n", " return x < y\n", "\n", - "@calcfunction\n", + "@task.calcfunction()\n", "def add(x, y):\n", " return x + y\n", "\n", - "@calcfunction\n", + "@task.calcfunction()\n", "def multiply(x, y):\n", " return x*y\n", "\n", @@ -102,7 +92,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 10, "id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0", "metadata": {}, "outputs": [ @@ -121,10 +111,10 @@ " " ], "text/plain": [ - "" + "" ] }, - "execution_count": 2, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -138,6 +128,9 @@ "add1 = wg.add_task(add, name=\"add1\", x=1, y=1)\n", "add1.set_context({\"result\": \"n\"})\n", "#---------------------------------------------------------------------\n", + "# Create the while tasks\n", + "compare1 = wg.add_task(compare, name=\"compare1\", x=\"{{n}}\", y=50)\n", + "while1 = wg.add_task(\"While\", max_iterations=100, conditions=compare1.outputs[\"result\"])\n", "# Create the tasks in the while loop.\n", "add2 = wg.add_task(add, name=\"add2\", x=\"{{n}}\", y=1)\n", "add2.waiting_on.add(\"add1\")\n", @@ -146,12 +139,7 @@ " y=2)\n", "# update the context variable\n", "multiply1.set_context({\"result\": \"n\"})\n", - "compare1 = wg.add_task(compare, name=\"compare1\", x=multiply1.outputs[\"result\"], y=50)\n", - "# Save the `result` of compare1 task as context.should_run, and used as condition\n", - "compare1.set_context({\"result\": \"should_run\"})\n", - "# Create the while tasks\n", - "while1 = wg.add_task(\"While\", max_iterations=100, conditions=[\"should_run\"])\n", - "while1.children=[\"add2\", \"multiply1\", \"compare1\"]\n", + "while1.children.add([\"add2\", \"multiply1\"])\n", "#---------------------------------------------------------------------\n", "add3 = wg.add_task(add, name=\"add3\", x=1, y=1)\n", "wg.add_link(multiply1.outputs[\"result\"], add3.inputs[\"x\"])\n", @@ -177,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 12, "id": "9ebf35aa", "metadata": {}, "outputs": [ @@ -185,9 +173,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "WorkGraph process created, PK: 106924\n", + "WorkGraph process created, PK: 117695\n", "State of WorkGraph: FINISHED\n", - "Result of add1 : uuid: 50a4a4b9-4fbf-4152-be6f-06efde03c8e2 (pk: 106967) value: 63\n" + "Result of add1 : uuid: 061abd52-84fe-4d4e-b381-c303e4c25e19 (pk: 117741) value: 63\n" ] } ], @@ -207,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 13, "id": "0060e380", "metadata": {}, "outputs": [ @@ -220,564 +208,602 @@ "\n", "\n", - "\n", + "\n", "\n", - "\n", - "\n", + "\n", + "\n", "\n", - "N106924\n", - "\n", - "WorkGraph<while_task> (106924)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117695\n", + "\n", + "WorkGraph<while_task> (117695)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", + "\n", "\n", - "N106927\n", - "\n", - "add (106927)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117698\n", + "\n", + "add (117698)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106927\n", - "\n", - "\n", - "CALL_CALC\n", - "add1\n", + "\n", + "\n", + "N117695->N117698\n", + "\n", + "\n", + "CALL_CALC\n", + "add1\n", "\n", - "\n", + "\n", "\n", - "N106930\n", - "\n", - "add (106930)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117701\n", + "\n", + "compare (117701)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106930\n", - "\n", - "\n", - "CALL_CALC\n", - "add2\n", + "\n", + "\n", + "N117695->N117701\n", + "\n", + "\n", + "CALL_CALC\n", + "compare1\n", "\n", - "\n", + "\n", "\n", - "N106933\n", - "\n", - "multiply (106933)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117704\n", + "\n", + "add (117704)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106933\n", - "\n", - "\n", - "CALL_CALC\n", - "multiply1\n", + "\n", + "\n", + "N117695->N117704\n", + "\n", + "\n", + "CALL_CALC\n", + "add2\n", "\n", - "\n", + "\n", "\n", - "N106936\n", - "\n", - "compare (106936)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117707\n", + "\n", + "multiply (117707)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106936\n", - "\n", - "\n", - "CALL_CALC\n", - "compare1\n", + "\n", + "\n", + "N117695->N117707\n", + "\n", + "\n", + "CALL_CALC\n", + "multiply1\n", "\n", - "\n", + "\n", "\n", - "N106939\n", - "\n", - "add (106939)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117710\n", + "\n", + "compare (117710)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106939\n", - "\n", - "\n", - "CALL_CALC\n", - "add2\n", + "\n", + "\n", + "N117695->N117710\n", + "\n", + "\n", + "CALL_CALC\n", + "compare1\n", "\n", - "\n", + "\n", "\n", - "N106942\n", - "\n", - "multiply (106942)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117713\n", + "\n", + "add (117713)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106942\n", - "\n", - "\n", - "CALL_CALC\n", - "multiply1\n", + "\n", + "\n", + "N117695->N117713\n", + "\n", + "\n", + "CALL_CALC\n", + "add2\n", "\n", - "\n", + "\n", "\n", - "N106945\n", - "\n", - "compare (106945)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117716\n", + "\n", + "multiply (117716)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106945\n", - "\n", - "\n", - "CALL_CALC\n", - "compare1\n", + "\n", + "\n", + "N117695->N117716\n", + "\n", + "\n", + "CALL_CALC\n", + "multiply1\n", "\n", - "\n", + "\n", "\n", - "N106948\n", - "\n", - "add (106948)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117719\n", + "\n", + "compare (117719)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106948\n", - "\n", - "\n", - "CALL_CALC\n", - "add2\n", + "\n", + "\n", + "N117695->N117719\n", + "\n", + "\n", + "CALL_CALC\n", + "compare1\n", "\n", - "\n", + "\n", "\n", - "N106951\n", - "\n", - "multiply (106951)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117722\n", + "\n", + "add (117722)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106951\n", - "\n", - "\n", - "CALL_CALC\n", - "multiply1\n", + "\n", + "\n", + "N117695->N117722\n", + "\n", + "\n", + "CALL_CALC\n", + "add2\n", "\n", - "\n", + "\n", "\n", - "N106954\n", - "\n", - "compare (106954)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117725\n", + "\n", + "multiply (117725)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", + "\n", "\n", - "N106924->N106954\n", - "\n", - "\n", - "CALL_CALC\n", - "compare1\n", + "N117695->N117725\n", + "\n", + "\n", + "CALL_CALC\n", + "multiply1\n", "\n", - "\n", + "\n", "\n", - "N106957\n", - "\n", - "add (106957)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117728\n", + "\n", + "compare (117728)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106957\n", - "\n", - "\n", - "CALL_CALC\n", - "add2\n", + "\n", + "\n", + "N117695->N117728\n", + "\n", + "\n", + "CALL_CALC\n", + "compare1\n", "\n", - "\n", + "\n", "\n", - "N106960\n", - "\n", - "multiply (106960)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117731\n", + "\n", + "add (117731)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106960\n", - "\n", - "\n", - "CALL_CALC\n", - "multiply1\n", + "\n", + "\n", + "N117695->N117731\n", + "\n", + "\n", + "CALL_CALC\n", + "add2\n", "\n", - "\n", + "\n", "\n", - "N106963\n", - "\n", - "compare (106963)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117734\n", + "\n", + "multiply (117734)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106963\n", - "\n", - "\n", - "CALL_CALC\n", - "compare1\n", + "\n", + "\n", + "N117695->N117734\n", + "\n", + "\n", + "CALL_CALC\n", + "multiply1\n", "\n", - "\n", + "\n", "\n", - "N106966\n", - "\n", - "add (106966)\n", - "State: finished\n", - "Exit Code: 0\n", + "N117737\n", + "\n", + "compare (117737)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106966\n", - "\n", - "\n", - "CALL_CALC\n", - "add3\n", + "\n", + "\n", + "N117695->N117737\n", + "\n", + "\n", + "CALL_CALC\n", + "compare1\n", "\n", - "\n", + "\n", "\n", - "N106968\n", - "\n", - "Int (106968)\n", + "N117740\n", + "\n", + "add (117740)\n", + "State: finished\n", + "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106924->N106968\n", - "\n", - "\n", - "RETURN\n", - "execution_count\n", + "\n", + "\n", + "N117695->N117740\n", + "\n", + "\n", + "CALL_CALC\n", + "add3\n", + "\n", + "\n", + "\n", + "N117742\n", + "\n", + "Int (117742)\n", "\n", - "\n", + "\n", + "\n", + "N117695->N117742\n", + "\n", + "\n", + "RETURN\n", + "execution_count\n", + "\n", + "\n", "\n", - "N106928\n", - "\n", - "Int (106928)\n", + "N117699\n", + "\n", + "Int (117699)\n", "\n", - "\n", - "\n", - "N106927->N106928\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117698->N117699\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106928->N106930\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117699->N117701\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", - "\n", - "N106931\n", - "\n", - "Int (106931)\n", + "\n", + "\n", + "N117699->N117704\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", - "\n", - "N106930->N106931\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117702\n", + "\n", + "Bool (117702)\n", "\n", - "\n", - "\n", - "N106931->N106933\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117701->N117702\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", + "\n", "\n", - "N106934\n", - "\n", - "Int (106934)\n", - "\n", - "\n", - "\n", - "N106933->N106934\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "N117705\n", + "\n", + "Int (117705)\n", "\n", - "\n", - "\n", - "N106934->N106936\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117704->N117705\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106934->N106939\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117705->N117707\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", "\n", - "N106937\n", - "\n", - "Bool (106937)\n", - "\n", - "\n", - "\n", - "N106936->N106937\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "N117708\n", + "\n", + "Int (117708)\n", "\n", - "\n", - "\n", - "N106940\n", - "\n", - "Int (106940)\n", + "\n", + "\n", + "N117707->N117708\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106939->N106940\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117708->N117710\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", "\n", - "N106940->N106942\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "N117708->N117713\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", - "\n", - "N106943\n", - "\n", - "Int (106943)\n", + "\n", + "\n", + "N117711\n", + "\n", + "Bool (117711)\n", "\n", - "\n", - "\n", - "N106942->N106943\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117710->N117711\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106943->N106945\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117714\n", + "\n", + "Int (117714)\n", "\n", - "\n", - "\n", - "N106943->N106948\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117713->N117714\n", + "\n", + "\n", + "CREATE\n", + "result\n", + "\n", + "\n", + "\n", + "N117714->N117716\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", "\n", - "N106946\n", - "\n", - "Bool (106946)\n", + "N117717\n", + "\n", + "Int (117717)\n", "\n", - "\n", - "\n", - "N106945->N106946\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117716->N117717\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106949\n", - "\n", - "Int (106949)\n", + "\n", + "\n", + "N117717->N117719\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", - "\n", - "N106948->N106949\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117717->N117722\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", + "\n", + "N117720\n", + "\n", + "Bool (117720)\n", + "\n", + "\n", "\n", - "N106949->N106951\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "N117719->N117720\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", + "\n", "\n", - "N106952\n", - "\n", - "Int (106952)\n", - "\n", - "\n", - "\n", - "N106951->N106952\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "N117723\n", + "\n", + "Int (117723)\n", "\n", - "\n", - "\n", - "N106952->N106954\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117722->N117723\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106952->N106957\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117723->N117725\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", "\n", - "N106955\n", - "\n", - "Bool (106955)\n", + "N117726\n", + "\n", + "Int (117726)\n", "\n", - "\n", - "\n", - "N106954->N106955\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117725->N117726\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106958\n", - "\n", - "Int (106958)\n", + "\n", + "\n", + "N117726->N117728\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", - "\n", - "N106957->N106958\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117726->N117731\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", - "\n", - "N106958->N106960\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117729\n", + "\n", + "Bool (117729)\n", "\n", - "\n", - "\n", - "N106961\n", - "\n", - "Int (106961)\n", + "\n", + "\n", + "N117728->N117729\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106960->N106961\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117732\n", + "\n", + "Int (117732)\n", "\n", - "\n", - "\n", - "N106961->N106963\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117731->N117732\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", - "\n", - "\n", - "N106961->N106966\n", - "\n", - "\n", - "INPUT_CALC\n", - "x\n", + "\n", + "\n", + "N117732->N117734\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", "\n", - "N106964\n", - "\n", - "Bool (106964)\n", + "N117735\n", + "\n", + "Int (117735)\n", "\n", - "\n", - "\n", - "N106963->N106964\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117734->N117735\n", + "\n", + "\n", + "CREATE\n", + "result\n", + "\n", + "\n", + "\n", + "N117735->N117737\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", "\n", - "\n", + "\n", + "\n", + "N117735->N117740\n", + "\n", + "\n", + "INPUT_CALC\n", + "x\n", + "\n", + "\n", "\n", - "N106967\n", - "\n", - "Int (106967)\n", + "N117738\n", + "\n", + "Bool (117738)\n", "\n", - "\n", - "\n", - "N106966->N106967\n", - "\n", - "\n", - "CREATE\n", - "result\n", + "\n", + "\n", + "N117737->N117738\n", + "\n", + "\n", + "CREATE\n", + "result\n", + "\n", + "\n", + "\n", + "N117741\n", + "\n", + "Int (117741)\n", + "\n", + "\n", + "\n", + "N117740->N117741\n", + "\n", + "\n", + "CREATE\n", + "result\n", "\n", "\n", "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 4, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -799,7 +825,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 14, "id": "4d0598d3", "metadata": {}, "outputs": [], @@ -834,7 +860,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 15, "id": "336e5ab7", "metadata": {}, "outputs": [ @@ -853,10 +879,10 @@ " " ], "text/plain": [ - "" + "" ] }, - "execution_count": 6, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -886,17 +912,25 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 16, "id": "17f6d666", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/xing/miniconda3/envs/aiida/lib/python3.11/site-packages/aiida/storage/psql_dos/orm/nodes.py:224: SAWarning: Object of type not in session, add operation along 'DbUser.dbnodes' will not proceed\n", + " session.commit()\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "WorkGraph process created, PK: 106969\n", + "WorkGraph process created, PK: 117743\n", "State of WorkGraph: FINISHED\n", - "Result of add2 : uuid: fc0d990f-c886-44a2-8c6b-1fb658b037a7 (pk: 107019) value: 63\n" + "Result of add2 : uuid: 4ba92c1b-9bb0-4e1e-9878-1e6d3d152d57 (pk: 117793) value: 63\n" ] } ], @@ -916,7 +950,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 17, "id": "bc6297de", "metadata": {}, "outputs": [ @@ -933,615 +967,615 @@ " viewBox=\"0.00 0.00 1442.55 2565.50\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", "\n", "\n", - "\n", + "\n", "\n", - "N106969\n", + "N117743\n", "\n", - "WorkGraph<while_graph_builder> (106969)\n", + "WorkGraph<while_graph_builder> (117743)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", + "\n", "\n", - "N106972\n", + "N117746\n", "\n", - "add (106972)\n", + "add (117746)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106969->N106972\n", + "\n", + "\n", + "N117743->N117746\n", "\n", "\n", "CALL_CALC\n", "add1\n", "\n", - "\n", + "\n", "\n", - "N106974\n", + "N117748\n", "\n", - "WorkGraph<add_multiply_while1> (106974)\n", + "WorkGraph<add_multiply_while1> (117748)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106969->N106974\n", + "\n", + "\n", + "N117743->N117748\n", "\n", "\n", "CALL_WORK\n", "add_multiply_while1\n", "\n", - "\n", + "\n", "\n", - "N107018\n", + "N117792\n", "\n", - "add (107018)\n", + "add (117792)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106969->N107018\n", + "\n", + "\n", + "N117743->N117792\n", "\n", "\n", "CALL_CALC\n", "add2\n", "\n", - "\n", + "\n", "\n", - "N107020\n", + "N117794\n", "\n", - "Int (107020)\n", + "Int (117794)\n", "\n", - "\n", - "\n", - "N106969->N107020\n", + "\n", + "\n", + "N117743->N117794\n", "\n", "\n", "RETURN\n", "execution_count\n", "\n", - "\n", + "\n", "\n", - "N106973\n", + "N117747\n", "\n", - "Int (106973)\n", + "Int (117747)\n", "\n", - "\n", - "\n", - "N106972->N106973\n", + "\n", + "\n", + "N117746->N117747\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N106973->N106974\n", + "\n", + "\n", + "N117747->N117748\n", "\n", "\n", "INPUT_WORK\n", "wg__context__n\n", "\n", - "\n", + "\n", "\n", - "N106977\n", + "N117751\n", "\n", - "compare (106977)\n", + "compare (117751)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106977\n", + "\n", + "\n", + "N117748->N117751\n", "\n", "\n", "CALL_CALC\n", "compare1\n", "\n", - "\n", + "\n", "\n", - "N106981\n", + "N117755\n", "\n", - "add (106981)\n", + "add (117755)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106981\n", + "\n", + "\n", + "N117748->N117755\n", "\n", "\n", "CALL_CALC\n", "add1\n", "\n", - "\n", + "\n", "\n", - "N106984\n", + "N117758\n", "\n", - "multiply (106984)\n", + "multiply (117758)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106984\n", + "\n", + "\n", + "N117748->N117758\n", "\n", "\n", "CALL_CALC\n", "multiply1\n", "\n", - "\n", + "\n", "\n", - "N106987\n", + "N117761\n", "\n", - "compare (106987)\n", + "compare (117761)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106987\n", + "\n", + "\n", + "N117748->N117761\n", "\n", "\n", "CALL_CALC\n", "compare1\n", "\n", - "\n", + "\n", "\n", - "N106990\n", + "N117764\n", "\n", - "add (106990)\n", + "add (117764)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106990\n", + "\n", + "\n", + "N117748->N117764\n", "\n", "\n", "CALL_CALC\n", "add1\n", "\n", - "\n", + "\n", "\n", - "N106993\n", + "N117767\n", "\n", - "multiply (106993)\n", + "multiply (117767)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106993\n", + "\n", + "\n", + "N117748->N117767\n", "\n", "\n", "CALL_CALC\n", "multiply1\n", "\n", - "\n", + "\n", "\n", - "N106996\n", + "N117770\n", "\n", - "compare (106996)\n", + "compare (117770)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106996\n", + "\n", + "\n", + "N117748->N117770\n", "\n", "\n", "CALL_CALC\n", "compare1\n", "\n", - "\n", + "\n", "\n", - "N106999\n", + "N117773\n", "\n", - "add (106999)\n", + "add (117773)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N106999\n", + "\n", + "\n", + "N117748->N117773\n", "\n", "\n", "CALL_CALC\n", "add1\n", "\n", - "\n", + "\n", "\n", - "N107002\n", + "N117776\n", "\n", - "multiply (107002)\n", + "multiply (117776)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N107002\n", + "\n", + "\n", + "N117748->N117776\n", "\n", "\n", "CALL_CALC\n", "multiply1\n", "\n", - "\n", + "\n", "\n", - "N107005\n", + "N117779\n", "\n", - "compare (107005)\n", + "compare (117779)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N107005\n", + "\n", + "\n", + "N117748->N117779\n", "\n", "\n", "CALL_CALC\n", "compare1\n", "\n", - "\n", + "\n", "\n", - "N107008\n", + "N117782\n", "\n", - "add (107008)\n", + "add (117782)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N107008\n", + "\n", + "\n", + "N117748->N117782\n", "\n", "\n", "CALL_CALC\n", "add1\n", "\n", - "\n", + "\n", "\n", - "N107011\n", + "N117785\n", "\n", - "multiply (107011)\n", + "multiply (117785)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N107011\n", + "\n", + "\n", + "N117748->N117785\n", "\n", "\n", "CALL_CALC\n", "multiply1\n", "\n", - "\n", + "\n", "\n", - "N107012\n", + "N117786\n", "\n", - "Int (107012)\n", + "Int (117786)\n", "\n", - "\n", - "\n", - "N106974->N107012\n", + "\n", + "\n", + "N117748->N117786\n", "\n", "\n", "RETURN\n", "result\n", "\n", - "\n", + "\n", "\n", - "N107014\n", + "N117788\n", "\n", - "compare (107014)\n", + "compare (117788)\n", "State: finished\n", "Exit Code: 0\n", "\n", - "\n", - "\n", - "N106974->N107014\n", + "\n", + "\n", + "N117748->N117788\n", "\n", "\n", "CALL_CALC\n", "compare1\n", "\n", - "\n", + "\n", "\n", - "N107016\n", + "N117790\n", "\n", - "Int (107016)\n", + "Int (117790)\n", "\n", - "\n", - "\n", - "N106974->N107016\n", + "\n", + "\n", + "N117748->N117790\n", "\n", "\n", "RETURN\n", "execution_count\n", "\n", - "\n", + "\n", "\n", - "N106978\n", + "N117752\n", "\n", - "Bool (106978)\n", + "Bool (117752)\n", "\n", - "\n", - "\n", - "N106977->N106978\n", + "\n", + "\n", + "N117751->N117752\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", + "\n", "\n", - "N106982\n", + "N117756\n", "\n", - "Int (106982)\n", + "Int (117756)\n", "\n", - "\n", - "\n", - "N106981->N106982\n", + "\n", + "\n", + "N117755->N117756\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N106982->N106984\n", + "\n", + "\n", + "N117756->N117758\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N106985\n", + "N117759\n", "\n", - "Int (106985)\n", + "Int (117759)\n", "\n", - "\n", - "\n", - "N106984->N106985\n", + "\n", + "\n", + "N117758->N117759\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N106985->N106987\n", + "\n", + "\n", + "N117759->N117761\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", - "\n", - "N106985->N106990\n", + "\n", + "\n", + "N117759->N117764\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N106988\n", + "N117762\n", "\n", - "Bool (106988)\n", + "Bool (117762)\n", "\n", - "\n", - "\n", - "N106987->N106988\n", + "\n", + "\n", + "N117761->N117762\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", + "\n", "\n", - "N106991\n", + "N117765\n", "\n", - "Int (106991)\n", + "Int (117765)\n", "\n", - "\n", - "\n", - "N106990->N106991\n", + "\n", + "\n", + "N117764->N117765\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N106991->N106993\n", + "\n", + "\n", + "N117765->N117767\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N106994\n", + "N117768\n", "\n", - "Int (106994)\n", + "Int (117768)\n", "\n", - "\n", - "\n", - "N106993->N106994\n", + "\n", + "\n", + "N117767->N117768\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N106994->N106996\n", + "\n", + "\n", + "N117768->N117770\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N106994->N106999\n", + "N117768->N117773\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N106997\n", + "N117771\n", "\n", - "Bool (106997)\n", + "Bool (117771)\n", "\n", - "\n", - "\n", - "N106996->N106997\n", + "\n", + "\n", + "N117770->N117771\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", + "\n", "\n", - "N107000\n", + "N117774\n", "\n", - "Int (107000)\n", + "Int (117774)\n", "\n", - "\n", - "\n", - "N106999->N107000\n", + "\n", + "\n", + "N117773->N117774\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N107000->N107002\n", + "\n", + "\n", + "N117774->N117776\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N107003\n", + "N117777\n", "\n", - "Int (107003)\n", + "Int (117777)\n", "\n", - "\n", - "\n", - "N107002->N107003\n", + "\n", + "\n", + "N117776->N117777\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N107003->N107005\n", + "\n", + "\n", + "N117777->N117779\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", - "\n", - "N107003->N107008\n", + "\n", + "\n", + "N117777->N117782\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N107006\n", + "N117780\n", "\n", - "Bool (107006)\n", + "Bool (117780)\n", "\n", - "\n", - "\n", - "N107005->N107006\n", + "\n", + "\n", + "N117779->N117780\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", + "\n", "\n", - "N107009\n", + "N117783\n", "\n", - "Int (107009)\n", + "Int (117783)\n", "\n", - "\n", - "\n", - "N107008->N107009\n", + "\n", + "\n", + "N117782->N117783\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N107009->N107011\n", + "\n", + "\n", + "N117783->N117785\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", - "\n", - "N107011->N107012\n", + "\n", + "\n", + "N117785->N117786\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", - "\n", - "N107012->N107014\n", + "\n", + "\n", + "N117786->N117788\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", - "\n", - "N107012->N107018\n", + "\n", + "\n", + "N117786->N117792\n", "\n", "\n", "INPUT_CALC\n", "x\n", "\n", - "\n", + "\n", "\n", - "N107015\n", + "N117789\n", "\n", - "Bool (107015)\n", + "Bool (117789)\n", "\n", - "\n", - "\n", - "N107014->N107015\n", + "\n", + "\n", + "N117788->N117789\n", "\n", "\n", "CREATE\n", "result\n", "\n", - "\n", + "\n", "\n", - "N107019\n", + "N117793\n", "\n", - "Int (107019)\n", + "Int (117793)\n", "\n", - "\n", - "\n", - "N107018->N107019\n", + "\n", + "\n", + "N117792->N117793\n", "\n", "\n", "CREATE\n", @@ -1551,10 +1585,10 @@ "\n" ], "text/plain": [ - "" + "" ] }, - "execution_count": 8, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1575,7 +1609,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "b3764765", "metadata": {}, "outputs": [],