Beispiel #1
0
    def test_publish_flow(self):
        flow = openml.OpenMLFlow(
            name="sklearn.dummy.DummyClassifier",
            class_name="sklearn.dummy.DummyClassifier",
            description="test description",
            model=sklearn.dummy.DummyClassifier(),
            components=collections.OrderedDict(),
            parameters=collections.OrderedDict(),
            parameters_meta_info=collections.OrderedDict(),
            external_version=self.extension._format_external_version(
                "sklearn",
                sklearn.__version__,
            ),
            tags=[],
            language="English",
            dependencies=None,
        )

        flow, _ = self._add_sentinel_to_flow_name(flow, None)

        flow.publish()
        TestBase._mark_entity_for_removal("flow", (flow.flow_id, flow.name))
        TestBase.logger.info("collected from {}: {}".format(
            __file__.split("/")[-1], flow.flow_id))
        self.assertIsInstance(flow.flow_id, int)
Beispiel #2
0
    def test_upload_flow(self, name_mock):
        flow = openml.OpenMLFlow(model=DummyClassifier(),
                                 description="test description")

        # Create a unique prefix for the flow. Necessary because the flow is
        # identified by its name and external version online. Having a unique
        #  name allows us to publish the same flow in each test run
        md5 = hashlib.md5()
        md5.update(str(time.time()).encode('utf-8'))
        sentinel = md5.hexdigest()[:10]
        name_mock.return_value = '%s%s' % (sentinel, flow.name)

        flow.publish()
        self.assertIsInstance(flow.flow_id, int)
Beispiel #3
0
    def test_ensure_flow_exists(self):
        sentinel = get_sentinel()

        flow = openml.OpenMLFlow(name='Test',
                                 description="test description",
                                 model=sklearn.dummy.DummyClassifier(),
                                 components=collections.OrderedDict(),
                                 parameters=collections.OrderedDict(),
                                 parameters_meta_info=collections.OrderedDict(),
                                 external_version=_format_external_version(
                                     'sklearn', sklearn.__version__),
                                 tags=[],
                                 language='English',
                                 dependencies='')
        flow.name = 'TEST%s%s' % (sentinel, flow.name)
        flow_id = flow._ensure_flow_exists()
        self.assertIsInstance(flow_id, int)
        self.assertEqual(flow._ensure_flow_exists(), flow_id)
Beispiel #4
0
    def test_publish_flow(self):
        flow = openml.OpenMLFlow(name='sklearn.dummy.DummyClassifier',
                                 class_name='sklearn.dummy.DummyClassifier',
                                 description="test description",
                                 model=sklearn.dummy.DummyClassifier(),
                                 components=collections.OrderedDict(),
                                 parameters=collections.OrderedDict(),
                                 parameters_meta_info=collections.OrderedDict(),
                                 external_version=_format_external_version(
                                     'sklearn', sklearn.__version__),
                                 tags=[],
                                 language='English',
                                 dependencies=None)

        flow, _ = self._add_sentinel_to_flow_name(flow, None)

        flow.publish()
        self.assertIsInstance(flow.flow_id, int)