Skip to content

Commit 2f334e2

Browse files
committed
MAINT split task and flow files into separate files
1 parent a001782 commit 2f334e2

6 files changed

Lines changed: 560 additions & 537 deletions

File tree

openml/flows/flow.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sklearn
44

55
from .._api_calls import _perform_api_call
6+
from .functions import _check_flow_exists
67

78

89
class OpenMLFlow(object):
@@ -121,36 +122,3 @@ def _get_name(self):
121122
return self.name
122123

123124

124-
def _check_flow_exists(name, version):
125-
"""Retrieves the flow id of the flow uniquely identified by name+version.
126-
127-
Parameter
128-
---------
129-
name : string
130-
Name of the flow
131-
version : string
132-
Version information associated with flow.
133-
134-
Returns
135-
-------
136-
flow_exist : int
137-
Flow id or -1 if the flow doesn't exist.
138-
139-
Notes
140-
-----
141-
see http://www.openml.org/api_docs/#!/flow/get_flow_exists_name_version
142-
"""
143-
if not (type(name) is str and len(name) > 0):
144-
raise ValueError('Argument \'name\' should be a non-empty string')
145-
if not (type(version) is str and len(version) > 0):
146-
raise ValueError('Argument \'version\' should be a non-empty string')
147-
148-
return_code, xml_response = _perform_api_call(
149-
"flow/exists/%s/%s" % (name, version))
150-
# TODO check with latest version of code if this raises an exception
151-
if return_code != 200:
152-
# fixme raise appropriate error
153-
raise ValueError("api call failed: %s" % xml_response)
154-
xml_dict = xmltodict.parse(xml_response)
155-
flow_id = xml_dict['oml:flow_exists']['oml:id']
156-
return return_code, xml_response, flow_id

openml/flows/functions.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import xmltodict
2+
3+
from openml._api_calls import _perform_api_call
4+
5+
6+
def _check_flow_exists(name, version):
7+
"""Retrieves the flow id of the flow uniquely identified by name+version.
8+
9+
Parameter
10+
---------
11+
name : string
12+
Name of the flow
13+
version : string
14+
Version information associated with flow.
15+
16+
Returns
17+
-------
18+
flow_exist : int
19+
Flow id or -1 if the flow doesn't exist.
20+
21+
Notes
22+
-----
23+
see http://www.openml.org/api_docs/#!/flow/get_flow_exists_name_version
24+
"""
25+
if not (type(name) is str and len(name) > 0):
26+
raise ValueError('Argument \'name\' should be a non-empty string')
27+
if not (type(version) is str and len(version) > 0):
28+
raise ValueError('Argument \'version\' should be a non-empty string')
29+
30+
return_code, xml_response = _perform_api_call(
31+
"flow/exists/%s/%s" % (name, version))
32+
# TODO check with latest version of code if this raises an exception
33+
if return_code != 200:
34+
# fixme raise appropriate error
35+
raise ValueError("api call failed: %s" % xml_response)
36+
xml_dict = xmltodict.parse(xml_response)
37+
flow_id = xml_dict['oml:flow_exists']['oml:id']
38+
return return_code, xml_response, flow_id

openml/runs/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .run import OpenMLRun
2-
from .run import (run_task, get_run, list_runs, list_runs_by_flow,
3-
list_runs_by_tag, list_runs_by_task, list_runs_by_uploader,
4-
list_runs_by_filters)
2+
from .functions import (run_task, get_run, list_runs, list_runs_by_flow,
3+
list_runs_by_tag, list_runs_by_task,
4+
list_runs_by_uploader, list_runs_by_filters)
55

66
__all__ = ['OpenMLRun', 'run_task', 'get_run', 'list_runs', 'list_runs_by_flow',
77
'list_runs_by_tag', 'list_runs_by_task', 'list_runs_by_uploader',

0 commit comments

Comments
 (0)