Skip to content

Commit 57a2b3d

Browse files
authored
Merge branch 'develop' into fix373
2 parents 215f892 + a1e9368 commit 57a2b3d

14 files changed

Lines changed: 61 additions & 10 deletions

File tree

openml/_api_calls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def _parse_server_exception(response, url=None):
139139
additional = None
140140
if 'oml:additional_information' in server_exception['oml:error']:
141141
additional = server_exception['oml:error']['oml:additional_information']
142-
if code in [370, 372, 512, 500, 482]:
143-
# 512 for runs, 370 for datasets (should be 372), 500 for flows
144-
# 482 for tasks
142+
if code in [372, 512, 500, 482, 542, 674]: # datasets,
143+
# 512 for runs, 372 for datasets, 500 for flows
144+
# 482 for tasks, 542 for evaluations, 674 for setups
145145
return OpenMLServerNoResult(code, message, additional)
146146
return OpenMLServerException(
147147
code=code,

openml/datasets/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _list_datasets(api_call):
189189
try:
190190
xml_string = _perform_api_call(api_call)
191191
except OpenMLServerNoResult:
192-
return []
192+
return dict()
193193
datasets_dict = xmltodict.parse(xml_string, force_list=('oml:dataset',))
194194

195195
# Minimalistic check if the XML is useful

openml/evaluations/functions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import xmltodict
22

3+
from openml.exceptions import OpenMLServerNoResult
34
from .._api_calls import _perform_api_call
45
from ..evaluations import OpenMLEvaluation
56

@@ -59,8 +60,10 @@ def list_evaluations(function, offset=None, size=None, id=None, task=None,
5960

6061
def _list_evaluations(api_call):
6162
"""Helper function to parse API calls which are lists of runs"""
62-
63-
xml_string = _perform_api_call(api_call)
63+
try:
64+
xml_string = _perform_api_call(api_call)
65+
except OpenMLServerNoResult:
66+
return dict()
6467

6568
evals_dict = xmltodict.parse(xml_string, force_list=('oml:evaluation',))
6669
# Minimalistic check if the XML is useful

openml/flows/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _list_flows(api_call):
112112
try:
113113
xml_string = _perform_api_call(api_call)
114114
except OpenMLServerNoResult:
115-
return []
115+
return dict()
116116
flows_dict = xmltodict.parse(xml_string, force_list=('oml:flow',))
117117

118118
# Minimalistic check if the XML is useful

openml/runs/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def _list_runs(api_call):
953953
try:
954954
xml_string = _perform_api_call(api_call)
955955
except OpenMLServerNoResult:
956-
return []
956+
return dict()
957957

958958
runs_dict = xmltodict.parse(xml_string, force_list=('oml:run',))
959959
# Minimalistic check if the XML is useful

openml/setups/functions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .. import config
99
from .setup import OpenMLSetup, OpenMLParameter
1010
from openml.flows import flow_exists
11+
from openml.exceptions import OpenMLServerNoResult
1112

1213

1314
def setup_exists(flow, model=None):
@@ -145,7 +146,10 @@ def list_setups(flow=None, tag=None, setup=None, offset=None, size=None):
145146
def _list_setups(api_call):
146147
"""Helper function to parse API calls which are lists of setups"""
147148

148-
xml_string = openml._api_calls._perform_api_call(api_call)
149+
try:
150+
xml_string = openml._api_calls._perform_api_call(api_call)
151+
except OpenMLServerNoResult:
152+
return dict()
149153

150154
setups_dict = xmltodict.parse(xml_string, force_list=('oml:setup',))
151155
# Minimalistic check if the XML is useful

openml/study/functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from openml.study import OpenMLStudy
44
from .._api_calls import _perform_api_call
55

6+
67
def _multitag_to_list(result_dict, tag):
78
if isinstance(result_dict[tag], list):
89
return result_dict[tag]

openml/tasks/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def _list_tasks(api_call):
141141
try:
142142
xml_string = _perform_api_call(api_call)
143143
except OpenMLServerNoResult:
144-
return []
144+
return dict()
145145
tasks_dict = xmltodict.parse(xml_string, force_list=('oml:task','oml:input'))
146146
# Minimalistic check if the XML is useful
147147
if 'oml:tasks' not in tasks_dict:

tests/test_datasets/test_dataset_functions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ def test_list_datasets_paginate(self):
147147
for did in datasets:
148148
self._check_dataset(datasets[did])
149149

150+
def test_list_datasets_empty(self):
151+
datasets = openml.datasets.list_datasets(tag='NoOneWouldUseThisTagAnyway')
152+
if len(datasets) > 0:
153+
raise ValueError('UnitTest Outdated, tag was already used (please remove)')
154+
155+
self.assertIsInstance(datasets, dict)
156+
157+
150158
@unittest.skip('See https://github.com/openml/openml-python/issues/149')
151159
def test_check_datasets_active(self):
152160
active = openml.datasets.check_datasets_active([1, 17])

tests/test_evaluations/test_evaluation_functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ def test_evaluation_list_limit(self):
6363

6464
evaluations = openml.evaluations.list_evaluations("predictive_accuracy", size=100, offset=100)
6565
self.assertEquals(len(evaluations), 100)
66+
67+
def test_list_evaluations_empty(self):
68+
evaluations = openml.evaluations.list_evaluations('unexisting_measure')
69+
if len(evaluations) > 0:
70+
raise ValueError('UnitTest Outdated, got somehow results')
71+
72+
self.assertIsInstance(evaluations, dict)

0 commit comments

Comments
 (0)