bout_runners.parameters.final_parameters¶
Contains the class dealing with the final parameters.
Classes
|
Class which deals with the final parameters. |
-
class
bout_runners.parameters.final_parameters.
FinalParameters
(default_parameters: Optional[bout_runners.parameters.default_parameters.DefaultParameters] = None, run_parameters: Optional[bout_runners.parameters.run_parameters.RunParameters] = None)[source]¶ Class which deals with the final parameters.
The final parameters are those who are going to be used in the execution of the project
Examples
The easiest way to use FinalParameters is to run a script from the root directory of the project (i.e. where the Makefile and data directory are normally situated. The script can simply call
>>> FinalParameters().get_final_parameters() {'global': {'append': False, 'async_send': False, ...}}
A more elaborate example where all the dependency objects are built manually:
Import dependencies
>>> from pathlib import Path >>> from bout_runners.executor.bout_paths import BoutPaths >>> from bout_runners.parameters.default_parameters import DefaultParameters >>> from bout_runners.parameters.run_parameters import RunParameters
Create the bout_paths object
>>> project_path = Path().joinpath('path', 'to', 'project') >>> bout_inp_src_dir = Path().joinpath('path', 'to', 'source', 'BOUT.inp') >>> bout_inp_dst_dir = Path().joinpath('path', 'to', 'destination', 'BOUT.inp') >>> bout_paths = BoutPaths(project_path=project_path, ... bout_inp_src_dir=bout_inp_src_dir, ... bout_inp_dst_dir=bout_inp_dst_dir)
Get the final parameters
>>> default_parameters = DefaultParameters(bout_paths=bout_paths) >>> final_parameters = FinalParameters(default_parameters, ... RunParameters({'nout': 10})) >>> final_parameters_dict = final_parameters.get_final_parameters() >>> final_parameters_dict {'global': {'append': False, 'async_send': False, ..., 'nout': 10, ...}}
>>> final_parameters.\ ... cast_to_sql_type(final_parameters_dict) {'global': {'append': TEXT, 'async_send': TETX, ..., 'nout': INTEGER, ...}}
- Attributes
- self.__default_parametersDefaultParameters
Object dealing with the default parameters
- self.__run_parameters = run_parameters
Object dealing with the run parameters
Methods
get_final_parameters()
Obtain the final parameters that will be used in a run
cast_parameters_to_sql_type(parameter_dict)
Cast the values of a parameter dict to valid SQL types
Set the member data.
- Parameters
- default_parametersDefaultParameters or None
Object dealing with default parameters (i.e. standard BOUT++ parameters, or those given in BOUT.inp)
- run_parametersRunParameters or None
Object dealing with run parameters (i.e. parameters set in bout_runner which has precedence over BOUT.inp) If None, default parameters will be used
Methods
cast_to_sql_type
(parameter_dict)Cast the values of a parameter dict to valid SQL types.
Obtain the final parameters that will be used in a run.
-
static
cast_to_sql_type
(parameter_dict: Dict[str, Dict[str, Union[str, int, float]]]) → Dict[str, Dict[str, str]][source]¶ Cast the values of a parameter dict to valid SQL types.
- Parameters
- parameter_dictdict
Dictionary containing the parameters given in BOUT.settings On the form
>>> {'section': {'parameter': 'value'}}
- Returns
- parameter_dict_as_sql_typesdict
Dictionary containing the parameters given in BOUT.settings On the form
>>> {'section': {'parameter': 'value_type'}}
-
get_final_parameters
() → Dict[str, Dict[str, Union[int, float, bool, str]]][source]¶ Obtain the final parameters that will be used in a run.
- Returns
- final_parameters_dictdict
Parameters on the form
>>> {'global':{'append': 'False', 'nout': 5}, ... 'mesh': {'nx': 4}, ... 'section_in_BOUT_inp': {'some_variable': 'some_value'}}
- Raises
- RuntimeError
If run_parameters_dict is None