Skip to content

Exceptions

ropt.exceptions

Exceptions raised within the ropt library.

Two families are defined here. The errors derive from RoptError and report a failure a caller may catch: WorkflowError, ExecutionError, UnsupportedError and AbortedError.

The other three derive from Exception directly and are control-flow signals rather than errors. OptimizerStop and ExecutorStopped are raised and caught inside ropt. TooFewRealizations is raised by a RealizationFilter that can give no realization a positive weight.

RoptError

Bases: Exception

Base class for all runtime errors raised by ropt.

Catch this to handle any error raised by ropt itself. Configuration and validation errors are not part of this hierarchy; they surface as pydantic.ValidationError. The control-flow signals OptimizerStop, TooFewRealizations and ExecutorStopped are excluded too.

WorkflowError

Bases: RoptError

A workflow or runtime object was used incorrectly.

For example a compute step or evaluator used concurrently, an event handler re-entered from inside itself, or an executor asked to run work from one of its own workers.

ExecutionError

Bases: RoptError

The execution infrastructure failed at runtime.

For example an executor that cannot start, a broken process pool, a function that cannot be serialized for a worker, an HPC setup or submission problem, or an evaluation whose worker died before producing a result.

UnsupportedError

Bases: RoptError

An optional dependency is missing or a requested feature is unsupported.

For example a required extra (such as pandas or polars) is not installed, or the selected plugin does not support the requested method.

AbortedError

Bases: RoptError

Work was aborted before it could finish.

Raised by an optimization, an evaluation or a run call that was aborted: by Session.abort, by its session closing, by a failure elsewhere, or because its pool could no longer run the work. See Failures and Aborts.

Attributes:

Name Type Description
exit_code

Why the work was aborted.

__init__

__init__(exit_code: ExitCode) -> None

Initialize the error.

Parameters:

Name Type Description Default
exit_code ExitCode

Why the work was aborted.

required

OptimizerStop

Bases: Exception

Raised internally to stop an optimization with a specific exit code.

Used only within the optimizer core to unwind the backend optimization loop (for example when a function or batch budget is reached). It carries the ExitCode the optimization terminates with.

__init__

__init__(exit_code: ExitCode) -> None

Initialize the OptimizerStop exception.

Parameters:

Name Type Description Default
exit_code ExitCode

The exit code the optimization terminates with.

required

TooFewRealizations

Bases: Exception

Raised when too few realizations are available to compute a result.

A generic signal, carrying no exit code.

ExecutorStopped

Bases: Exception

Raised when the evaluation executor can no longer run the work.

A generic signal, carrying no exit code. In practice this happens at interpreter shutdown, when the worker pool is gone and a task that outlived its program is released rather than left waiting.