Skip to content

Commit

Permalink
verdi plugin list: Show which exit codes invalidate cache (#5710)
Browse files Browse the repository at this point in the history
For `Process` entry points, the `verdi plugin list` command will show a
formatted rendering of the process specification. Here we mark exit
codes that invalidate the cache in bold red. For example, the
`ArithmeticAddCalculation` will now display as:

    $ verdi plugin list aiida.calculations core.arithmetic.add
    ...
    Exit codes:

      0  The process finished successfully.
      1  The process has failed with an unspecified error.
      2  The process failed with legacy failure mode.
     11  The process did not register a required output.
    100  The process did not have the required `retrieved` output.
    110  The job ran out of memory.
    120  The job ran out of walltime.
    310  The output file could not be read.
    320  The output file contains invalid output.
    410  The sum of the operands is a negative number.

    Exit codes that invalidate the cache are marked in bold red.
  • Loading branch information
sphuber authored Oct 24, 2022
1 parent de10760 commit 59f5914
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions aiida/cmdline/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
from typing import TYPE_CHECKING

from click import style
from tabulate import tabulate

from . import echo
Expand Down Expand Up @@ -472,10 +473,19 @@ def build_entries(ports):
echo.echo(template.format(*entry, width_name=max_width_name, width_type=max_width_type))

if process_spec.exit_codes:
echo.echo('Exit codes:', fg=echo.COLORS['report'], bold=True)
for exit_code in sorted(process_spec.exit_codes.values(), key=lambda exit_code: exit_code.status):
message = exit_code.message
echo.echo('{:>{width_name}d}: {}'.format(exit_code.status, message, width_name=max_width_name))
echo.echo('\nExit codes:\n', fg=echo.COLORS['report'], bold=True)

table = [('0', 'The process finished successfully.')]

for exit_code in sorted(process_spec.exit_codes.values(), key=lambda exit_code: exit_code.status):
if exit_code.invalidates_cache:
status = style(exit_code.status, bold=True, fg='red')
else:
status = exit_code.status
table.append((status, exit_code.message))

echo.echo(tabulate(table, tablefmt='plain'))
echo.echo(style('\nExit codes that invalidate the cache are marked in bold red.\n', italic=True))


def get_num_workers():
Expand Down

0 comments on commit 59f5914

Please sign in to comment.