Skip to content

Commit

Permalink
supports use both node name and the node in the wait list. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 authored Apr 18, 2024
1 parent ef75156 commit 621dbcc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aiida_worktree/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, **kwargs):
"""
super().__init__(**kwargs)
self.to_ctx = None
self.wait = None
self.wait = []
self.process = None
self.pk = None
self._widget = NodeGraphWidget(
Expand All @@ -30,7 +30,9 @@ def __init__(self, **kwargs):
def to_dict(self):
ndata = super().to_dict()
ndata["to_ctx"] = [] if self.to_ctx is None else self.to_ctx
ndata["wait"] = [] if self.wait is None else self.wait
ndata["wait"] = [
node if isinstance(node, str) else node.name for node in self.wait
]
ndata["process"] = self.process.uuid if self.process else None
ndata["metadata"]["pk"] = self.process.pk if self.process else None

Expand Down
20 changes: 20 additions & 0 deletions tests/test_node_wait.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import aiida

aiida.load_profile()


def test_node_wait(decorated_add):
"""Run simple calcfunction."""
from aiida_worktree import WorkTree

wt = WorkTree(name="test_node_wait")
add1 = wt.nodes.new(decorated_add, "add1", x=1, y=1)
add1.to_ctx = [["result", "sum1"]]
add2 = wt.nodes.new(decorated_add, "add2", x=2, y=2)
add2.to_ctx = [["result", "sum2"]]
add3 = wt.nodes.new(decorated_add, "add3", x="{{sum1}}", y="{{sum2}}")
add3.wait = ["add1", add2]
wt.submit(wait=True)
add3.ctime < add1.ctime
add3.ctime < add2.ctime
assert add3.outputs[0].value == 6

0 comments on commit 621dbcc

Please sign in to comment.