Batch¶
Core Concept¶
A Batch is responsible for executing a collection of simulation runs.
Each run is identified by an integer index:
Run 0 \
Run 1 \
...
Run N
For each run, the Batch determines:
- what command should be executed
- what preparation is required before execution
- what processing is required after execution
Execution Lifecycle¶
A Batch progresses through several phases for each run:
- Preparation — setup work before execution (create directories, write inputs)
- Execution — run the command
- Validation — verify simulation outputs exist and are valid
- Post-Processing — collect results, compute metrics, generate reports
Core Components¶
BatchExecCmdIter¶
The BatchExecCmdIter class manages batch execution and coordinates the full lifecycle.
See API BatchExecCmdIter
InputsBuilder¶
Prepares simulation inputs for each case before execution.
Example:
from studpy.batch import OneFileInputsBuilder
inputs_builder = OneFileInputsBuilder(
template_path="inputs/template.txt",
output_dir="runs",
)
See API OneFileInputsBuilder
Execution Modes¶
Sequential Execution¶
Run simulations one at a time:
Useful for: - Single-core systems - Debugging - I/O constrained problems
Parallel Execution¶
Run multiple simulations concurrently:
Useful for: - Multi-core systems - Independent simulations - Reducing total execution time
Configuration¶
Progress Reporting¶
Monitor execution progress in real-time:
Error Handling¶
Control behavior when simulations fail:
Output Validation¶
Verify simulation outputs before collection:
Best Practices¶
Start with sequential execution¶
Debug inputs and command configuration before parallelizing.
Validate early¶
Test your InputsBuilder on a small subset before full batch execution.
Use consistent naming¶
Structure output directories consistently across all runs:
Monitor resource usage¶
Adjust max_workers based on available system memory and CPU.
Collect intermediate results¶
Enable result collection at regular intervals to avoid data loss on failure.
Typical Workflow¶
- Build
CaseBuilderwith parameter definitions - Generate cases dataset
- Create
InputsBuilderfor case preparation - Initialize
BatchExecCmdIterwith execution command - Execute batch (sequential or parallel)
- Validate outputs
- Aggregate results