PipelineIR¶
- class lsst.pipe.base.pipelineIR.PipelineIR(loaded_yaml: dict[str, Any])¶
Bases:
object
Intermediate representation of a pipeline definition
- Parameters:
- loaded_yaml
dict
A dictionary which matches the structure that would be produced by a yaml reader which parses a pipeline definition document
- loaded_yaml
- Raises:
- ValueError
Raised if:
a pipeline is declared without a description;
no tasks are declared in a pipeline, and no pipelines are to be inherited;
more than one instrument is specified;
more than one inherited pipeline share a label.
Methods Summary
from_string
(pipeline_string)Create a
PipelineIR
object from a string formatted like a pipeline documentfrom_uri
(uri)Create a
PipelineIR
object from the document specified by the input uri.merge_pipelines
(pipelines)Merge one or more other
PipelineIR
objects into this object.subset_from_labels
(labelSpecifier[, subsetCtrl])Subset a pipelineIR to contain only labels specified in labelSpecifier.
Convert to a representation used in yaml serialization
write_to_uri
(uri)Serialize this
PipelineIR
object into a yaml formatted string and write the output to a file at the specified uri.Methods Documentation
- classmethod from_string(pipeline_string: str) PipelineIR ¶
Create a
PipelineIR
object from a string formatted like a pipeline document- Parameters:
- pipeline_string
str
A string that is formatted according like a pipeline document
- pipeline_string
- classmethod from_uri(uri: str | ParseResult | ResourcePath | Path) PipelineIR ¶
Create a
PipelineIR
object from the document specified by the input uri.- Parameters:
- uri: convertible to `~lsst.resources.ResourcePath`
Location of document to use in creating a
PipelineIR
object.
- Returns:
- pipelineIR
PipelineIR
The loaded pipeline
- pipelineIR
- merge_pipelines(pipelines: Iterable[PipelineIR]) None ¶
Merge one or more other
PipelineIR
objects into this object.- Parameters:
- pipelines
Iterable
ofPipelineIR
objects An
Iterable
that contains one or morePipelineIR
objects to merge into this object.
- pipelines
- Raises:
- ValueError
Raised if there is a conflict in instrument specifications. Raised if a task label appears in more than one of the input
PipelineIR
objects which are to be merged. Raised if a labeled subset appears in more than one of the inputPipelineIR
objects which are to be merged, and with any subset existing in this object.
- subset_from_labels(labelSpecifier: set[str], subsetCtrl: PipelineSubsetCtrl = PipelineSubsetCtrl.DROP) PipelineIR ¶
Subset a pipelineIR to contain only labels specified in labelSpecifier.
- Parameters:
- labelSpecifier
set
ofstr
Set containing labels that describes how to subset a pipeline.
- subsetCtrl
PipelineSubsetCtrl
Control object which decides how subsets with missing labels are handled. Setting to
PipelineSubsetCtrl.DROP
(the default) will cause any subsets that have labels which are not in the set of all task labels to be dropped. Setting toPipelineSubsetCtrl.EDIT
will cause the subset to instead be edited to remove the nonexistent label.
- labelSpecifier
- Returns:
- pipeline
PipelineIR
A new pipelineIR object that is a subset of the old pipelineIR
- pipeline
- Raises:
- ValueError
Raised if there is an issue with specified labels
Notes
This method attempts to prune any contracts that contain labels which are not in the declared subset of labels. This pruning is done using a string based matching due to the nature of contracts and may prune more than it should.
- to_primitives() dict[str, Any] ¶
Convert to a representation used in yaml serialization
- Returns:
- primitives
dict
dictionary that maps directly to the serialized YAML form.
- primitives
- write_to_uri(uri: str | ParseResult | ResourcePath | Path) None ¶
Serialize this
PipelineIR
object into a yaml formatted string and write the output to a file at the specified uri.- Parameters:
- uri: convertible to `~lsst.resources.ResourcePath`
Location of document to write a
PipelineIR
object.