# Redesign of the \`verdi node graph generate\` command

**URL:** <https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395>\
**Category:** Design Discussions\
**Created:** [May 27, 2024, 10:09am UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395 "2024-05-27T10:09:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [May 27, 2024, 10:09am UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395/1 "2024-05-27T10:09:19Z")

</div>

The current interface is:

```auto
verdi node graph generate ROOT_NODE [OUTPUT_FILE]

```

That is, currently, only a single root node can be specified. But it is perfectly reasonable to want to specify multiple root nodes.

To this end, [this pull request](https://github.com/aiidateam/aiida-core/pull/6405) was submitted and merged. It adds the `-N/--nodes` option that now allows users to specify multiple root nodes. The original `ROOT_NODE` argument was deprecated.

But maybe an even better design would be to change the interface to

```auto
verdi node graph generate ROOT_NODES

```

That is, allow for one or multiple root nodes as positional arguments and the output file can be specified through an option (e.g., `--output-file`). The advantage is that this is more in line with other commands that take multiple nodes as input. They are almost always specified as arguments, with the notable exception being `verdi archive create`. The only downside is that this would be breaking backwards compatibility, whereas the current solution merely deprecates the old behavior.

So, the question is, **which solution do you find more intuitive** :

### Option-based

```auto
verdi node graph generate 100
verdi node graph generate 100 output.aiida
verdi node graph generate -N 100 101 102
verdi node graph generate -N 100 101 102 -- output.aiida

```

### Argument-based

```auto
verdi node graph generate 100
verdi node graph generate 100 --output output.aiida
verdi node graph generate 100 101 102
verdi node graph generate 100 101 102 --output output.aiida

```

Even though the argument-based approach would be breaking some use cases, I think it is the better solution and would vote for adopting that over the current option-based approach. **Please voice your opinions below on what you think is the best solution.**

---

<div class="post-metadata">

**Author:** ![ali-khosravi](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/ali-khosravi/32/58_2.png) [@ali-khosravi](https://aiida.discourse.group/u/ali-khosravi)\
**Post date:** [May 27, 2024, 12:30pm UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395/2 "2024-05-27T12:30:15Z")

</div>

Thank you for providing a compact and well-summarized question.  
With the current implementation of `verdi` line, to me argument based is more intuitive.  
A side node, I feel it would also be even more user friendly to accept ranges:

```auto
verdi node graph generate 100 101 102 --output output.aiida
verdi node graph generate 100-102 --output output.aiida

```

---

<div class="post-metadata">

**Author:** ![mbercx](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/mbercx/32/345_2.png) [@mbercx](https://aiida.discourse.group/u/mbercx)\
**Post date:** [May 28, 2024, 11:48am UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395/3 "2024-05-28T11:48:08Z")

</div>

As already discussed yesterday, I’m also in favor of the argument-based approach. 🙂

The node ranges idea is also interesting, but I would never dare to introduce such [scope creep](https://en.wikipedia.org/wiki/Scope_creep) to this discussion. 😇

---

<div class="post-metadata">

**Author:** ![danielhollas](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/danielhollas/32/4_2.png) [@danielhollas](https://aiida.discourse.group/u/danielhollas)\
**Post date:** [May 28, 2024, 3:46pm UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395/4 "2024-05-28T15:46:29Z")

</div>

Given that the OUTPUT\_FILE is optional, it doesn’t really make sense for it to be a positional argument. So I am also in favour of the argument-based approach.

> [@ali-khosravi](#):
>
> A side node, I feel it would also be even more user friendly to accept ranges:

I don’t think the extra complexity is worth it in this case — supposedly the case where root nodes would have consecutive IDs should be very rare.

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [May 28, 2024, 9:02pm UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395/5 "2024-05-28T21:02:55Z")

</div>

Thanks everyone for the feedback. Seems everyone was on board with breaking backwards compatibility in order to have the most intuitive interface: [CLI: `verdi node graph generate` root nodes as arguments by sphuber · Pull Request #6427 · aiidateam/aiida-core · GitHub](https://github.com/aiidateam/aiida-core/pull/6427)

---

<div class="post-metadata">

**Author:** ![geiger\_j](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/geiger_j/32/57_2.png) [@geiger\_j](https://aiida.discourse.group/u/geiger_j)\
**Post date:** [May 29, 2024, 7:14am UTC](https://aiida.discourse.group/t/redesign-of-the-verdi-node-graph-generate-command/395/6 "2024-05-29T07:14:31Z")

</div>

A bit late to the party, but agreeing with the rest of the team. Just ran the command with multiple nodes, and, intuitively, I was expecting multiple output files, one for each graph, rather than a single one. But I guess if a user wants this behavior, they can just loop over the nodes outside the `verdi` command, so all good!
