aiida-core
aiida-core copied to clipboard
API to follow the process call stack to quickly locate the child node
Hi all, maybe it is something already exist or had some way to support, otherwise could be a good feature to add.
I have a process call stack as shown below, and I want to quickly anchor the last nested PwCalculation<1420195>
. From my run script I have the pk of most outside parent node ConvergenceBandsWorkChain<1416934>
. I have two ways now to get the node programmaly.
- I do
orm.load_node(1416934).called[2].called[2].called[0]
, but it is obvious this is flasky and I found it has the problem when working on the cached workchains. - With the querybuilder, but as some of you (such as @edan-bainglass ) may know, I am very bad at writing querybuilder and I guess there can be a intuitive way for such case where I had clear process calling path to follow to get the target node.
- Since I have link label for every sub workchain and calcjobs, I do get the
outgoing = node.base.links.get_outgoing()
first and thenoutgoing.get_node_by_label("<link_label>")
to get the the nodes. If I understand correctly, under the hood the querybuild can use such information to follow and get the node.
So for 3, I think it would be useful to provide an API node.get_called_node_by_link_label
to get the child nodes hidden in the nested calling path. The problem I can see with the implementation is the default label is CALL
so if the label for every child process is not set, then there can be same keys and multiple entities to return.
ConvergenceBandsWorkChain<1416934> Finished [0] [7:_finalize]
├── get_standard_structure<1416946> Finished [0]
├── BandsWorkChain<1416986> Finished [0] [3:finalize]
│ ├── create_kpoints_from_distance<1417002> Finished [0]
│ └── PwBandsWorkChain<1417028> Finished [0] [4:results]
│ ├── PwBaseWorkChain<1417047> Finished [0] [3:results]
│ │ ├── create_kpoints_from_distance<1417056> Finished [0]
│ │ └── PwCalculation<1417071> Finished [0]
│ └── PwBaseWorkChain<1417119> Finished [0] [3:results]
│ └── PwCalculation<1417135> Finished [0]
├── BandsWorkChain<1417183> Finished [0] [3:finalize]
│ ├── create_kpoints_from_distance<1417209> Finished [0]
│ └── PwBandsWorkChain<1417240> Finished [0] [4:results]
│ ├── PwBaseWorkChain<1417280> Finished [0] [3:results]
│ │ ├── create_kpoints_from_distance<1417312> Finished [0]
│ │ ├── PwCalculation<1417344> Finished [0]
│ │ └── PwCalculation<1418959> Finished [0]
│ └── PwBaseWorkChain<1419259> Finished [0] [3:results]
│ └── PwCalculation<1420195> Finished [0]