@@ -583,9 +583,6 @@ def get_run(run_id):
583583
584584 run = _create_run_from_xml (run_xml )
585585
586- with io .open (run_file , "w" , encoding = 'utf8' ) as fh :
587- fh .write (run_xml )
588-
589586 return run
590587
591588
@@ -680,10 +677,18 @@ def _create_run_from_xml(xml):
680677 'description XML' % run_id )
681678
682679 if 'predictions' not in files :
683- # JvR: actually, I am not sure whether this error should be raised.
684- # a run can consist without predictions. But for now let's keep it
685- raise ValueError ('No prediction files for run %d in run '
686- 'description XML' % run_id )
680+ task = openml .tasks .get_task (task_id )
681+ if task .task_type_id == 8 :
682+ raise NotImplementedError (
683+ 'Subgroup discovery tasks are not yet supported.'
684+ )
685+ else :
686+ # JvR: actually, I am not sure whether this error should be raised.
687+ # a run can consist without predictions. But for now let's keep it
688+ # Matthias: yes, it should stay as long as we do not really handle
689+ # this stuff
690+ raise ValueError ('No prediction files for run %d in run '
691+ 'description XML' % run_id )
687692
688693 tags = openml .utils .extract_xml_tags ('oml:tag' , run )
689694
@@ -702,14 +707,17 @@ def _create_run_from_xml(xml):
702707
703708
704709def _create_trace_from_description (xml ):
705- result_dict = xmltodict .parse (xml )['oml:trace' ]
710+ result_dict = xmltodict .parse (xml , force_list = ( 'oml:trace_iteration' ,) )['oml:trace' ]
706711
707712 run_id = result_dict ['oml:run_id' ]
708713 trace = dict ()
709714
710715 if 'oml:trace_iteration' not in result_dict :
711716 raise ValueError ('Run does not contain valid trace. ' )
712717
718+ assert type (result_dict ['oml:trace_iteration' ]) == list , \
719+ type (result_dict ['oml:trace_iteration' ])
720+
713721 for itt in result_dict ['oml:trace_iteration' ]:
714722 repeat = int (itt ['oml:repeat' ])
715723 fold = int (itt ['oml:fold' ])
@@ -857,7 +865,7 @@ def _list_runs(api_call):
857865
858866 xml_string = _perform_api_call (api_call )
859867
860- runs_dict = xmltodict .parse (xml_string )
868+ runs_dict = xmltodict .parse (xml_string , force_list = ( 'oml:run' ,) )
861869 # Minimalistic check if the XML is useful
862870 if 'oml:runs' not in runs_dict :
863871 raise ValueError ('Error in return XML, does not contain "oml:runs": %s'
@@ -872,15 +880,11 @@ def _list_runs(api_call):
872880 '"http://openml.org/openml": %s'
873881 % str (runs_dict ))
874882
875- if isinstance (runs_dict ['oml:runs' ]['oml:run' ], list ):
876- runs_list = runs_dict ['oml:runs' ]['oml:run' ]
877- elif isinstance (runs_dict ['oml:runs' ]['oml:run' ], dict ):
878- runs_list = [runs_dict ['oml:runs' ]['oml:run' ]]
879- else :
880- raise TypeError ()
883+ assert type (runs_dict ['oml:runs' ]['oml:run' ]) == list , \
884+ type (runs_dict ['oml:runs' ])
881885
882886 runs = dict ()
883- for run_ in runs_list :
887+ for run_ in runs_dict [ 'oml:runs' ][ 'oml:run' ] :
884888 run_id = int (run_ ['oml:run_id' ])
885889 run = {'run_id' : run_id ,
886890 'task_id' : int (run_ ['oml:task_id' ]),
0 commit comments