66
77
88class OpenMLFlow (object ):
9+ """OpenML Flow. Stores machine learning models.
10+
11+ Parameters
12+ ----------
13+ model : scikit-learn compatible model
14+ The model the flow consists of. The model needs to have fit and predict methods.
15+ description : string
16+ Description of the flow (free text).
17+ creator : string
18+ FIXME
19+ contributor : string
20+ FIXME
21+ tag : string
22+ FIXME
23+ id : int, optional
24+ Flow ID. Assigned by the server (fixme shouldn't be here?)
25+ uploader : string, optional
26+ User uploading the model (fixme shouldn't be here?). Assigned by the server.
27+
28+
29+ """
930 def __init__ (self , model , id = None , uploader = None ,
1031 description = 'Flow generated by run_task' , creator = None ,
1132 contributor = None , tag = None ):
@@ -20,7 +41,14 @@ def __init__(self, model, id=None, uploader=None,
2041 model .__class__ .__name__ )
2142 self .external_version = 'Tsklearn_' + sklearn .__version__
2243
23- def generate_flow_xml (self ):
44+ def _generate_flow_xml (self ):
45+ """Generate xml representation of self for upload to server.
46+
47+ Returns
48+ -------
49+ flow_xml : string
50+ Flow represented as XML string.
51+ """
2452 model = self .model
2553 flow_dict = OrderedDict ()
2654 flow_dict ['oml:flow' ] = OrderedDict ()
@@ -53,18 +81,22 @@ def publish(self):
5381
5482 (optional) file_path is the absolute path to the file that is the flow (eg. a script)
5583 """
56- xml_description = self .generate_flow_xml ()
84+ xml_description = self ._generate_flow_xml ()
5785 data = {'description' : xml_description , 'source' : self .source }
5886 return_code , return_value = _perform_api_call (
5987 "/flow/" , data = data )
6088 return return_code , return_value
6189
62- def ensure_flow_exists (self ):
63- """
64- First checks if a flow exists for the given model.
65- If it does, then it will return the corresponding flow id.
66- If it does not, then it will create a flow, and return the flow id
67- of the newly created flow.
90+ def _ensure_flow_exists (self ):
91+ """ Checks if a flow exists for the given model and possibly creates it.
92+
93+ If the given flow exists on the server, the flow-id will simply
94+ be returned. Otherwise it will be uploaded to the server.
95+
96+ Returns
97+ -------
98+ flow_id : int
99+ Flow id on the server.
68100 """
69101 import sklearn
70102 flow_version = 'Tsklearn_' + sklearn .__version__
@@ -83,9 +115,21 @@ def ensure_flow_exists(self):
83115def _check_flow_exists (name , version ):
84116 """Retrieves the flow id of the flow uniquely identified by name+version.
85117
86- Returns flow id if such a flow exists,
87- returns -1 if flow does not exists,
88- http://www.openml.org/api_docs/#!/flow/get_flow_exists_name_version
118+ Parameter
119+ ---------
120+ name : string
121+ Name of the flow
122+ version : string
123+ Version information associated with flow.
124+
125+ Returns
126+ -------
127+ flow_exist : int
128+ Flow id or -1 if the flow doesn't exist.
129+
130+ Notes
131+ -----
132+ see http://www.openml.org/api_docs/#!/flow/get_flow_exists_name_version
89133 """
90134 if not (type (name ) is str and len (name ) > 0 ):
91135 raise ValueError ('Parameter \' name\' should be a non-empty string' )
0 commit comments