macrostat.util package

Submodules

macrostat.util.batchprocessing module

Batch processing functionionality

macrostat.util.batchprocessing.parallel_processor(tasks: list = [], worker: callable = <function timeseries_worker>, cpu_count: int = 1, tqdm_info: str = '')[source]

Run all of the tasks in parallel using the ProcessPoolExecutor.

Parameters:
  • tasks (list[tuple]) – List of tasks to be processed in parallel. Each task should be a tuple

  • worker (callable) – Worker function to be used for the parallel processing. Each task will be passed to the worker function as a tuple

  • cpu_count (int (default=1)) – Number of CPUs to be used for the parallel processing.

  • tqdm_info (str (default="")) – Information to be displayed in the tqdm progress bar.

Returns:

List of tuple results from the worker function

Return type:

list

macrostat.util.batchprocessing.timeseries_worker(task: tuple)[source]

Worker function for parallel_processor, which will execute a simulation with the given parameters and return the output.

Parameters:

task (tuple) – Tuple of (name, model, *args) where name is the name of the simulation, model is the model to be simulated and *args are the arguments to be passed to the model’s simulate method.

Returns:

Tuple of (name, *args, output) where name is the name of the simulation, *args are the arguments passed to the model’s simulate method and output is the output of the simulation.

Return type:

tuple

Module contents