hydromodpy.simulation.execution.runner#

Execute a resolved SimulationPlan against a prepared runtime state.

The runner is the orchestration layer that sits between planning and concrete solver APIs.

By the time this module runs, the planner has already converted the declarative [simulation] block into a flat ordered list of concrete ProcessRun objects. The runner therefore does not decide what should run or in which order. Its job is narrower:

  • walk through the runs in the order provided by the planner,

  • ensure each process-family block has its required runtime objects,

  • open and close process-family blocks via optional callbacks,

  • resolve the exact upstream models referenced by depends_on,

  • delegate solver-specific execution to the matching adapter,

  • store each produced model back into state.execution.models_by_run_id.

In one sentence:

  • the runner knows the plan and the runtime state;

  • the adapters know how to call the concrete solvers.

Keeping this logic separate from the planner avoids mixing dependency validation with side effects. Keeping it separate from the adapters avoids mixing generic orchestration with solver-specific API calls.

Functions

ensure_flow(state)

Create state.setup.flow from state.cfg.flow when missing.

ensure_process_context(state, process_type)

Ensure all process objects required by process_type exist.

ensure_transport(state)

Create state.setup.transport from state.cfg.transport when missing.

Classes

ProcessCallbacks([before_process, ...])

Optional callbacks fired when the runner enters or leaves a process family.

SimulationRunner([callbacks])

Sequentially execute a resolved plan and persist each produced model.