Command Plugins

pavilion.commands module

class pavilion.commands.Command(name, description, short_help=None, aliases=None)

Provides a pavilion command via a plugin.

_setup_arguments(parser)

Setup the commands arguments in the Pavilion argument parser. This is handed a pre-created sub-command parser for this command. Simply add arguments to it like you would a base parser.

parser.add_arguemnt('-x', '--extra',
                    action='store_true',
                    help="Add extra stuff.")
Parameters:parser (argparse.ArgumentParser) – The parser object.
_setup_other()

Additional setup actions for this command at activation time. The base version of this does nothing..

activate()

The Yapsy plugin system calls this to setup the plugin. In this case that includes:

  • Adding the command’s sub-command arguments to the general pavilion argument parser.
  • Running the _setup_other method.
  • Adding the command to Pavilion’s known commands.
clear_output()

Reset the output io buffers for this command.

deactivate()

You can’t deactivate commands.

run(pav_cfg, args)

Override this method with your command’s code.

Parameters:
  • pav_cfg – The pavilion configuration object.
  • args (argparse.Namespace) – The parsed arguments for pavilion.
Returns:

The return code of the command should denote success (0) or failure (not 0).

silence()

Convert the command to use string IO for its output and error output.

exception pavilion.commands.CommandError

Bases: RuntimeError

The error type commands should raise for semi-expected errors.

pavilion.commands.add_command(command)

Add the given command instance to the dictionary of commands.

Parameters:command (Command) – The command object to add
pavilion.commands.get_command(command_name)

Return the command of the given name.

Parameters:command_name (str) – The name of the command to search for.
Return type:Command

Included Command Plugins

cancel command

Cancels tests as prescribed by the user.

class pavilion.plugins.commands.cancel.CancelCommand

Bases: pavilion.commands.Command

Cancel a set of commands using the appropriate scheduler.

run(pav_cfg, args)

Cancel the given tests.

clean command

Clean old tests/builds/etc from the working directory.

class pavilion.plugins.commands.clean.CleanCommand

Bases: pavilion.commands.Command

Cleans outdated test and series run directories.

run(pav_cfg, args)

Run this command.

log command

Print out the contents of the various log files for a given test run.

class pavilion.plugins.commands.log.LogCommand

Bases: pavilion.commands.Command

Print the contents of log files for test runs.

LOG_PATHS = {'build': 'build.log', 'kickoff': 'kickoff.log', 'results': 'results.log', 'run': 'run.log'}
run(pav_cfg, args)

Figure out which log the user wants and print it.

result command

Print the test results for the given test/suite.

class pavilion.plugins.commands.result.ResultsCommand

Bases: pavilion.commands.Command

Plugin for result printing.

BASE_FIELDS = ['name', 'id', 'sys_name', 'started', 'finished', 'result']
run(pav_cfg, args)

Print the test results in a variety of formats.

update_results(pav_cfg: dict, tests: List[pavilion.test_run.TestRun], log_file: IO[str]) → bool

Update each of the given tests with the result section from the current version of their configs. Then rerun result processing and update the results in the test object (but change nothing on disk).

Parameters:
  • pav_cfg – The pavilion config.
  • tests – A list of test objects to update.
  • log_file – The logfile to log results to. May be None.
Returns:

True if successful, False otherwise. Will handle printing of any failure related errors.

run command

The run command resolves tests by their names, builds them, and runs them.

class pavilion.plugins.commands.run.RunCommand

Bases: pavilion.commands.Command

Resolve tests by name, build, and run them.

Variables:
  • last_series (TestSeries) – The suite number of the last suite to run with this command (for unit testing).
  • last_tests (List[TestRun]) – A list of the last test runs that this command started (also for unit testing).
BUILD_ONLY = False
BUILD_SLEEP_TIME = 0.1
BUILD_STATUS_PREAMBLE = '{when:20s} {test_id:6} {state:{state_len}s}'
SLEEP_INTERVAL = 1
build_local(tests, max_threads, mb_tracker, build_verbosity)

Build all tests that request for their build to occur on the kickoff host.

Parameters:
  • tests (list[TestRun]) – The list of tests to potentially build.
  • max_threads (int) – Maximum number of build threads to start.
  • build_verbosity (int) – How much info to print during building. See the -b/–build-verbose argument for more info.
  • mb_tracker (MultiBuildTracker) – The tracker for all builds.
check_result_format(tests)

Make sure the result parsers for each test are ok.

run(pav_cfg, args)

Resolve the test configurations into individual tests and assign to schedulers. Have those schedulers kick off jobs to run the individual tests themselves. :param pav_cfg: The pavilion configuration. :param args: The parsed command line argument object.

