@@ -90,7 +90,7 @@ def _get_estimation_procedure_list():
9090 procs_dict = xmltodict .parse (xml_string )
9191 # Minimalistic check if the XML is useful
9292 if "oml:estimationprocedures" not in procs_dict :
93- raise ValueError ("Error in return XML, does not contain tag " " oml:estimationprocedures." )
93+ raise ValueError ("Error in return XML, does not contain tag oml:estimationprocedures." )
9494 elif "@xmlns:oml" not in procs_dict ["oml:estimationprocedures" ]:
9595 raise ValueError (
9696 "Error in return XML, does not contain tag "
@@ -106,10 +106,19 @@ def _get_estimation_procedure_list():
106106
107107 procs = []
108108 for proc_ in procs_dict ["oml:estimationprocedures" ]["oml:estimationprocedure" ]:
109+ task_type_int = int (proc_ ["oml:ttid" ])
110+ try :
111+ task_type_id = TaskType (task_type_int )
112+ except ValueError as e :
113+ warnings .warn (
114+ f"Could not create task type id for { task_type_int } due to error { e } " ,
115+ RuntimeWarning ,
116+ )
117+ continue
109118 procs .append (
110119 {
111120 "id" : int (proc_ ["oml:id" ]),
112- "task_type_id" : TaskType ( int ( proc_ [ "oml:ttid" ])) ,
121+ "task_type_id" : task_type_id ,
113122 "name" : proc_ ["oml:name" ],
114123 "type" : proc_ ["oml:type" ],
115124 }
@@ -124,7 +133,7 @@ def list_tasks(
124133 size : Optional [int ] = None ,
125134 tag : Optional [str ] = None ,
126135 output_format : str = "dict" ,
127- ** kwargs
136+ ** kwargs ,
128137) -> Union [Dict , pd .DataFrame ]:
129138 """
130139 Return a number of tasks having the given tag and task_type
@@ -175,7 +184,7 @@ def list_tasks(
175184 offset = offset ,
176185 size = size ,
177186 tag = tag ,
178- ** kwargs
187+ ** kwargs ,
179188 )
180189
181190
@@ -240,9 +249,18 @@ def __list_tasks(api_call, output_format="dict"):
240249 tid = None
241250 try :
242251 tid = int (task_ ["oml:task_id" ])
252+ task_type_int = int (task_ ["oml:task_type_id" ])
253+ try :
254+ task_type_id = TaskType (task_type_int )
255+ except ValueError as e :
256+ warnings .warn (
257+ f"Could not create task type id for { task_type_int } due to error { e } " ,
258+ RuntimeWarning ,
259+ )
260+ continue
243261 task = {
244262 "tid" : tid ,
245- "ttid" : TaskType ( int ( task_ [ "oml: task_type_id" ])) ,
263+ "ttid" : task_type_id ,
246264 "did" : int (task_ ["oml:did" ]),
247265 "name" : task_ ["oml:name" ],
248266 "task_type" : task_ ["oml:task_type" ],
@@ -330,7 +348,10 @@ def get_task(
330348 task
331349 """
332350 if not isinstance (task_id , int ):
333- warnings .warn ("Task id must be specified as `int` from 0.14.0 onwards." , DeprecationWarning )
351+ warnings .warn (
352+ "Task id must be specified as `int` from 0.14.0 onwards." ,
353+ DeprecationWarning ,
354+ )
334355
335356 try :
336357 task_id = int (task_id )
@@ -466,9 +487,12 @@ def create_task(
466487 estimation_procedure_id : int ,
467488 target_name : Optional [str ] = None ,
468489 evaluation_measure : Optional [str ] = None ,
469- ** kwargs
490+ ** kwargs ,
470491) -> Union [
471- OpenMLClassificationTask , OpenMLRegressionTask , OpenMLLearningCurveTask , OpenMLClusteringTask
492+ OpenMLClassificationTask ,
493+ OpenMLRegressionTask ,
494+ OpenMLLearningCurveTask ,
495+ OpenMLClusteringTask ,
472496]:
473497 """Create a task based on different given attributes.
474498
@@ -519,7 +543,7 @@ def create_task(
519543 target_name = target_name ,
520544 estimation_procedure_id = estimation_procedure_id ,
521545 evaluation_measure = evaluation_measure ,
522- ** kwargs
546+ ** kwargs ,
523547 )
524548
525549
0 commit comments