fastoad.cmd.calc_runner module
Tools for running multiple computations
- class fastoad.cmd.calc_runner.CalcRunner(configuration_file_path: str | PathLike, input_file_path: str | PathLike | None = None, optimize: bool = False)[source]
Bases:
object
Class for running FAST-OAD computations for a specific configuration.
It is specifically designed to run several computations concurrently with
run_cases()
. For each computation, data can be isolated in a specific folder.- run(input_values: VariableList | None = None, calculation_folder: str | PathLike | None = None) DataFile [source]
Run the computation.
This method is useful to set input values on-the-fly, and/or isolate the computation data in a dedicated folder.
- Parameters:
input_values – if provided, these values will supersede the content of input file (specified in configuration file)
calculation_folder – if specified, all data, including configuration file, will be stored in that folder. The input file in this folder will contain data from input_values
- Returns:
the written output data
- run_cases(input_list: List[VariableList], destination_folder: str | PathLike, *, max_workers: int | None = None, use_MPI_if_available: bool = True, overwrite_subfolders: bool = False)[source]
Run computations concurrently.
The data of each computation will be isolated in a dedicated subfolder of destination folder.
- Parameters:
input_list – a computation will be run for each item of this list
destination_folder – The data of each computation will be isolated in a dedicated subfolder of this folder.
max_workers – if not specified, all available processors will be used. Set to -1 to use all available processors except 1 (useful when running locally while keeping some CPU for working meanwhile).
use_MPI_if_available – If False, or if no MPI implementation is available, computations will be run concurrently using the multiprocessing library.
overwrite_subfolders – if False, calculations that match existing subfolders won’t be run (allows batch continuation)