From f5289fb9e820ecead85dd6aef63e877e88dea3a6 Mon Sep 17 00:00:00 2001 From: Matthias Feurer Date: Mon, 9 Oct 2017 18:26:33 +0200 Subject: [PATCH] Add unit test for loading non-sklearn flows, fixes #218 --- openml/runs/functions.py | 16 ++++++++++++---- tests/test_flows/test_flow.py | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/openml/runs/functions.py b/openml/runs/functions.py index 3e12362f5d..cdaf26f3a1 100644 --- a/openml/runs/functions.py +++ b/openml/runs/functions.py @@ -677,10 +677,18 @@ def _create_run_from_xml(xml): 'description XML' % run_id) if 'predictions' not in files: - # JvR: actually, I am not sure whether this error should be raised. - # a run can consist without predictions. But for now let's keep it - raise ValueError('No prediction files for run %d in run ' - 'description XML' % run_id) + task = openml.tasks.get_task(task_id) + if task.task_type_id == 8: + raise NotImplementedError( + 'Subgroup discovery tasks are not yet supported.' + ) + else: + # JvR: actually, I am not sure whether this error should be raised. + # a run can consist without predictions. But for now let's keep it + # Matthias: yes, it should stay as long as we do not really handle + # this stuff + raise ValueError('No prediction files for run %d in run ' + 'description XML' % run_id) tags = openml.utils.extract_xml_tags('oml:tag', run) diff --git a/tests/test_flows/test_flow.py b/tests/test_flows/test_flow.py index 2bbc84b22c..303d890c6c 100644 --- a/tests/test_flows/test_flow.py +++ b/tests/test_flows/test_flow.py @@ -348,3 +348,29 @@ def test_extract_tags(self): flow_dict = xmltodict.parse(flow_xml) tags = openml.utils.extract_xml_tags('oml:tag', flow_dict['oml:flow']) self.assertEqual(tags, ['OpenmlWeka', 'weka']) + + def test_download_non_scikit_learn_flows(self): + openml.config.server = self.production_server + + flow = openml.flows.get_flow(6742) + self.assertIsInstance(flow, openml.OpenMLFlow) + self.assertEqual(flow.flow_id, 6742) + self.assertEqual(len(flow.parameters), 19) + self.assertEqual(len(flow.components), 1) + self.assertIsNone(flow.model) + + subflow_1 = list(flow.components.values())[0] + self.assertIsInstance(subflow_1, openml.OpenMLFlow) + self.assertEqual(subflow_1.flow_id, 6743) + self.assertEqual(len(subflow_1.parameters), 8) + self.assertEqual(subflow_1.parameters['U'], '0') + self.assertEqual(len(subflow_1.components), 1) + self.assertIsNone(subflow_1.model) + + subflow_2 = list(subflow_1.components.values())[0] + self.assertIsInstance(subflow_2, openml.OpenMLFlow) + self.assertEqual(subflow_2.flow_id, 5888) + self.assertEqual(len(subflow_2.parameters), 4) + self.assertIsNone(subflow_2.parameters['batch-size']) + self.assertEqual(len(subflow_2.components), 0) + self.assertIsNone(subflow_2.model)