@@ -52,15 +52,10 @@ def _generate_flow_xml(self):
5252 """
5353 model = self .model
5454
55- if config ._testmode :
56- flow_name = '%s%s' % (config .testsentinel , self .name )
57- else :
58- flow_name = self .name
59-
6055 flow_dict = OrderedDict ()
6156 flow_dict ['oml:flow' ] = OrderedDict ()
6257 flow_dict ['oml:flow' ]['@xmlns:oml' ] = 'http://openml.org/openml'
63- flow_dict ['oml:flow' ]['oml:name' ] = flow_name
58+ flow_dict ['oml:flow' ]['oml:name' ] = self . _get_name ()
6459 flow_dict ['oml:flow' ]['oml:external_version' ] = self .external_version
6560 flow_dict ['oml:flow' ]['oml:description' ] = self .description
6661
@@ -106,7 +101,7 @@ def _ensure_flow_exists(self):
106101 """
107102 import sklearn
108103 flow_version = 'sklearn_' + sklearn .__version__
109- _ , _ , flow_id = _check_flow_exists (self .name , flow_version )
104+ _ , _ , flow_id = _check_flow_exists (self ._get_name () , flow_version )
110105 # TODO add numpy and scipy version!
111106
112107 if int (flow_id ) == - 1 :
@@ -118,6 +113,10 @@ def _ensure_flow_exists(self):
118113
119114 return int (flow_id )
120115
116+ def _get_name (self ):
117+ """Helper function. Can be mocked for testing."""
118+ return self .name
119+
121120
122121def _check_flow_exists (name , version ):
123122 """Retrieves the flow id of the flow uniquely identified by name+version.
@@ -143,12 +142,6 @@ def _check_flow_exists(name, version):
143142 if not (type (version ) is str and len (version ) > 0 ):
144143 raise ValueError ('Argument \' version\' should be a non-empty string' )
145144
146- if config ._testmode :
147- # It could already be in the name, for example when checking if a
148- # downloaded flow exists on the server
149- if config .testsentinel not in name :
150- name = '%s%s' % (config .testsentinel , name )
151-
152145 return_code , xml_response = _perform_api_call (
153146 "flow/exists/%s/%s" % (name , version ))
154147 # TODO check with latest version of code if this raises an exception
0 commit comments