Redesign of the `verdi node graph generate` command

The current interface is:

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 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

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

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

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.

1 Like

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:

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

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

The node ranges idea is also interesting, but I would never dare to introduce such scope creep to this discussion. :innocent:

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.

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.

2 Likes

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

1 Like

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!

1 Like