Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to follow the process call stack to quickly locate the child node #6478

Open
unkcpz opened this issue Jun 18, 2024 · 1 comment
Open

Comments

@unkcpz
Copy link
Member

unkcpz commented Jun 18, 2024

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.

  1. 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.
  2. 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.
  3. Since I have link label for every sub workchain and calcjobs, I do get the outgoing = node.base.links.get_outgoing() first and then outgoing.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]  
@unkcpz unkcpz added the type/feature request status undecided label Jun 18, 2024
@unkcpz
Copy link
Member Author

unkcpz commented Jun 18, 2024

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.

A side idea to improve can be instead of the CALL as default, maybe we can tag the number to CALL_0, CALL_1 ... automatically to distinguish them and to make the keys of LinkManager unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants