How to use the mlblocks.discovery.load_primitive function in mlblocks

To help you get started, we’ve selected a few mlblocks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDI-Project / MLBlocks / tests / test_discovery.py View on Github external
def test__load_primitive_value_error(load_mock, gpp_mock):
    load_mock.return_value = None
    gpp_mock.return_value = ['a', 'b']

    with pytest.raises(ValueError):
        discovery.load_primitive('invalid.primitive')

    load_mock.assert_called_once_with('invalid.primitive', ['a', 'b'])
github HDI-Project / MLBlocks / tests / test_discovery.py View on Github external
def test__load_primitive_success(load_mock, gpp_mock):
    gpp_mock.return_value = ['a', 'b']

    primitive = discovery.load_primitive('valid.primitive')

    load_mock.assert_called_once_with('valid.primitive', ['a', 'b'])

    assert primitive == load_mock.return_value
github HDI-Project / MLBlocks / mlblocks / mlblock.py View on Github external
def __init__(self, primitive, **kwargs):
        if isinstance(primitive, str):
            primitive = load_primitive(primitive)

        self.metadata = primitive
        self.name = primitive['name']

        self.primitive = import_object(self.metadata['primitive'])

        self._fit = self.metadata.get('fit', dict())
        self.fit_args = self._fit.get('args', [])
        self.fit_method = self._fit.get('method')

        self._produce = self.metadata['produce']
        self.produce_args = self._produce['args']
        self.produce_output = self._produce['output']
        self.produce_method = self._produce.get('method')

        self._class = bool(self.produce_method)