def testSerialization(self): pipeline = Pipeline("test") pipeline.addTask(AddTask, "add") pipeline.addTask(MultTask, "mult") dump = str(pipeline) load = Pipeline.fromString(dump) self.assertEqual(pipeline, load)
def _makePipeline(tasks): """Generate Pipeline instance. Parameters ---------- tasks : list of tuples Each tuple in the list has 3 or 4 items: - input DatasetType name(s), string or tuple of strings - output DatasetType name(s), string or tuple of strings - task label, string - optional task class object, can be None Returns ------- Pipeline instance """ pipe = Pipeline("test pipeline") for task in tasks: inputs = task[0] outputs = task[1] label = task[2] klass = task[3] if len(task) > 3 else ExamplePipelineTask pipe.addTask(klass, label) _makeConfig(inputs, outputs, pipe, label) return list(pipe.toExpandedPipeline())
def testInitial(self): """Testing constructor with initial data """ pipeline = Pipeline("test") pipeline.addTask(AddTask, "add") pipeline.addTask(MultTask, "mult") self.assertEqual(len(pipeline), 2) expandedPipeline = list(pipeline.toExpandedPipeline()) self.assertEqual(expandedPipeline[0].taskName, "AddTask") self.assertEqual(expandedPipeline[1].taskName, "MultTask")
def makePipeline(self, args): """Build a pipeline from command line arguments. Parameters ---------- args : `argparse.Namespace` Parsed command line Returns ------- pipeline : `~lsst.pipe.base.Pipeline` """ if args.pipeline: pipeline = Pipeline.fromFile(args.pipeline) else: pipeline = Pipeline("anonymous") # loop over all pipeline actions and apply them in order for action in args.pipeline_actions: if action.action == "add_instrument": pipeline.addInstrument(action.value) elif action.action == "new_task": pipeline.addTask(action.value, action.label) elif action.action == "delete_task": pipeline.removeTask(action.label) elif action.action == "config": # action value string is "field=value", split it at '=' field, _, value = action.value.partition("=") pipeline.addConfigOverride(action.label, field, value) elif action.action == "configfile": pipeline.addConfigFile(action.label, action.value) else: raise ValueError(f"Unexpected pipeline action: {action.action}") if args.save_pipeline: pipeline.toFile(args.save_pipeline) if args.pipeline_dot: pipeline2dot(pipeline, args.pipeline_dot) return pipeline