aiida-core icon indicating copy to clipboard operation
aiida-core copied to clipboard

`CLI`: `verdi node list --descendant` list all descendant nodes of a node, respecting traversal rules

Open khsrali opened this issue 9 months ago • 1 comments

verdi node list already is rich and supports many flags. However, it's not possible, or at least not immediatly clear how to get all descendant nodes of another node.

Therefore, I think it would be nice, if it could list all descendants of a node for a given traversal rules, via e.g. verdi node list --descendant

If that would be possible, then one can use the output as an input for another verdi commands, for example:

verdi node list --descendant <pk> --raw | xargs verdi calcjob cleanworkdir

This was just an example, of course the functionality of this requested feature by no means would not be not limited to, or exclusive to this example.

Pinging, @agoscinski and @unkcpz with whom we previously discussed this.

khsrali avatar Mar 05 '25 10:03 khsrali

Hi @khsrali!

Hope you are fine!

I think to add a --descendants flag in verdi node list that will use the QueryBuilder to recursively query all child nodes. I will also add optional link type and depth arguments, allowing users to further customize the QueryBuilder query. This is important, as it will allow for clean integration with tools such as calcjob , cleanworkdir in the CLI—for example, querying the nodes of a workchain.Let me know if I missed something or proposed the solution wrong , I would be happy to discuss the solution and work on this issue to resolve it ?

Thank You !

Muhammad-Rebaal avatar Apr 05 '25 22:04 Muhammad-Rebaal