Command Arguments and Base Configuration

pavilion.arguments module

Sets up a base set of pavilion arguments, and allows plugins and other components to add sub-commands.

pavilion.arguments.get_parser(add_commands: bool = True)

Get the main pavilion argument parser. This is generally only meant to be used by the main pavilion command. If the main parser hasn’t yet been defined, this defines it.

Parameters:

add_commands – Add arguments to the parser for all commands.

pavilion.config module

This module defines the base configuration for Pavilion itself.

Pavilion can have multiple configuration directories. However, many options apply only to the ‘base’ configuration. Additional directories can be specified in that base config or through other options.

class pavilion.config.ExPathElem(name=None, **kwargs)

Bases: PathElem

Expand environment variables in the path.

validate(value, partial=False)

Expand environment variables in the path.

class pavilion.config.LocalConfig(set_attrs: dict | None = None)

Bases: PavConfigDict

This provides type checkers something to working with. See PavConfig above.

class pavilion.config.LocalConfigLoader(name='<root>')

Bases: YamlConfigLoader

Loads the configuration for an individual Pavilion config directory.

ELEMENTS = [<yaml_config RegexElem label>, <yaml_config ExPathElem working_dir>, <yaml_config StrElem group>, <yaml_config ExPathElem path>]
type

alias of LocalConfig

class pavilion.config.PavConfig(set_attrs=None)

Bases: PavConfigDict

Define types and attributes for Pavilion config options.

property config_paths: Iterator[Path]

Return an iterator of paths to all config directories

find_file(file: Path | str, sub_dirs: List[Path | str] | Path | str | None = None) Path | None
Look for the given file and return a full path to it. Relative paths

are searched for in all config directories under ‘sub_dir’, if it exists.

Parameters:
  • file – The path to the file.

  • sub_dirs – The subdirectory (or list of subdirectories) in which to search in each directory.

Returns:

The full path to the found file, or None if no such file could be found.

property result_logs: List[Path]

Return a list of all result log paths, which may be paths to either files (in the case of common file loggers) or directories (in the case of series file loggers).

property suite_info: List[Tuple[str, str, Path]]

Get the label, name, and path for every suite the config knows about. If the suite uses a suite directory structure, the path with be the directory itself. Otherwise, the path with be the suite config file.

property suite_names: Iterator[str]

Return an iterator of suite names

property suite_paths: Iterator[Path]

Return an iterator of paths to all test suites

property suites_dirs: Iterator[Path]

Return an iterator of paths to all suites directories

property tests_dirs: Iterator[Path]

Return an iterator of paths to all test directories.

class pavilion.config.PavConfigDict(set_keys: dict | PavConfigDict | None = None)

Bases: object

The default config dict class is meant for flexibility. We want something that can also handle type checking.

as_dict() dict

Return keys and values as a standard dictionary.

copy()

Create a copy of this PavConfigDict

get(key, default=None)

Return the value of ‘key’, or the default if key doesn’t exist.

items()

Produce an iterable of (key, value) tuples.

keys()

Produce an iterable of the keys.

values()

Produce an iterable of the values.

exception pavilion.config.PavConfigError(msg, prior_error=None, data=None)

Bases: PavilionError

Config specific errors.

class pavilion.config.PavilionConfigLoader(name='<root>')

Bases: YamlConfigLoader

This object uses YamlConfig to define Pavilion’s base configuration format and options. If you’re looking to add an option to the general pavilion.yaml format, this is the place to do it.

DEFAULT_RESULT_LOGGER_TIMEOUT = 3600
ELEMENTS = [<yaml_config ListElem config_dirs>, <yaml_config BoolElem user_config>, <yaml_config ExPathElem working_dir>, <yaml_config ExPathElem spack_path>, <yaml_config ListElem disable_plugins>, <yaml_config StrElem shared_group>, <yaml_config StrElem umask>, <yaml_config IntRangeElem build_threads>, <yaml_config IntRangeElem max_threads>, <yaml_config IntRangeElem max_cpu>, <yaml_config StrElem log_format>, <yaml_config StrElem log_level>, <yaml_config ExPathElem result_log>, <yaml_config BoolElem flatten_results>, <yaml_config ExPathElem exception_log>, <yaml_config IntElem wget_timeout>, <yaml_config CategoryElem proxies>, <yaml_config ListElem no_proxy>, <yaml_config ListElem env_setup>, <yaml_config CategoryElem default_results>, <yaml_config ListElem result_loggers>, <yaml_config IntRangeElem result_logger_timeout>, <yaml_config ExPathElem pav_cfg_file>, <yaml_config ExPathElem pav_root>, <yaml_config KeyedElem pav_vars>, <yaml_config KeyedElem configs>, <yaml_config ListElem warnings>]
type

alias of PavConfig

pavilion.config.add_config_dirs(pav_cfg, setup_working_dirs: bool) OrderedDict

Setup the config dictionaries for each configuration directory. This will involve loading each directories config.yaml, and saving the results in this dict. These will be in an ordered dictionary by label.

Parameters:
  • pav_cfg – The pavilion config.

  • setup_working_dirs – Whether to create the working directory structure. Allows us to bypass in cases where we would set incorrect permissions.

pavilion.config.find_pavilion_config(target: Path | None = None, setup_working_dirs=True) PavConfig

Search for a pavilion.yaml configuration file. Use the one pointed to by the PAV_CONFIG_FILE environment variable. Otherwise, use the first found in these directories the default config search paths:

  • The given ‘target’ file (used only for testing).

  • The ~/.pavilion directory

  • The Pavilion source directory (don’t put your config here).

    param target:

    A known path to a Pavilion config.

    param setup_working_dirs:

    Set to False when used outside of the bin/pav provided newgrp/umask environment. Test code generally doesn’t care, unless you’re testing the permissions themselves.

pavilion.config.get_version()

Returns the current version of Pavilion.

pavilion.config.make_config(options: dict, setup_working_dirs: bool = True)

Create a pavilion config given the raw config options.

pavilion.config.make_invalidator(msg)

Returns a function that provides an ‘invalid option’ validator. This will always give an error if the option isn’t null.