run_tests(pav_cfg, tests_by_sched, series, wait, report_status)
Parameters:
  • pav_cfg
  • tests_by_sched (dict[str,[TestRun]]) – A dict by scheduler name of the tests (in a list).
  • series – The test series.
  • wait (int) – Wait this long for a test to start before exiting.
  • report_status (bool) – Do a ‘pav status’ after tests have started. on nodes, and kick them off in build only mode.
Returns:

set_status command

Set the status for a test run. Typically used by pavilion when a test run errors inside its run script.

class pavilion.plugins.commands.set_status.SetStatusCommand

Bases: pavilion.commands.Command

Plugin for setting the status of a test.

run(pav_cfg, args)

Set the status of the given test.

show command

Show a variety of different internal information for Pavilion.

class pavilion.plugins.commands.show.ShowCommand

Bases: pavilion.commands.Command

Plugin to show Pavilion internal info.

SUMMARY_SIZE_LIMIT = 100
run(pav_cfg, args)

Run the show command’s chosen sub-command.

pavilion.plugins.commands.show.show_cmd(*aliases)

Tag this given function as a show_cmd, and record its aliases.

status command

The Status command, along with useful functions that make it easy for other commands to print statuses.

class pavilion.plugins.commands.status.StatusCommand

Bases: pavilion.commands.Command

Prints the status of a set of tests.

display_history(pav_cfg, args)

Display_history takes a test_id from the command line arguments and formats the status file from the id and displays it for the user through draw tables. :param pav_cfg: The pavilion config. :param argparse namespace args: The test via command line :rtype int

print_summary(statuses)

Print_summary takes in a list of test statuses. It summarizes basic state output and displays the data to the user through draw_table. :param statuses: state list of current jobs :rtype: int

run(pav_cfg, args)

Gathers and prints the statuses from the specified test runs and/or series.

pavilion.plugins.commands.status.get_all_tests(pav_cfg, args)

Return the statuses for all tests, up to the limit in args.limit.

pavilion.plugins.commands.status.get_last_ctime(path)

Gets the time path was modified.

pavilion.plugins.commands.status.get_statuses(pav_cfg, args, errfile)

Get the statuses of the listed tests or series.

Parameters:
  • pav_cfg – The pavilion config.
  • namespace args (argparse) – The tests via the command line args.
  • errfile – stream to output errors as needed.
Returns:

List of dictionary objects with the test id, name, state, time that the most recent status was set, and the associated note.

pavilion.plugins.commands.status.get_tests(pav_cfg, args, errfile)
Gets the tests depending on arguments.
Parameters:
  • pav_cfg – The pavilion config
  • namespace args (argparse) – The tests via command line args.
  • errfile – stream to output errors as needed
Returns:

List of test objects

pavilion.plugins.commands.status.print_from_test_obj(pav_cfg, test_obj, outfile, json=False)

Print the statuses given a list of test objects or a single test object.

Parameters:
  • pav_cfg (dict) – Base pavilion configuration.
  • test_obj (Union(test_run.TestRun,list(test_run.TestRun)) – Single or list of test objects.
  • json (bool) – Whether the output should be a JSON object or not.
  • outfile (stream) – Stream to which the statuses should be printed.
Returns:

0 for success.

Return type:

int

pavilion.plugins.commands.status.print_status(statuses, outfile, json=False, show_skipped=False)

Prints the statuses provided in the statuses parameter.

Parameters:
  • statuses (list) – list of dictionary objects containing the test ID, name, state, time of state update, and note associated with that state.
  • json (bool) – Whether state should be printed as a JSON object or not.
  • outfile (stream) – Stream to which the statuses should be printed.
Returns:

success or failure.

Return type:

int

pavilion.plugins.commands.status.status_from_test_obj(pav_cfg: dict, *test_objs)
Takes a test object or list of test objects and creates the dictionary
expected by the print_status function.
Parameters:
  • pav_cfg – Pavilion base configuration.
  • test_obj – Pavilion test object.
Returns:

List of dictionary objects containing the test ID, name, statt time of state update, and note associated with that state.

Return type:

list(dict)

view command

class pavilion.plugins.commands.view.ViewCommand

Bases: pavilion.plugins.commands.run.RunCommand

SLEEP_INTERVAL = 1
run(pav_cfg, args)

Resolve the test configurations into individual tests and assign to schedulers. Have those schedulers kick off jobs to run the individual tests themselves. :param err_file:

wait command

class pavilion.plugins.commands.wait.WaitCommand

Bases: pavilion.commands.Command

run(pav_cfg, args)

Override this method with your command’s code.

Parameters:
  • pav_cfg – The pavilion configuration object.
  • args (argparse.Namespace) – The parsed arguments for pavilion.
Returns:

The return code of the command should denote success (0) or failure (not 0).