pyDeltaRCM.preprocessor.BasePreprocessor¶
- class pyDeltaRCM.preprocessor.BasePreprocessor¶
Base preprocessor class.
Defines a prelimiary yaml reading, then handles the YAML “meta” tag parsing, model instatiation, and job running.
Subclasses create the high-level command line API and the high-level python API.
Note
You probably do not need to interact with this class direclty. Check out the Python API.
- __init__() None ¶
Initialize the base preprocessor.
Methods
__init__
()Initialize the base preprocessor.
Construct the file list.
open_input_file_to_dict
(input_file)Open an input file and convert it to a dictionary.
run_jobs
([DeltaModel])Run the set of jobs.
Attributes
Configuration list.
File list.
Job list.
- _expand_ensemble() None ¶
Create ensemble random seeds and put into matrix.
Ensemble expansion is implemented as a special class of matrix/set expansion where:
if set specification is used, each set is duplicated the specified number of times, and a seed is added to each set
otherwise, the matrix key is set for the seed field of the model
This approach ensures that the runs will have different outcomes, while allowing all other parameters to remain fixed, and supporting additional keys in the matrix/set.
In the non-set expansion implementation, if the matrix does not yet exist (e.g., only ensemble specified), then the matrix is created.
- _expand_matrix() None ¶
Expand YAML matrix.
Compute the matrix expansion of parameters listed in matrix key.
- _open_yaml(input_file)¶
Safely open, read, and close a yaml file.
- Parameters:
file (input) – string or path to file
- Returns:
yaml file, as a Python dict
- Return type:
yaml_dict
- _prelim_config_parsing() None ¶
Preliminary configuration parsing.
Extract
.yml
file (self.input_file
) into a dictionary, if provided. This dictionary provides a few keys used throughout the code.Here, we check whether the file is valid yaml, and place it into a dictionary.
Additionally, set the
self._has_matrix
flag, which is used in the_expand_matrix()
.
- property config_list¶
Configuration list.
A list of dict containing the input configurations for jobs constructed by the preprocessor.
- construct_file_list() None ¶
Construct the file list.
The job list is constructed by expanding the various multi-job specifications. For example, matrix, set, and ensemble yaml files are created in this stage.
- property file_list: List[Path]¶
File list.
A list of Path to input YAML files for jobs constructed by the preprocessor.
- property job_list¶
Job list.
A list of jobs, type
_SerialJob
or_ParallelJob
, from the jobs executed by the preprocessor.Note
This will be an empty list before
run_jobs
has been called.
- open_input_file_to_dict(input_file: str | Path)¶
Open an input file and convert it to a dictionary.
This method is used by subclassing Preprocessors to complete the first import of the yaml configuration.
- Parameters:
input_file – Path to the input file as string, or Pathlib Path.
- Returns:
Input file converted to a dictionary.
- Return type:
yaml_dict
- run_jobs(DeltaModel=None) None ¶
Run the set of jobs.
This method can be seen as the actual execution stage of the preprocessor. If –parallel is specified in the command line or YAML file, the jobs will run in parallel.