Command Arguments and Base Configuration¶
Table of Contents
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
()¶ 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:
yaml_config.scalars.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)¶ Bases:
pavilion.config.PavConfigDict
This provides type checkers something to working with. See PavConfig above.
-
class
pavilion.config.
LocalConfigLoader
(name='<root>')¶ Bases:
yaml_config.loaders.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:
pavilion.config.PavConfigDict
Define types and attributes for Pavilion config options.
-
class
pavilion.config.
PavConfigDict
(set_keys: 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.
-
-
class
pavilion.config.
PavilionConfigLoader
(name='<root>')¶ Bases:
yaml_config.loaders.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>]¶
-
-
pavilion.config.
add_config_dirs
(pav_cfg, setup_working_dirs: bool) → collections.OrderedDict¶ Setup the config dictionaries for each configuration directory. This will involve loading each directories pavilion.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.
config_dirs_validator
(config, values)¶ Get all of the configurations directories and convert them into path objects.
-
pavilion.config.
find_pavilion_config
(target: pathlib.Path = None, warn: bool = True, setup_working_dirs=True) → pavilion.config.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 warn: Issue printed warnings. 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.