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. 94 taskDef.connections = taskDef.config.connections.ConnectionsClass(config=taskDef.config)
100 return orderedPipeline
105 """Append new task to a pipeline. 110 Name of the new task, can be either full class name including 111 package and module, or just a class name to be searched in 112 known packages and modules. 113 label : `str`, optional 114 Label for new task, if `None` then task class name is used as 118 taskClass, taskName = self.
_taskFactory.loadTaskClass(taskName)
122 label = taskName.rpartition(
'.')[2]
123 if self.
_pipeline.labelIndex(label) >= 0:
124 raise LookupError(
"Task label (or name) is not unique: " + label)
127 config = taskClass.ConfigClass()
130 taskClass=taskClass, label=label))
133 """Remove task from a pipeline. 138 Label of the task to remove. 142 raise LookupError(
"Task label is not found: " + label)
146 """Move task to a new position in a pipeline. 151 Label of the task to move. 157 raise LookupError(
"Task label is not found: " + label)
161 """Change task label. 166 Existing label of the task. 168 New label of the task. 172 raise LookupError(
"Task label is not found: " + label)
174 if newLabel != label
and self.
_pipeline.labelIndex(newLabel) >= 0:
175 raise LookupError(
"New task label is not unique: " + label)
179 """Apply single config override. 186 String in the form ``"param=value"`` or ``"parm.subpar=value"``, 187 ``value`` can be a Python constant or a list of constants. 191 raise LookupError(
"Task label is not found: " + label)
192 key, sep, val = value.partition(
'=')
194 overrides.addValueOverride(key, val)
195 overrides.applyTo(self.
_pipeline[idx].config)
198 """Apply overrides from file. 205 Path to file with overrides. 209 raise LookupError(
"Task label is not found: " + label)
211 overrides.addFileOverride(path)
212 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)
def __init__(self, taskFactory, pipeline=None)
def labelTask(self, label, newLabel)
def configOverrideFile(self, label, path)
def moveTask(self, label, newIndex)