Skip to content

Commit 23687ba

Browse files
authored
Merge branch 'develop' into joaquinvanschoren-patch-1
2 parents 19223f9 + 3b37dfc commit 23687ba

4 files changed

Lines changed: 30 additions & 10 deletions

File tree

openml/_api_calls.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,16 @@ def _read_url_files(url, data=None, file_dictionary=None, file_elements=None):
104104
def _read_url(url, data=None):
105105

106106
data = {} if data is None else data
107-
data['api_key'] = config.apikey
108-
109-
# Using requests.post sets header 'Accept-encoding' automatically to
110-
# 'gzip,deflate'
111-
response = requests.post(url, data=data)
107+
if config.apikey is not None:
108+
data['api_key'] = config.apikey
109+
110+
if len(data) == 0 or (len(data) == 1 and 'api_key' in data):
111+
# do a GET
112+
response = requests.get(url, params=data)
113+
else: # an actual post request
114+
# Using requests.post sets header 'Accept-encoding' automatically to
115+
# 'gzip,deflate'
116+
response = requests.post(url, data=data)
112117

113118
if response.status_code != 200:
114119
raise _parse_server_exception(response)

openml/flows/sklearn_converter.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,13 @@ def check(param_dict, disallow_parameter=False):
586586
elif isinstance(model, sklearn.model_selection.RandomizedSearchCV):
587587
param_distributions = model.param_distributions
588588
else:
589+
if hasattr(model, 'param_distributions'):
590+
param_distributions = model.param_distributions
591+
else:
592+
raise AttributeError('Using subclass BaseSearchCV other than {GridSearchCV, RandomizedSearchCV}. Could not find attribute param_distributions. ')
589593
print('Warning! Using subclass BaseSearchCV other than ' \
590594
'{GridSearchCV, RandomizedSearchCV}. Should implement param check. ')
591-
pass
592-
595+
593596
if not check(param_distributions, True):
594597
raise PyOpenMLError('openml-python should not be used to '
595598
'optimize the n_jobs parameter.')

openml/study/functions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ def _multitag_to_list(result_dict, tag):
1212
raise TypeError()
1313

1414

15-
def get_study(study_id):
15+
def get_study(study_id, type=None):
1616
'''
1717
Retrieves all relevant information of an OpenML study from the server
1818
Note that some of the (data, tasks, flows, setups) fields can be empty
1919
(depending on information on the server)
2020
'''
21-
xml_string = _perform_api_call("study/%d" %(study_id))
21+
call_suffix = "study/%s" %str(study_id)
22+
if type is not None:
23+
call_suffix += "/" + type
24+
xml_string = _perform_api_call(call_suffix)
2225
result_dict = xmltodict.parse(xml_string)['oml:study']
2326
id = int(result_dict['oml:id'])
2427
name = result_dict['oml:name']

tests/test_study/test_study_functions.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ def test_get_study(self):
1313
self.assertEquals(len(study.data), 105)
1414
self.assertEquals(len(study.tasks), 105)
1515
self.assertEquals(len(study.flows), 27)
16-
self.assertEquals(len(study.setups), 30)
16+
self.assertEquals(len(study.setups), 30)
17+
18+
def test_get_tasks(self):
19+
study_id = 14
20+
21+
study = openml.study.get_study(study_id, 'tasks')
22+
self.assertEquals(study.data, None)
23+
self.assertGreater(len(study.tasks), 0)
24+
self.assertEquals(study.flows, None)
25+
self.assertEquals(study.setups, None)

0 commit comments

Comments
 (0)