Reconfigurator¶
Submodules¶
Markup modules¶
Sample¶
This script is samples a set of variables and adds them to a configuration file
- sample.from_file_to_file(sample_file: str, save_file: str)¶
Samples variables for experiments
- Parameters:
sample_file – (str) Filename for sample params
save_file – (str) Filename for saving params
- sample.sample(sample_params: dict)¶
Samples variables using specification
Note For those using from_file_to_file or sample_all, sample params can be specified with the string key of another variable and it will be replaced with a copy of that value. Additionally, samples can be multi-dimensional
- Params sample_params:
(dict) Contains sample parameters as follows:
Continous sample {
“low”: lower limit “high”: upper limit “num_increments”: (optional) number of increments to down sample a continuous space “num”: (optional) number of times to sample
}
Discrete sample {
“choice”: Options to sample from “probability”: probability to sample from “num”: (optional) number of times to sample
}
- Returns:
(list) sampled values
- sample.sample_all(sample_config: dict, output: dict)¶
Sample configuration to an output dictionary
Sampling uses NestifyDict so variables can be specified as their deepest key assuming this variable is only used in one place. Otherwise the variable should be defined as a list. Nonexistent keys are skipped as the sampling declarations are contained here.
- Parameters:
sample_config – (dict) Sample configuration
output – (dict) Where to add samples
Compiler¶
This script contains functions for compiling a dense configuration file into a list of configurations.
- compiler.compile_as_generator(config: dict)¶
Compiles dense configuration using a generator to get all sets of configurations
- Parameters:
config – (dict) dense configuration file
- Returns:
(dict) a single configuration
- compiler.compile_to_list(config: dict)¶
Compiles dense configuration to get list of all sets of configurations
- Parameters:
config – (dict) dense configuration file
- Returns:
(list) all configurations captured
Reconfigurator CLI module¶
Reconfigurator¶
Key functionalities are to - Overwrite configs with replace - Merge a series of config files - Update variables in a configuration - Print a configuration
Command Line Interface¶
The reconfigurator can be accessed using reconfigurator <flag> <args>. Use man reconfigurator for more information.
- reconfigurator.compile_config_file(config_file: str)¶
Compile a configuration file into a list of configurations
- Parameters:
config_file – (str) location of file to compile
- reconfigurator.merge_file(source_files: list, do_append: bool = False)¶
Accepts a list of configuration files and merges them into a single file. Last file will be destination
- Parameters:
source_files – (list(str)) Files to merge, if priority matters, later defaults will overwrite earlier ones.
do_append – (bool) if true, iterables inside dictionaries will be merged as well, default: False
- reconfigurator.print_config(config: dict)¶
Prints configuration
- Parameters:
config – (dict) Configuration params
- reconfigurator.print_config_file(file: str)¶
Prints configuration file settings
- Parameters:
file – (str) Location of configuration params
- reconfigurator.replace_file(sink_file: str, source_file: str)¶
Replace one file with another
- Parameters:
sink_file – (str) location of new to write into
source_file – (str) location of file to write from
- reconfigurator.update(var, val, config: dict, update_all: bool = False)¶
Update one or more config values in a file
- Parameters:
var – () parameter to update
val – () new value of parameter
config – (dict) configuration
update_all – (bool) if true, accepts var as a list of keys, default: False
- reconfigurator.update_file(var, val, file: str, update_all: bool = False)¶
Update one or more config values in a file
- Parameters:
var – () parameter to update
val – () new value of parameter
file – (str) location of file
update_all – (bool) if true, accepts var as a list of keys, default: False