SingleQuantumExecutor

class lsst.ctrl.mpexec.SingleQuantumExecutor(butler: lsst.daf.butler._butler.Butler | None[lsst.daf.butler._butler.Butler, None], taskFactory: lsst.pipe.base.taskFactory.TaskFactory, skipExistingIn: list[str] | None[list, None] = None, clobberOutputs: bool = False, enableLsstDebug: bool = False, exitOnKnownError: bool = False, mock: bool = False, mock_configs: list[lsst.ctrl.mpexec.cli.utils._PipelineAction] | None[list, None] = None, butler_config: lsst.daf.butler.core.config.Config | str | None[lsst.daf.butler.core.config.Config, str, None] = None, universe: lsst.daf.butler.core.dimensions._universe.DimensionUniverse | None[lsst.daf.butler.core.dimensions._universe.DimensionUniverse, None] = None)

Bases: lsst.ctrl.mpexec.QuantumExecutor

Executor class which runs one Quantum at a time.

Parameters:
butler : Butler or None

Data butler, None means that Quantum-backed butler should be used instead.

taskFactory : TaskFactory

Instance of a task factory.

skipExistingIn : list [ str ], optional

Accepts list of collections, if all Quantum outputs already exist in the specified list of collections then that Quantum will not be rerun.

clobberOutputs : bool, optional

If True, then existing outputs in output run collection will be overwritten. If skipExistingIn is defined, only outputs from failed quanta will be overwritten. Only used when butler is not None.

enableLsstDebug : bool, optional

Enable debugging with lsstDebug facility for a task.

exitOnKnownError : bool, optional

If True, call sys.exit with the appropriate exit code for special known exceptions, after printing a traceback, instead of letting the exception propagate up to calling. This is always the behavior for InvalidQuantumError.

mock : bool, optional

If True then mock task execution.

mock_configs : list [ _PipelineAction ], optional

Optional config overrides for mock tasks.

Methods Summary

checkExistingOutputs(quantum, taskDef, …) Decide whether this quantum needs to be executed.
execute(taskDef, quantum) Execute single quantum.
getReport() Return execution report from last call to execute.
initGlobals(quantum) Initialize global state needed for task execution.
runQuantum(task, quantum, taskDef, …) Execute task on a single quantum.
updatedQuantumInputs(quantum, taskDef, …) Update quantum with extra information, returns a new updated Quantum.
writeMetadata(quantum, metadata, taskDef, …)

Methods Documentation

checkExistingOutputs(quantum: lsst.daf.butler.core.quantum.Quantum, taskDef: lsst.pipe.base.pipeline.TaskDef, limited_butler: lsst.daf.butler._limited_butler.LimitedButler) → bool

Decide whether this quantum needs to be executed.

If only partial outputs exist then they are removed if clobberOutputs is True, otherwise an exception is raised.

Parameters:
quantum : Quantum

Quantum to check for existing outputs

taskDef : TaskDef

Task definition structure.

Returns:
exist : bool

True if self.skipExistingIn is defined, and a previous execution of this quanta appears to have completed successfully (either because metadata was written or all datasets were written). False otherwise.

Raises:
RuntimeError

Raised if some outputs exist and some not.

execute(taskDef: lsst.pipe.base.pipeline.TaskDef, quantum: lsst.daf.butler.core.quantum.Quantum) → lsst.daf.butler.core.quantum.Quantum

Execute single quantum.

Parameters:
taskDef : TaskDef

Task definition structure.

quantum : Quantum

Quantum for this execution.

Returns:
quantum : Quantum

The quantum actually executed. At present this quantum will contain only unresolved DatasetRef instances for output datasets, reflecting the state of the quantum just before it was run (but after any adjustments for predicted but now missing inputs). This may change in the future to include resolved output DatasetRef objects.

Notes

Any exception raised by the task or code that wraps task execution is propagated to the caller of this method.

getReport() → Optional[lsst.ctrl.mpexec.reports.QuantumReport, None]

Return execution report from last call to execute.

Returns:
report : QuantumReport

Structure describing the status of the execution of a quantum. None is returned if implementation does not support this feature.

Raises:
RuntimeError

Raised if this method is called before execute.

initGlobals(quantum: lsst.daf.butler.core.quantum.Quantum) → None

Initialize global state needed for task execution.

Parameters:
quantum : Quantum

Single Quantum instance.

Notes

There is an issue with initializing filters singleton which is done by instrument, to avoid requiring tasks to do it in runQuantum() we do it here when any dataId has an instrument dimension. Also for now we only allow single instrument, verify that all instrument names in all dataIds are identical.

This will need revision when filter singleton disappears.

runQuantum(task: lsst.pipe.base.pipelineTask.PipelineTask, quantum: lsst.daf.butler.core.quantum.Quantum, taskDef: lsst.pipe.base.pipeline.TaskDef, limited_butler: lsst.daf.butler._limited_butler.LimitedButler) → None

Execute task on a single quantum.

Parameters:
task : PipelineTask

Task object.

quantum : Quantum

Single Quantum instance.

taskDef : TaskDef

Task definition structure.

updatedQuantumInputs(quantum: lsst.daf.butler.core.quantum.Quantum, taskDef: lsst.pipe.base.pipeline.TaskDef, limited_butler: lsst.daf.butler._limited_butler.LimitedButler) → lsst.daf.butler.core.quantum.Quantum

Update quantum with extra information, returns a new updated Quantum.

Some methods may require input DatasetRefs to have non-None dataset_id, but in case of intermediate dataset it may not be filled during QuantumGraph construction. This method will retrieve missing info from registry.

Parameters:
quantum : Quantum

Single Quantum instance.

taskDef : TaskDef

Task definition structure.

Returns:
update : Quantum

Updated Quantum instance

writeMetadata(quantum: lsst.daf.butler.core.quantum.Quantum, metadata: Any, taskDef: lsst.pipe.base.pipeline.TaskDef, limited_butler: lsst.daf.butler._limited_butler.LimitedButler) → None