SolverAdapter#

class hydromodpy.solver.SolverAdapter(*args, **kwargs)[source]#

Bases: Protocol

One adapter binds one (process_type, solver_name) pair.

validate(ctx)[source]#

Fail-fast precondition checks before execute.

Parameters:

ctx (RunContext)

Return type:

None

execute(ctx)[source]#

Run the concrete solver for ctx.run and return its outputs.

Parameters:

ctx (RunContext)

Return type:

RunExecutionResult

cleanup(ctx)[source]#

Release temporary scratch files after extraction completes.

Parameters:

ctx (RunContext)

Return type:

None

extract_observables(ctx, store, requests, *, time_index=None)[source]#

Read every requested observable from this run, keyed by request id.

The whole batch arrives at once so a backend opens each binary file once instead of once per request, and a backend driven through an API knows before the solve which timesteps it has to keep.

Lightweight calibration trials read straight from the solver scratch dir via ctx.state.execution.output_dirs_by_run_id; store is the cold-path Catalog reserved for backends that already wrote results to it.

An adapter that cannot produce a requested observable raises ObservableNotAvailableError naming it. That refusal is the contract: a caller never reads a signature to find out what a backend supports.

Parameters:
Return type:

dict[str, ObservableResult]