|
1 | 1 | from collections import defaultdict |
2 | 2 | import io |
| 3 | +import json |
3 | 4 | import os |
4 | | -import xmltodict |
5 | | -import numpy as np |
| 5 | +import sys |
| 6 | +import time |
6 | 7 | import warnings |
| 8 | + |
| 9 | +import numpy as np |
7 | 10 | import sklearn |
8 | | -import time |
9 | 11 | import six |
10 | | -import json |
| 12 | +import xmltodict |
11 | 13 |
|
12 | 14 | from ..exceptions import PyOpenMLError |
13 | 15 | from .. import config |
14 | | - |
15 | 16 | from ..flows import sklearn_to_flow, get_flow, flow_exists, _check_n_jobs |
16 | 17 | from ..setups import setup_exists, initialize_model |
17 | | - |
18 | 18 | from ..exceptions import OpenMLCacheException, OpenMLServerException |
19 | | -from ..util import URLError, version_complies |
20 | 19 | from .._api_calls import _perform_api_call, _file_id_to_url |
21 | 20 | from .run import OpenMLRun, _get_version_information |
22 | 21 | from .trace import OpenMLRunTrace, OpenMLTraceIteration |
|
26 | 25 | # circular imports |
27 | 26 |
|
28 | 27 |
|
29 | | - |
30 | 28 | def run_task(task, model, avoid_duplicate_runs=True, flow_tags=None, seed=None): |
31 | 29 | """Performs a CV run on the dataset of the given task, using the split. |
32 | 30 |
|
@@ -296,7 +294,7 @@ def _run_task_get_arffcontent(model, task, class_labels): |
296 | 294 | user_defined_measures = defaultdict(lambda: defaultdict(dict)) |
297 | 295 |
|
298 | 296 | rep_no = 0 |
299 | | - can_measure_runtime = version_complies(3, 3) and _check_n_jobs(model) |
| 297 | + can_measure_runtime = sys.version_info[:2] >= (3, 3) and _check_n_jobs(model) |
300 | 298 | # TODO use different iterator to only provide a single iterator (less |
301 | 299 | # methods, less maintenance, less confusion) |
302 | 300 | for rep in task.iterate_repeats(): |
@@ -447,14 +445,9 @@ def get_run(run_id): |
447 | 445 |
|
448 | 446 | try: |
449 | 447 | return _get_cached_run(run_id) |
450 | | - except (OpenMLCacheException): |
451 | | - try: |
452 | | - run_xml = _perform_api_call("run/%d" % run_id) |
453 | | - except (URLError, UnicodeEncodeError) as e: |
454 | | - # TODO logger.debug |
455 | | - print(e) |
456 | | - raise e |
457 | 448 |
|
| 449 | + except (OpenMLCacheException): |
| 450 | + run_xml = _perform_api_call("run/%d" % run_id) |
458 | 451 | with io.open(run_file, "w", encoding='utf8') as fh: |
459 | 452 | fh.write(run_xml) |
460 | 453 |
|
|
0 commit comments