pytrnsys_process.process.process_batch.process_whole_result_set_parallel#

pytrnsys_process.process.process_batch.process_whole_result_set_parallel(results_folder: Path, processing_scenario: Callable[[Simulation], None] | Sequence[Callable[[Simulation], None]], max_workers: int | None = None) SimulationsData[source]#

Process all simulation folders in a results directory in parallel.

Uses a ProcessPoolExecutor to process multiple simulations concurrently.

Parameters:
  • results_folder – Path to the directory containing simulation folders. Each subfolder should contain valid simulation data files.

  • processing_scenario – Single callable or sequence of callables that implement the processing logic for each simulation. Each callable should take a Simulation object as its only parameter.

  • max_workers – Maximum number of worker processes to use. If None, defaults to the number of processors on the machine.

Returns:

SimulationsData

  • monthly: Dict mapping simulation names to monthly DataFrame results

  • hourly: Dict mapping simulation names to hourly DataFrame results

  • scalar: DataFrame containing scalar/deck values from all simulations

Return type:

pytrnsys_process.api.SimulationsData

Raises:
  • ValueError – If results_folder doesn’t exist or is not a directory:

  • Exception – Individual simulation failures are logged but not re-raised:

Example

>>> import pathlib as _pl
>>> from pytrnsys_process import api
...
>>> def processing_step_1(sim):
...     # Process simulation data
...     pass
>>> def processing_step_2(sim):
...     # Process simulation data
...     pass
>>> results = api.process_whole_result_set_parallel(
...     _pl.Path("path/to/results"),
...     [processing_step_1, processing_step_2]
... )