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

CLI: Improve the quality of verdi code list output #5750

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Nov 4, 2022

The output of verdi code list was being formatted "by hand" and as a result was quite different from the output of other commands that typically use the tabulate library to do the formatting.

The command is refactored to use tabulate. A single query is created which is more readable compared to the old logic and filters for each of the entities are built up consistently based on the options passed to the command.

The -P/--project option is added. Just as for verdi proces list this option allows to control which properties of the query are projected and printed to stdout. This means that the -o/--show-owner option is no longer needed and so is deprecated. It can be replaced by using -P user with the new option.

The new option also allows projecting the "entry_point" of the Code instances that are matched by the query. This has become interesting since recently the AbstractCode class allows plugins to provide custom implementations registered through an entry point.

@sphuber
Copy link
Contributor Author

sphuber commented Nov 5, 2022

Old look:

# List of configured codes:
# (use 'verdi code show CODEID' to see the details)
* pk 41871 - split
* pk 42987 - cif-filter@localhost
* pk 42988 - cif-select@localhost
* pk 56729 - pw-v6.6@localhost
* pk 56730 - ph-v6.6@localhost
* pk 57650 - echo@localhost

New look:

Report: Use `verdi code show IDENTIFIER` to see details for a code
Full label                       Pk  Entry point
----------------------------  -----  -----------------------
split                         41871  core.code.portable
cif-filter@localhost          42987  core.code
cif-select@localhost          42988  core.code
pw-v6.6@localhost             56729  core.code.installed
ph-v6.6@localhost             56730  core.code.installed
echo@localhost                57650  core.code.shell

Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

thanks @sphuber , looks good to me!

two optional suggestions

aiida/cmdline/commands/cmd_code.py Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_code.py Outdated Show resolved Hide resolved
The output of `verdi code list` was being formatted "by hand" and as a
result was quite different from the output of other commands that
typically use the `tabulate` library to do the formatting.

The command is refactored to use `tabulate`. A single query is created
which is more readable compared to the old logic and filters for each of
the entities are built up consistently based on the options passed to
the command.

The `-P/--project` option is added. Just as for `verdi proces list` this
option allows to control which properties of the query are projected and
printed to stdout. This means that the `-o/--show-owner` option is no
longer needed and so is deprecated. It can be replaced by using `-P user`
with the new option.

The new option also allows projecting the "entry_point" of the `Code`
instances that are matched by the query. This has become interesting
since recently the `AbstractCode` class allows plugins to provide
custom implementations registered through an entry point.

In adding the project option, the `-P/--input-plugin` option had to be
changed since the short flag `-P` overlapped. This was anyway a good
idea since the attribute `input_plugin` has long ago been renamed to
`default_calc_job_plugin` so the option now takes the flags `-d` and
`--default-calc-job-plugin`.
@sphuber sphuber merged commit 6488802 into aiidateam:main Nov 7, 2022
@sphuber sphuber deleted the fix/verdi-code-list branch November 7, 2022 08:59
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.

2 participants