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

node graph generate accepts multiple ROOT_NODES #6338

Merged
merged 3 commits into from
Apr 4, 2024

Conversation

bilke
Copy link
Contributor

@bilke bilke commented Apr 2, 2024

Implements #6335.
Related to https://aiida.discourse.group/t/node-graph-generate-with-multiple-root-nodes/353.

TODO

  • Output path must explicitly stated.

Current usage is

verdi node graph generate 5673 5666 two-root-nodes.pdf

if the output is left out then the last root node name would be used as the output file name.

@sphuber Do you have an idea / opinion how the cli interface should handle that?

@sphuber
Copy link
Contributor

sphuber commented Apr 2, 2024

@sphuber Do you have an idea / opinion how to cli interface should handle that?

This is a known problem of command line interfaces that have an option that accepts multiple values. The parser will be greedy and treats other (optional) positional arguments as a value for the option. The distinction has to be made explicitly by the caller. You can insert the -- marker to indicate the end of options, and so all tokens that follow should be interpreted as positional arguments. See the docs as well: https://aiida.readthedocs.io/projects/aiida-core/en/latest/topics/cli.html#multi-value-options

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bilke . As you noticed changing the positional arguments to take multiple values doesn't play well with the optional output filename also being positional. See my comments elsewhere for a potential solution.

src/aiida/cmdline/commands/cmd_node.py Outdated Show resolved Hide resolved
src/aiida/cmdline/commands/cmd_node.py Outdated Show resolved Hide resolved
src/aiida/cmdline/commands/cmd_node.py Show resolved Hide resolved
src/aiida/cmdline/commands/cmd_node.py Outdated Show resolved Hide resolved
bilke and others added 3 commits April 4, 2024 13:05
TODO: output path must explicitly stated.
This is necessary because otherwise if a user wants to specify the
output file when using multiple root nodes, they would have to specify a
single root node again or the output file would be mistaked for the
deprecated root node argument:

     verdi node graph generate -N 1 2 -- 1 output.pdf
@sphuber
Copy link
Contributor

sphuber commented Apr 4, 2024

Thanks a lot for the contribution @bilke

@sphuber sphuber merged commit f16c432 into aiidateam:main Apr 4, 2024
19 checks passed
@bilke bilke deleted the graph-multiple-root branch April 4, 2024 13:38
GeigerJ2 pushed a commit to qiaojunfeng/aiida-core that referenced this pull request Apr 10, 2024
…eam#6338)

So far, the command only allowed to specify a single root node through
a positional argument. However, in some cases having multiple root nodes
are perfectly sensible. Unfortunately, simply changing the positional
argument to accept multiple nodes won't work because the command also
accepts a second optional positional argument to specify the output
filename. Making the root node accept multiple values will make it
greedy and it will always mistake the output filename as another root
node specifier.

As an alternative solution the `-N/--nodes` and `-O/--output-file`
options are added that replace the positional arguments that are now
deprecated.

Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
GeigerJ2 pushed a commit to GeigerJ2/aiida-core that referenced this pull request Apr 16, 2024
…eam#6338)

So far, the command only allowed to specify a single root node through
a positional argument. However, in some cases having multiple root nodes
are perfectly sensible. Unfortunately, simply changing the positional
argument to accept multiple nodes won't work because the command also
accepts a second optional positional argument to specify the output
filename. Making the root node accept multiple values will make it
greedy and it will always mistake the output filename as another root
node specifier.

As an alternative solution the `-N/--nodes` and `-O/--output-file`
options are added that replace the positional arguments that are now
deprecated.

Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants