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.

class pavilion.arguments.WrappedFormatter(prog, indent_increment=2, max_help_position=24, width=None)

Bases: HelpFormatter

pavilion.arguments.get_parser()

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.

pavilion.arguments.get_subparser()

Get the pavilion subparser object. This should be used by command plugins to add sub-commands and their arguments to Pavilion. (If you’re writing a command, use the _setup_arguments method on automatically provided sub-command parser.)

See https://docs.python.org/3/library/argparse.html#sub-commands

Return type

argparse._SubParsersAction

pavilion.arguments.reset_parser()

Reset back to the base parser. This is for unittests only.

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: Optional[dict] = 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.

find_file(file: Path, sub_dir: Optional[Union[str, Path]] = None) Optional[Path]
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_dir – The subdirectory in each config directory in which to search.

Returns

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

class pavilion.config.PavConfigDict(set_keys: Optional[Union[dict, PavConfigDict]] = 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.

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 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: Optional[Path] = 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.