Skip to content

Commit 146a42a

Browse files
committed
FIX _check_flow_exists
1 parent 815c259 commit 146a42a

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

openml/_api_calls.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .exceptions import OpenMLServerError
99

1010

11-
def _perform_api_call(call, file_dictionary=None,
11+
def _perform_api_call(call, data=None, file_dictionary=None,
1212
file_elements=None, add_authentication=True):
1313
"""
1414
Perform an API call at the OpenML server.
@@ -19,6 +19,8 @@ def _read_url(self, url, add_authentication=False, data=None, filePath=None):
1919
----------
2020
call : str
2121
The API call. For example data/list
22+
data : dict
23+
Dictionary with post-request payload.
2224
file_dictionary : dict
2325
Mapping of {filename: path} of files which should be uploaded to the
2426
server.
@@ -39,17 +41,20 @@ def _read_url(self, url, add_authentication=False, data=None, filePath=None):
3941
if not url.endswith("/"):
4042
url += "/"
4143
url += call
44+
45+
url = url.replace('=', '%3d')
46+
4247
if file_dictionary is not None or file_elements is not None:
43-
return _read_url_files(url, file_dictionary=file_dictionary,
48+
return _read_url_files(url, data=data, file_dictionary=file_dictionary,
4449
file_elements=file_elements)
45-
return _read_url(url)
50+
return _read_url(url, data)
4651

4752

48-
def _read_url_files(url, file_dictionary=None, file_elements=None):
49-
"""do a post request to url with data None, file content of
53+
def _read_url_files(url, data=None, file_dictionary=None, file_elements=None):
54+
"""do a post request to url with data, file content of
5055
file_dictionary and sending file_elements as files"""
5156

52-
data = {}
57+
data = {} if data is None else data
5358
data['api_key'] = config.apikey
5459
if file_elements is None:
5560
file_elements = {}
@@ -82,14 +87,15 @@ def _read_url_files(url, file_dictionary=None, file_elements=None):
8287
return response.status_code, response.text
8388

8489

85-
def _read_url(url):
90+
def _read_url(url, data=None):
8691

87-
data = {}
92+
data = {} if data is None else data
8893
data['api_key'] = config.apikey
8994

9095
# Using requests.post sets header 'Accept-encoding' automatically to
9196
# 'gzip,deflate'
9297
response = requests.post(url, data=data)
98+
9399
if response.status_code != 200:
94100
raise OpenMLServerError(('Status code: %d\n' % response.status_code) + response.text)
95101
if 'Content-Encoding' not in response.headers or \

openml/flows/flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def _check_flow_exists(name, version):
386386
raise ValueError('Argument \'version\' should be a non-empty string')
387387

388388
return_code, xml_response = _perform_api_call(
389-
"flow/exists/%s/%s" % (name, version))
389+
"flow/exists", data={'name': name, 'external_version': version})
390390
# TODO check with latest version of code if this raises an exception
391391
if return_code != 200:
392392
# fixme raise appropriate error

0 commit comments

Comments
 (0)