1515from ..util import URLError
1616from ..tasks .functions import _create_task_from_xml
1717from .._api_calls import _perform_api_call
18- from .run import OpenMLRun
18+ from .run import OpenMLRun , _get_version_information
1919
2020
2121# _get_version_info, _get_dict and _create_setup_string are in run.py to avoid
@@ -66,8 +66,10 @@ def run_task(task, model):
6666 raise ValueError ('The task has no class labels. This method currently '
6767 'only works for tasks with class labels.' )
6868
69+ run_environment = _get_version_information ()
70+ tags = ['openml-python' , run_environment [1 ]]
6971 # execute the run
70- run = OpenMLRun (task_id = task .task_id , flow_id = flow_id , dataset_id = dataset .dataset_id , model = model )
72+ run = OpenMLRun (task_id = task .task_id , flow_id = flow_id , dataset_id = dataset .dataset_id , model = model , tags = tags )
7173
7274 try :
7375 run .data_content , run .trace_content , run .trace_attributes = _run_task_get_arffcontent (model , task , class_labels )
@@ -337,27 +339,31 @@ def _create_run_from_xml(xml):
337339 evaluations = dict ()
338340 detailed_evaluations = defaultdict (lambda : defaultdict (dict ))
339341 evaluation_flows = dict ()
340- for evaluation_dict in run ['oml:output_data' ]['oml:evaluation' ]:
341- key = evaluation_dict ['oml:name' ]
342- if 'oml:value' in evaluation_dict :
343- value = float (evaluation_dict ['oml:value' ])
344- elif 'oml:array_data' in evaluation_dict :
345- value = evaluation_dict ['oml:array_data' ]
346- else :
347- raise ValueError ('Could not find keys "value" or "array_data" '
348- 'in %s' % str (evaluation_dict .keys ()))
349-
350- if '@repeat' in evaluation_dict and '@fold' in evaluation_dict :
351- repeat = int (evaluation_dict ['@repeat' ])
352- fold = int (evaluation_dict ['@fold' ])
353- repeat_dict = detailed_evaluations [key ]
354- fold_dict = repeat_dict [repeat ]
355- fold_dict [fold ] = value
356- else :
357- evaluations [key ] = value
358- evaluation_flows [key ] = flow_id
342+ if 'oml:output_data' in run and 'oml:evaluation' in run ['oml:output_data' ]:
343+ for evaluation_dict in run ['oml:output_data' ]['oml:evaluation' ]:
344+ key = evaluation_dict ['oml:name' ]
345+ if 'oml:value' in evaluation_dict :
346+ value = float (evaluation_dict ['oml:value' ])
347+ elif 'oml:array_data' in evaluation_dict :
348+ value = evaluation_dict ['oml:array_data' ]
349+ else :
350+ raise ValueError ('Could not find keys "value" or "array_data" '
351+ 'in %s' % str (evaluation_dict .keys ()))
352+
353+ if '@repeat' in evaluation_dict and '@fold' in evaluation_dict :
354+ repeat = int (evaluation_dict ['@repeat' ])
355+ fold = int (evaluation_dict ['@fold' ])
356+ repeat_dict = detailed_evaluations [key ]
357+ fold_dict = repeat_dict [repeat ]
358+ fold_dict [fold ] = value
359+ else :
360+ evaluations [key ] = value
361+ evaluation_flows [key ] = flow_id
359362
360- evaluation_flows [key ] = flow_id
363+ evaluation_flows [key ] = flow_id
364+ tags = None
365+ if 'oml:tag' in run :
366+ tags = run ['oml:tag' ]
361367
362368 return OpenMLRun (run_id = run_id , uploader = uploader ,
363369 uploader_name = uploader_name , task_id = task_id ,
@@ -368,7 +374,7 @@ def _create_run_from_xml(xml):
368374 parameter_settings = parameters ,
369375 dataset_id = dataset_id , predictions_url = predictions_url ,
370376 evaluations = evaluations ,
371- detailed_evaluations = detailed_evaluations )
377+ detailed_evaluations = detailed_evaluations , tags = tags )
372378
373379
374380def _get_cached_run (run_id ):
0 commit comments