22 """Module defining PipelineBuilder class and related methods. 25 __all__ = [
"PipelineBuilder"]
35 from .configOverrides
import ConfigOverrides
36 from .pipeline
import Pipeline, TaskDef
37 from .
import pipeTools
43 _LOG = logging.getLogger(__name__.partition(
".")[2])
51 """PipelineBuilder class is responsible for building task pipeline. 53 The class provides a set of methods to manipulate pipeline by adding, 54 deleting, re-ordering tasks in pipeline and changing their labels or 59 taskFactory : `TaskFactory` 60 Factory object used to load/instantiate PipelineTasks 61 pipeline : `Pipeline`, optional 62 Initial pipeline to be modified, if `None` then new empty pipeline 65 def __init__(self, taskFactory, pipeline=None):
72 """Return updated pipeline instance. 74 Pipeline will be checked for possible inconsistencies before 79 ordered : `bool`, optional 80 If `True` then order resulting pipeline according to Task data 90 Raised if any inconsistencies are detected in pipeline definition, 91 see `pipeTools.orderPipeline` for list of exception types. 97 return orderedPipeline
102 """Append new task to a pipeline. 107 Name of the new task, can be either full class name including 108 package and module, or just a class name to be searched in 109 known packages and modules. 110 label : `str`, optional 111 Label for new task, if `None` then task class name is used as 115 taskClass, taskName = self.
_taskFactory.loadTaskClass(taskName)
119 label = taskName.rpartition(
'.')[2]
120 if self.
_pipeline.labelIndex(label) >= 0:
121 raise LookupError(
"Task label (or name) is not unique: " + label)
124 config = taskClass.ConfigClass()
127 taskClass=taskClass, label=label))
130 """Remove task from a pipeline. 135 Label of the task to remove. 139 raise LookupError(
"Task label is not found: " + label)
143 """Move task to a new position in a pipeline. 148 Label of the task to move. 154 raise LookupError(
"Task label is not found: " + label)
158 """Change task label. 163 Existing label of the task. 165 New label of the task. 169 raise LookupError(
"Task label is not found: " + label)
171 if newLabel != label
and self.
_pipeline.labelIndex(newLabel) >= 0:
172 raise LookupError(
"New task label is not unique: " + label)
176 """Apply single config override. 183 String in the form ``"param=value"`` or ``"parm.subpar=value"``, 184 ``value`` can be a Python constant or a list of constants. 188 raise LookupError(
"Task label is not found: " + label)
189 key, sep, val = value.partition(
'=')
191 overrides.addValueOverride(key, val)
192 overrides.applyTo(self.
_pipeline[idx].config)
195 """Apply overrides from file. 202 Path to file with overrides. 206 raise LookupError(
"Task label is not found: " + label)
208 overrides.addFileOverride(path)
209 overrides.applyTo(self.
_pipeline[idx].config)
212 """Apply name string formatting to config file. 219 A python dict used in formatting nameTemplates. 223 raise LookupError(
"Task label is not found: " + label)
226 overrides.addDatasetNameSubstitution(value)
227 overrides.applyTo(self.
_pipeline[idx].config)
def configOverride(self, label, value)
def pipeline(self, ordered=False)
def addTask(self, taskName, label=None)
def deleteTask(self, label)
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
def __init__(self, taskFactory, pipeline=None)
def labelTask(self, label, newLabel)
def substituteDatatypeNames(self, label, value)
def configOverrideFile(self, label, path)
def moveTask(self, label, newIndex)