|
3 | 3 | import sklearn |
4 | 4 |
|
5 | 5 | from .._api_calls import _perform_api_call |
| 6 | +from .. import config |
6 | 7 |
|
7 | 8 |
|
8 | 9 | class OpenMLFlow(object): |
@@ -50,10 +51,16 @@ def _generate_flow_xml(self): |
50 | 51 | Flow represented as XML string. |
51 | 52 | """ |
52 | 53 | model = self.model |
| 54 | + |
| 55 | + if config._testmode: |
| 56 | + flow_name = '%s%s' % (config.testsentinel, self.name) |
| 57 | + else: |
| 58 | + flow_name = self.name |
| 59 | + |
53 | 60 | flow_dict = OrderedDict() |
54 | 61 | flow_dict['oml:flow'] = OrderedDict() |
55 | 62 | flow_dict['oml:flow']['@xmlns:oml'] = 'http://openml.org/openml' |
56 | | - flow_dict['oml:flow']['oml:name'] = self.name |
| 63 | + flow_dict['oml:flow']['oml:name'] = flow_name |
57 | 64 | flow_dict['oml:flow']['oml:external_version'] = self.external_version |
58 | 65 | flow_dict['oml:flow']['oml:description'] = self.description |
59 | 66 |
|
@@ -136,6 +143,12 @@ def _check_flow_exists(name, version): |
136 | 143 | if not (type(version) is str and len(version) > 0): |
137 | 144 | raise ValueError('Argument \'version\' should be a non-empty string') |
138 | 145 |
|
| 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 | + |
139 | 152 | return_code, xml_response = _perform_api_call( |
140 | 153 | "flow/exists/%s/%s" % (name, version)) |
141 | 154 | # TODO check with latest version of code if this raises an exception |
|
0 commit comments