Xing
1
In one of my unit test, I need to add an out_going
link to a WorkChainNode
. I did a quick test in verdi shell
:
In [1]: from aiida import orm
In [2]: node = orm.WorkChainNode()
In [3]: x = Int(1)
In [4]: x.store()
Out[4]: <Int: uuid: 6abf3d44-27a0-478d-859e-21b1827f401c (pk: 19760) value: 1>
In [5]: x.base.links.add_incoming(node, link_type=LinkType.RETURN, link_label='x')
In [6]: x.base.links.get_incoming().all()
Out[6]: [LinkTriple(node=<WorkChainNode: uuid: 8da44db3-81d0-45ce-ad9c-db19b81859f1 (unstored)>, link_type=<LinkType.RETURN: 'return'>, link_label='x')]
In [7]: node.base.links.get_outgoing().all()
Out[7]: []
The incoming link is added successfully to the x
node, but the out_going
link is still empty for the node
. Does anyone know why?
sphuber
2
Try to store the WorkChainNode
. The links are not “flushed” until all both nodes of the link are stored.
Xing
3
Thanks for the quick reply! I stored the node, but the links are still empty.
sphuber
4
You need to store the WorkChainNode
before you call add_incoming
.
In [1]: from aiida import orm
...: node = orm.WorkChainNode().store()
...: x = Int(1)
...: x.store()
...: x.base.links.add_incoming(node, link_type=LinkType.RETURN, link_label='x')
...: print(x.base.links.get_incoming().all())
...: print(node.base.links.get_outgoing().all())
[LinkTriple(node=<WorkChainNode: uuid: 9445eb5e-12f1-444c-a572-527a027b9118 (pk: 155538)>, link_type=<LinkType.RETURN: 'return'>, link_label='x')]
[LinkTriple(node=<Int: uuid: d8361706-49d2-4222-a11d-f80e1ab1eaa3 (pk: 155539) value: 1>, link_type=<LinkType.RETURN: 'return'>, link_label='x')]
Xing
5
Hi @sphuber it works. Thanks!
system
Closed
6
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.