AnnotatedPartialOutputsError#

exception lsst.pipe.base.AnnotatedPartialOutputsError#

Bases: RepeatableQuantumError

Exception that runQuantum raises when the (partial) outputs it has written contain information about their own incompleteness or degraded quality.

Clients should construct this exception by calling annotate instead of calling the constructor directly. However, annotate does not chain the exception; this must still be done by the client.

This exception should always chain the original error. When the executor catches this exception, it will report the original exception. In contrast, other exceptions raised from runQuantum are considered to invalidate any outputs that are already written.

classmethod annotate(error: Exception, *args: GetSetDictMetadataHolder | None, log: Logger | LsstLogAdapter) AnnotatedPartialOutputsError#

Set metadata on outputs to explain the nature of the failure.

Parameters#

errorException

Exception that caused the task to fail.

*argsGetSetDictMetadataHolder

Objects (e.g. Task, Exposure, SimpleCatalog) to annotate with failure information. They must have a metadata property.

loglogging.Logger

Log to send error message to.

Returns#

errorAnnotatedPartialOutputsError

Exception that the failing task can raise from with the passed-in exception.

Notes#

This should be called from within an except block that has caught an exception. Here is an example of handling a failure in PipelineTask.runQuantum that annotates and writes partial outputs:

def runQuantum(self, butlerQC, inputRefs, outputRefs):
    inputs = butlerQC.get(inputRefs)
    exposures = inputs.pop("exposures")
    assert not inputs, "runQuantum got more inputs than expected"

    result = pipeBase.Struct(catalog=None)
    try:
        self.run(exposure)
    except pipeBase.AlgorithmError as e:
        error = pipeBase.AnnotatedPartialOutputsError.annotate(
            e, self, result.catalog, log=self.log
        )
        raise error from e
    finally:
        butlerQC.put(result, outputRefs)