romtools.workflows.model_execution#
Shared execution of blocking models and scheduler-backed job handles.
Functions
|
Read a model's QoI as an executor completion callback. |
|
Execute evaluations and return results in input order. |
|
Apply dispatcher process-safety restrictions to blocking models. |
Classes
|
Exceptions
|
A model returned an unsuccessful exit status. |
- class romtools.workflows.model_execution.ModelEvaluation(run_directory: str, parameter_sample: dict, run_time: float = nan, output: Any = None)[source]#
Bases:
object- Parameters:
run_directory (str)
parameter_sample (dict)
run_time (float)
output (Any)
- exception romtools.workflows.model_execution.ModelRunError(directory, status, run_time)[source]#
Bases:
RuntimeErrorA model returned an unsuccessful exit status.
- romtools.workflows.model_execution.compute_evaluation_qoi(model, evaluation)[source]#
Read a model’s QoI as an executor completion callback.
- romtools.workflows.model_execution.execute_models(model, evaluations, max_concurrent=1, poll_interval=0.1, *, prepare=None, postprocess=None, scope=None, start_method='spawn', return_exceptions=False, ignore_blocking_status=False)[source]#
Execute evaluations and return results in input order.
Optional prepare and postprocess callbacks take (model, evaluation). Postprocessing runs only after a successful exit and its return value is stored in evaluation.output. Blocking model callbacks run in the same process as the model, using a process pool when concurrency exceeds one. Non-blocking models use the caller’s process and keep at most max_concurrent handles in flight. An optional scope wraps each blocking evaluation or each submission and completion phase of a non-blocking one. Non-blocking polling and completion resume in the working directory left by submission and restore the caller’s directory afterward.
By default failures raise. With return_exceptions, failed entries contain exceptions and the remaining evaluations continue. Workflows that used to ignore blocking return values can preserve that behavior with ignore_blocking_status. Non-blocking exit statuses are always checked. After a non-blocking batch error, successful in-flight siblings still run postprocessing before the original error is raised.