Exemplo n.º 1
0
    def test_from_function(self):
        def dummy_function(input1, input2, param1, param2):
            return input1 + input2 + [param1] + [param2]

        workflow = Workflow.from_function(dummy_function,
                                          inputs={
                                              'input1': DummyType,
                                              'input2': DummyType,
                                              'param1': Int,
                                              'param2': Int
                                          },
                                          outputs=collections.OrderedDict([
                                              ('concatenated_inputs',
                                               DummyType)
                                          ]),
                                          name='Concatenate things',
                                          doc="Let's concatenate some things!")

        expected = Workflow(signature=Signature(
            name='Concatenate things',
            inputs={
                'input1': DummyType,
                'input2': DummyType,
                'param1': Int,
                'param2': Int,
            },
            outputs=collections.OrderedDict([('concatenated_inputs', DummyType)
                                             ])),
                            template=expected_template,
                            id_='dummy_function')

        self.assertEqual(workflow, expected)
Exemplo n.º 2
0
    def test_from_function(self):
        def dummy_function(input1: list, input2: list,
                           param1: int, param2: int) -> list:
            return input1 + input2 + [param1] + [param2]

        workflow = Workflow.from_function(
            dummy_function,
            inputs={
                'input1': qiime.core.testing.TestType,
                'input2': qiime.core.testing.TestType
            },
            parameters={
                'param1': qiime.plugin.Int,
                'param2': qiime.plugin.Int
            },
            outputs=collections.OrderedDict([
                ('concatenated_inputs', qiime.core.testing.TestType)
            ]),
            name='Concatenate things',
            doc="Let's concatenate some things!"
        )

        expected = Workflow(
            signature=Signature(
                name='Concatenate things',
                inputs={
                    'input1': (qiime.core.testing.TestType, list),
                    'input2': (qiime.core.testing.TestType, list)
                },
                parameters={
                    'param1': (qiime.plugin.Int, int),
                    'param2': (qiime.plugin.Int, int)
                },
                outputs=collections.OrderedDict([
                    ('concatenated_inputs',
                     (qiime.core.testing.TestType, list))
                ])
            ),
            template=expected_template,
            id_='dummy_function'
        )
        self.assertEqual(workflow, expected)
Exemplo n.º 3
0
    def test_from_function(self):
        def dummy_function(input1, input2, param1, param2):
            return input1 + input2 + [param1] + [param2]

        workflow = Workflow.from_function(
            dummy_function,
            inputs={
                'input1': DummyType,
                'input2': DummyType,
                'param1': Int,
                'param2': Int
            },
            outputs=collections.OrderedDict([
                ('concatenated_inputs', DummyType)
            ]),
            name='Concatenate things',
            doc="Let's concatenate some things!"
        )

        expected = Workflow(
            signature=Signature(
                name='Concatenate things',
                inputs={
                    'input1': DummyType,
                    'input2': DummyType,
                    'param1': Int,
                    'param2': Int,
                },
                outputs=collections.OrderedDict([
                    ('concatenated_inputs', DummyType)
                ])
            ),
            template=expected_template,
            id_='dummy_function'
        )

        self.assertEqual(workflow, expected)
Exemplo n.º 4
0
    def setUp(self):
        # TODO standardize temporary directories created by QIIME
        self.test_dir = tempfile.TemporaryDirectory(prefix='qiime2-temp-')

        self.workflow = Workflow.from_function(
            dummy_function,
            inputs={
                'input1': DummyType,
                'input2': DummyType,
                'param1': Int,
                'param2': Int
            },
            outputs=collections.OrderedDict([
                ('concatenated_inputs', DummyType)
            ]),
            name='Concatenate things',
            doc="Let's concatenate some things!"
        )

        self.artifact_fp1 = os.path.join(self.test_dir.name, 'artifact1.qtf')
        self.artifact_fp2 = os.path.join(self.test_dir.name, 'artifact2.qtf')
        Artifact.save([-1, 42, 0, 43, 43], DummyType, None, self.artifact_fp1)
        Artifact.save([1, 2, 100], DummyType, None, self.artifact_fp2)
        self.artifact_fp3 = os.path.join(self.test_dir.name, 'artifact3.qtf')