@@ -106,6 +106,24 @@ def list_tasks_by_type(task_type_id):
106106 return _list_tasks ("task/list/type/%d" % task_type_id )
107107
108108
109+ def list_tasks_by_tag (tag ):
110+ """Return all tasks having the given tag
111+
112+ Parameters
113+ ----------
114+ tag : str
115+
116+ Returns
117+ -------
118+ list
119+ A list of all tasks having a give tag. Every task is represented by
120+ a dictionary containing the following information: task id,
121+ dataset id, task_type and status. If qualities are calculated for
122+ the associated dataset, some of these are also returned.
123+ """
124+ return _list_tasks ("task/list/tag/%s" % tag )
125+
126+
109127def list_tasks ():
110128 """Return a list of all tasks which are on OpenML.
111129
@@ -124,9 +142,18 @@ def _list_tasks(api_call):
124142 return_code , xml_string = _perform_api_call (api_call )
125143 tasks_dict = xmltodict .parse (xml_string )
126144 # Minimalistic check if the XML is useful
127- assert tasks_dict ['oml:tasks' ]['@xmlns:oml' ] == \
128- 'http://openml.org/openml'
129- assert type (tasks_dict ['oml:tasks' ]['oml:task' ]) == list
145+ if 'oml:tasks' not in tasks_dict :
146+ raise ValueError ('Error in return XML, does not contain "oml:runs": %s'
147+ % str (tasks_dict ))
148+ elif '@xmlns:oml' not in tasks_dict ['oml:tasks' ]:
149+ raise ValueError ('Error in return XML, does not contain '
150+ '"oml:runs"/@xmlns:oml: %s'
151+ % str (tasks_dict ))
152+ elif tasks_dict ['oml:tasks' ]['@xmlns:oml' ] != 'http://openml.org/openml' :
153+ raise ValueError ('Error in return XML, value of '
154+ '"oml:runs"/@xmlns:oml is not '
155+ '"http://openml.org/openml": %s'
156+ % str (tasks_dict ))
130157
131158 tasks = []
132159 procs = get_estimation_procedure_list ()
0 commit comments