Ejemplo n.º 1
0
    def add_step(self, pipeline):
        prev_step = pipeline.steps[-1]
        m = Method()
        m.method = m
        self.add_inputs(m, self.create_input(datatypes.STR_PK, dataset_idx=1))
        self.add_outputs(m, self.create_output(datatypes.STR_PK,
                                               dataset_idx=1))
        step = PipelineStep(pipeline=pipeline,
                            transformation=m,
                            step_num=prev_step.step_num + 1)
        pipeline.steps.add(step)

        cable = PipelineStepInputCable(
            pipelinestep=step,
            source_step=prev_step.step_num,
            source=prev_step.transformation.outputs[0],
            dest=m.inputs[0])
        cable.pipelinestepinputcable = cable
        step.cables_in.add(cable)
        outcable = PipelineOutputCable(pipeline=pipeline,
                                       output_idx=step.step_num,
                                       source_step=step.step_num,
                                       source=m.outputs[0],
                                       output_cdt=m.outputs[0].get_cdt())
        pipeline.outcables.add(outcable)

        return step
Ejemplo n.º 2
0
    def create_valid_pipeline(self):
        p = Pipeline(family=PipelineFamily())
        self.add_inputs(p, self.create_input(datatypes.STR_PK, dataset_idx=1))
        m = Method()
        m.method = m
        self.add_inputs(m, self.create_input(datatypes.STR_PK, dataset_idx=1))
        self.add_outputs(m, self.create_output(datatypes.STR_PK,
                                               dataset_idx=1))

        step1 = PipelineStep(pipeline=p, transformation=m, step_num=1)
        p.steps.add(step1)

        cable = PipelineStepInputCable(pipelinestep=step1,
                                       source_step=0,
                                       source=p.inputs.all()[0],
                                       dest=m.inputs.all()[0])
        cable.pipelinestepinputcable = cable
        step1.cables_in.add(cable)

        outcable = PipelineOutputCable(pipeline=p,
                                       output_idx=1,
                                       source_step=1,
                                       source=m.outputs.all()[0],
                                       output_cdt=m.outputs.all()[0].get_cdt())
        p.outcables.add(outcable)

        yield p
Ejemplo n.º 3
0
    def test_pipeline_oneStep_outcable_references_invalid_output_clean(self):
        """Bad output cabling, request output not belonging to requested step"""
        with self.create_valid_pipeline() as p:
            unrelated_output = self.create_output(datatypes.STR_PK,
                                                  dataset_idx=3)
            m2 = Method()
            m2.method = m2
            unrelated_output.transformation = m2
            outcable = p.outcables[0]
            outcable.source = unrelated_output

            self.assertRaisesRegexp(
                ValidationError,
                'Transformation at step 1 does not produce output ".*"',
                outcable.clean)
            self.assertRaisesRegexp(
                ValidationError,
                'Transformation at step 1 does not produce output ".*"',
                p.clean)
Ejemplo n.º 4
0
    def test_pipeline_manySteps_outcable_references_invalid_output_clean(self):
        """Bad output cabling, chained-step pipeline: request output not belonging to requested step"""
        with self.create_valid_pipeline() as p:
            self.add_step(p)

            outcable1, outcable2 = p.outcables.all()
            unrelated_output = self.create_output(datatypes.STR_PK,
                                                  dataset_idx=3)
            m3 = Method()
            m3.method = m3
            unrelated_output.transformation = m3
            outcable2.source = unrelated_output

            self.assertEquals(outcable1.clean(), None)
            self.assertRaisesRegexp(
                ValidationError,
                'Transformation at step 2 does not produce output ".*"',
                outcable2.clean)
            self.assertRaisesRegexp(
                ValidationError,
                'Transformation at step 2 does not produce output ".*"',
                p.clean)