|
8 | 8 |
|
9 | 9 | from ..exceptions import PyOpenMLError |
10 | 10 | from .. import config |
11 | | -from ..flows import sklearn_to_flow, get_flow |
| 11 | +from ..flows import sklearn_to_flow, get_flow, flow_exists |
12 | 12 | from ..flows.sklearn_converter import get_traceble_model |
13 | 13 | from ..setups import setup_exists |
14 | 14 | from ..exceptions import OpenMLCacheException, OpenMLServerException |
@@ -67,14 +67,23 @@ def run_task(task, model, avoid_duplicate_runs=True): |
67 | 67 |
|
68 | 68 | # execute the run |
69 | 69 | run = OpenMLRun(task_id=task.task_id, flow_id=None, dataset_id=dataset.dataset_id, model=model) |
70 | | - run.data_content, run.trace_content = _run_task_get_arffcontent(model, task, class_labels) |
71 | | - |
72 | 70 | try: |
73 | 71 | run.data_content, run.trace_content, run.trace_attributes = _run_task_get_arffcontent(model, task, class_labels) |
74 | 72 | except PyOpenMLError as message: |
75 | 73 | run.error_message = str(message) |
76 | 74 | warnings.warn("Run terminated with error: %s" %run.error_message) |
77 | 75 |
|
| 76 | + if flow_id == False: |
| 77 | + # means the flow did not exists. As we could run it, publish it now |
| 78 | + flow = flow.publish() |
| 79 | + else: |
| 80 | + # flow already existed, download it from server |
| 81 | + # TODO (neccessary? is this a post condition of this function) |
| 82 | + flow = get_flow(flow_id) |
| 83 | + |
| 84 | + run.flow_id = flow.flow_id |
| 85 | + config.logger.info('Executed Task %d with Flow id: %d' % (task.task_id, run.flow_id)) |
| 86 | + |
78 | 87 | return run |
79 | 88 |
|
80 | 89 | def _run_exists(task_id, setup_id): |
|
0 commit comments