Beispiel #1
0
    def test_get_outputs_invalid(self):
        pipeline = MLPipeline(['a_primitive'])

        pipeline.blocks['a_primitive#1'].produce_output = [{
            'name': 'output',
            'type': 'whatever'
        }]

        with pytest.raises(ValueError):
            pipeline.get_outputs('a_primitive#1.invalid')
Beispiel #2
0
    def test_get_outputs_str_named(self):
        outputs = {
            'default': [
                {
                    'name': 'a_name',
                    'variable': 'a_variable',
                    'type': 'a_type',
                }
            ],
            'debug': [
                {
                    'name': 'another_name',
                    'variable': 'another_variable',
                }
            ]
        }
        pipeline = MLPipeline(['a_primitive', 'another_primitive'], outputs=outputs)

        returned = pipeline.get_outputs('debug')

        expected = [
            {
                'name': 'another_name',
                'variable': 'another_variable',
            }
        ]
        assert returned == expected
    def test_get_outputs_int(self):
        pipeline = MLPipeline(['a_primitive', 'another_primitive'])

        returned = pipeline.get_outputs(-1)

        expected = [{
            'name': 'another_primitive#1',
            'variable': 'another_primitive#1',
        }]
        assert returned == expected
    def test_get_outputs_invalid(self, mlblock_mock):
        outputs = {
            'default': [
                {
                    'name': 'a_name',
                    'variable': 'a_variable',
                    'type': 'a_type',
                }
            ],
            'debug': [
                {
                    'name': 'another_name',
                    'variable': 'another_variable',
                }
            ]
        }
        mlblock_mock.side_effect = [MagicMock(), MagicMock()]
        pipeline = MLPipeline(['a_primitive', 'another_primitive'], outputs=outputs)

        pipeline.blocks['a_primitive#1'].produce_output = [
            {
                'name': 'output',
                'type': 'whatever'
            }
        ]
        pipeline.blocks['another_primitive#1'].produce_output = [
            {
                'name': 'something',
            }
        ]

        returned = pipeline.get_outputs(['default', 'debug', -1, 'a_primitive#1.output'])

        expected = [
            {
                'name': 'a_name',
                'variable': 'a_variable',
                'type': 'a_type'
            },
            {
                'name': 'another_name',
                'variable': 'another_variable',
            },
            {
                'name': 'something',
                'variable': 'another_primitive#1.something',
            },
            {
                'name': 'output',
                'type': 'whatever',
                'variable': 'a_primitive#1.output'
            }
        ]

        assert returned == expected
Beispiel #5
0
    def test_get_outputs_combination(self):
        outputs = {
            'default': [
                {
                    'name': 'a_name',
                    'variable': 'a_variable',
                    'type': 'a_type',
                }
            ],
            'debug': [
                {
                    'name': 'another_name',
                    'variable': 'another_variable',
                }
            ]
        }
        pipeline = MLPipeline(['a_primitive', 'another_primitive'], outputs=outputs)

        pipeline.blocks['a_primitive#1'].produce_output = [
            {
                'name': 'output',
                'type': 'whatever'
            }
        ]
        pipeline.blocks['another_primitive#1'].produce_output = [
            {
                'name': 'something',
            }
        ]

        returned = pipeline.get_outputs(['default', 'debug', -1, 'a_primitive#1.output'])

        expected = [
            {
                'name': 'a_name',
                'variable': 'a_variable',
                'type': 'a_type'
            },
            {
                'name': 'another_name',
                'variable': 'another_variable',
            },
            {
                'name': 'another_primitive#1',
                'variable': 'another_primitive#1',
            },
            {
                'name': 'output',
                'type': 'whatever',
                'variable': 'a_primitive#1.output'
            }
        ]

        assert returned == expected
    def test_get_outputs_str_variable(self):
        pipeline = MLPipeline(['a_primitive', 'another_primitive'])
        pipeline.blocks['a_primitive#1'].produce_output = [{
            'name': 'output',
            'type': 'whatever'
        }]

        returned = pipeline.get_outputs('a_primitive#1.output')

        expected = [{
            'name': 'output',
            'type': 'whatever',
            'variable': 'a_primitive#1.output'
        }]
        assert returned == expected