mmgp.utils¶
Attributes¶
This dictionary defines the expected structure of a YAML configuration file. |
Functions¶
|
|
|
Recursively validate the structure and data types of a configuration dictionary. |
|
Read and process the YAML configuration file specified during class initialization. |
|
Read and process problem definition data from a directory. |
|
Reset or create a folder by deleting its contents. |
|
Remove a file if it exists. |
|
Return a string representation of the settings in a readable format (pretty print). |
Module Contents¶
- mmgp.utils.expected_structure[source]¶
This dictionary defines the expected structure of a YAML configuration file. It specifies the keys that should be present in the configuration file and their expected data types.
- mmgp.utils.validate_configs(configs: dict, v_structure: dict, depth_accumulator: str = '')[source]¶
Recursively validate the structure and data types of a configuration dictionary.
This function checks whether a given dictionary configs conforms to the expected structure and data types defined in the v_structure dictionary.
- Parameters:
configs (dict) – The configuration dictionary to be validated.
v_structure (dict) – The expected structure.
depth_accumulator (str) – The path from the root of the concerned.
- Returns:
- True if the configs dictionary matches the expected structure
and data types; False otherwise.
- Return type:
bool
- mmgp.utils.read_configuration(config_file: str) dict[str, str][source]¶
Read and process the YAML configuration file specified during class initialization. It then defines the configuration details inside the class.
- Parameters:
config_file (str) – The path to the YAML configuration file.
- Returns:
A dictionary containing configuration information.
- Return type:
dict[str,str]
Example
configuration = read_configuration('config.yaml')
Attention
Ensure that the configuration file exists at the specified path.
The method assumes that the configuration file is in YAML format.
- mmgp.utils.read_problem(configuration: dict) plaid.problem_definition.ProblemDefinition[source]¶
Read and process problem definition data from a directory.
- Parameters:
configuration (dict) – A dictionary containing configuration information.
- Returns:
An instance of the ProblemDefinition class representing the problem.
- Return type:
ProblemDefinition
Note
The fields: “init_dataset_location”, “zone_name” and “base_name” of the configuration file will be used to get and set the ‘problem definition’.
Attention
Ensure that the initial dataset and problem definition files exist at the specified path.
- mmgp.utils.reset_folder(path: str) None[source]¶
Reset or create a folder by deleting its contents.
- Parameters:
path (str) – The path to the folder to be reset or created.
Attention
Use this function with caution, as it permanently deletes the contents of the specified folder.