SimplePipelineExecutor¶
-
class
lsst.ctrl.mpexec.SimplePipelineExecutor(quantum_graph: lsst.pipe.base.graph.graph.QuantumGraph, butler: lsst.daf.butler._butler.Butler)¶ Bases:
objectA simple, high-level executor for pipelines.
Parameters: - quantum_graph :
QuantumGraph Graph to be executed.
- butler :
Butler Object that manages all I/O. Must be initialized with
collectionsandrunproperties that correspond to the input and output collections, which must be consistent with those used to createquantum_graph.
Notes
Most callers should use one of the
classmethodfactory functions (from_pipeline_filename,from_task_class,from_pipeline) instead of invoking the constructor directly; these guarantee that theButlerandQuantumGraphare created consistently.This class is intended primarily to support unit testing and small-scale integration testing of
PipelineTaskclasses. It deliberately lacks many features present in the command-line-onlypipetasktool in order to keep the implementation simple. Python callers that need more sophistication should call lower-level tools likeGraphBuilder,PreExecInit, andSingleQuantumExecutordirectly.Methods Summary
as_generator(register_dataset_types)Yield quanta in the QuantumGraphin topological order.from_pipeline(pipeline, …)Create an executor by building a QuantumGraph from an in-memory pipeline. from_pipeline_filename(pipeline_filename, *, …)Create an executor by building a QuantumGraph from an on-disk pipeline YAML file. from_task_class(task_class, config, …)Create an executor by building a QuantumGraph from a pipeline containing a single task. prep_butler(root, inputs, output, …)Helper method for creating Butlerinstances with collections appropriate for processing.run(register_dataset_types)Run all the quanta in the QuantumGraphin topological order.Methods Documentation
-
as_generator(register_dataset_types: bool = False) → Iterator[lsst.daf.butler.core.quantum.Quantum]¶ Yield quanta in the
QuantumGraphin topological order.These quanta will be run as the returned generator is iterated over. Use this method to run the quanta one at a time. Use
runto run all quanta in the graph.Parameters: Returns: - quanta :
Iterator[Quantum] Executed quanta. At present, these will contain only unresolved
DatasetRefinstances 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 outputDatasetRefobjects.
Notes
Global initialization steps (see
PreExecInit) are performed immediately when this method is called, but individual quanta are not actually executed until the returned iterator is iterated over.A topological ordering is not in general unique, but no other guarantees are made about the order in which quanta are processed.
- quanta :
-
classmethod
from_pipeline(pipeline: Union[lsst.pipe.base.pipeline.Pipeline, Iterable[lsst.pipe.base.pipeline.TaskDef]], *, where: str = '', butler: lsst.daf.butler._butler.Butler, **kwargs) → lsst.ctrl.mpexec.simple_pipeline_executor.SimplePipelineExecutor¶ Create an executor by building a QuantumGraph from an in-memory pipeline.
Parameters: - pipeline :
PipelineorIterable[TaskDef] A Python object describing the tasks to run, along with their labels and configuration.
- where :
str, optional Data ID query expression that constraints the quanta generated.
- butler :
Butler Butler that manages all I/O.
prep_butlercan be used to create one.
Returns: - executor :
SimplePipelineExecutor An executor instance containing the constructed
QuantumGraphandButler, ready forrunto be called.
- pipeline :
-
classmethod
from_pipeline_filename(pipeline_filename: str, *, where: str = '', butler: lsst.daf.butler._butler.Butler) → lsst.ctrl.mpexec.simple_pipeline_executor.SimplePipelineExecutor¶ Create an executor by building a QuantumGraph from an on-disk pipeline YAML file.
Parameters: - pipeline_filename :
str Name of the YAML file to load the pipeline definition from.
- where :
str, optional Data ID query expression that constraints the quanta generated.
- butler :
Butler Butler that manages all I/O.
prep_butlercan be used to create one.
Returns: - executor :
SimplePipelineExecutor An executor instance containing the constructed
QuantumGraphandButler, ready forrunto be called.
- pipeline_filename :
-
classmethod
from_task_class(task_class: Type[lsst.pipe.base.pipelineTask.PipelineTask], config: Optional[lsst.pex.config.config.Config, None] = None, label: Optional[str, None] = None, *, where: str = '', butler: lsst.daf.butler._butler.Butler) → lsst.ctrl.mpexec.simple_pipeline_executor.SimplePipelineExecutor¶ Create an executor by building a QuantumGraph from a pipeline containing a single task.
Parameters: - task_class :
type A concrete
PipelineTasksubclass.- config :
Config, optional Configuration for the task. If not provided, task-level defaults will be used (no per-instrument overrides).
- label :
str, optional Label for the task in its pipeline; defaults to
task_class._DefaultName.- where :
str, optional Data ID query expression that constraints the quanta generated.
- butler :
Butler Butler that manages all I/O.
prep_butlercan be used to create one.
Returns: - executor :
SimplePipelineExecutor An executor instance containing the constructed
QuantumGraphandButler, ready forrunto be called.
- task_class :
-
classmethod
prep_butler(root: str, inputs: Iterable[str], output: str, output_run: Optional[str, None] = None) → lsst.daf.butler._butler.Butler¶ Helper method for creating
Butlerinstances with collections appropriate for processing.Parameters: - root :
str Root of the butler data repository; must already exist, with all necessary input data.
- inputs :
Iterable[str] Collections to search for all input datasets, in search order.
- output :
str Name of a new output
CHAINEDcollection to create that will combine both inputs and outputs.- output_run :
str, optional Name of the output
RUNthat will directly hold all output datasets. If not provided, a name will be created fromoutputand a timestamp.
Returns: - butler :
Butler Butler client instance compatible with all
classmethodfactories. Always writeable.
- root :
-
run(register_dataset_types: bool = False) → List[lsst.daf.butler.core.quantum.Quantum]¶ Run all the quanta in the
QuantumGraphin topological order.Use this method to run all quanta in the graph. Use
as_generatorto get a generator to run the quanta one at a time.Parameters: Returns: - quanta :
List[Quantum] Executed quanta. At present, these will contain only unresolved
DatasetRefinstances 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 outputDatasetRefobjects.
Notes
A topological ordering is not in general unique, but no other guarantees are made about the order in which quanta are processed.
- quanta :
- quantum_graph :