@@ -89,131 +89,58 @@ def _get_estimation_procedure_list():
8989 return procs
9090
9191
92- def list_tasks_by_type (task_type_id ):
93- """Return a list of all tasks for a given tasks type which are on OpenML.
92+ def list_tasks (task_type_id = None , offset = None , size = None , tag = None ):
93+ """Return a number of tasks having the given tag and task_type_id
9494
9595 Parameters
9696 ----------
9797 task_type_id : int
9898 ID of the task type as detailed
9999 `here <http://www.openml.org/search?type=task_type>`_.
100-
101- Returns
102- -------
103- list
104- A list of all tasks of the given task type. Every task is represented by
105- a dictionary containing the following information: task id,
106- dataset id, task_type and status. If qualities are calculated for
107- the associated dataset, some of these are also returned.
108- """
109- try :
110- task_type_id = int (task_type_id )
111- except :
112- raise ValueError ("Task Type ID is neither an Integer nor can be "
113- "cast to an Integer." )
114- return _list_tasks ("task/list/type/%d" % task_type_id )
115-
116-
117- def list_tasks_paginate (offset ,size ):
118- """Return a partial list (of given size) tasks for a given tasks type, starting with offset.
119-
120- Parameters
121- ----------
122100 offset : int
123101 the number of tasks to skip, starting from the first
124102 size : int
125103 the maximum number of tasks to show
126-
127- Returns
128- -------
129- list
130- A partial list of tasks of the task type. Every task is represented by a
131- dictionary containing the following information: task id,
132- dataset id, task_type and status. If qualities are calculated for
133- the associated dataset, some of these are also returned.
134- """
135- try :
136- offset = int (offset )
137- except :
138- raise ValueError ("Offset is neither an Integer nor can be "
139- "cast to an Integer." )
140- try :
141- size = int (size )
142- except :
143- raise ValueError ("Size is neither an Integer nor can be "
144- "cast to an Integer." )
145- return _list_tasks ("task/list/offset/%d/limit/%d" % (offset , size ))
146-
147-
148- def list_tasks_by_type_paginate (task_type_id ,offset ,size ):
149- """Return a partial list (of given size) tasks, starting with offset.
150-
151- Parameters
152- ----------
153- task_type_id : int
154- ID of the task type as detailed
155- `here <http://www.openml.org/search?type=task_type>`_.
156- offset : int
157- the number of tasks to skip, starting from the first
158- size : int
159- the maximum number of tasks to show
160-
161- Returns
162- -------
163- list
164- A partial list of tasks. Every task is represented by a
165- dictionary containing the following information: task id,
166- dataset id, task_type and status. If qualities are calculated for
167- the associated dataset, some of these are also returned.
168- """
169- try :
170- task_type_id = int (task_type_id )
171- except :
172- raise ValueError ("Task Type ID is neither an Integer nor can be "
173- "cast to an Integer." )
174- try :
175- offset = int (offset )
176- except :
177- raise ValueError ("Offset is neither an Integer nor can be "
178- "cast to an Integer." )
179- try :
180- size = int (size )
181- except :
182- raise ValueError ("Size is neither an Integer nor can be "
183- "cast to an Integer." )
184- return _list_tasks ("task/list/type/%d/offset/%d/limit/%d" % (task_type_id ,offset , size ))
185-
186-
187- def list_tasks_by_tag (tag ):
188- """Return all tasks having the given tag
189-
190- Parameters
191- ----------
192104 tag : str
105+ the tag to include
193106
194107 Returns
195108 -------
196109 list
197- A list of all tasks having a give tag. Every task is represented by
198- a dictionary containing the following information: task id,
199- dataset id, task_type and status. If qualities are calculated for
200- the associated dataset, some of these are also returned.
110+ A list of all tasks having the given task_type_id and the give tag.
111+ Every task is represented by a dictionary containing the following
112+ information: task id, dataset id, task_type and status. If qualities
113+ are calculated for the associated dataset, some of these are also
114+ returned.
201115 """
202- return _list_tasks ("task/list/tag/%s" % tag )
203-
116+ api_call = "task/list"
117+ if task_type_id is not None :
118+ try :
119+ task_type_id = int (task_type_id )
120+ api_call += "/task_type_id/%d" % task_type_id
121+ except :
122+ raise ValueError ("Task_type_id is neither an Integer nor can be "
123+ "cast to an Integer." )
204124
205- def list_tasks ():
206- """Return a list of all tasks which are on OpenML.
125+ if offset is not None :
126+ try :
127+ offset = int (offset )
128+ api_call += "/offset/%d" % offset
129+ except :
130+ raise ValueError ("Offset is neither an Integer nor can be "
131+ "cast to an Integer." )
207132
208- Returns
209- -------
210- list
211- A list of all tasks. Every task is represented by a
212- dictionary containing the following information: task id,
213- dataset id, task_type and status. If qualities are calculated for
214- the associated dataset, some of these are also returned.
215- """
216- return _list_tasks ('task/list' )
133+ if size is not None :
134+ try :
135+ size = int (size )
136+ api_call += "/limit/%d" % size
137+ except :
138+ raise ValueError ("Size is neither an Integer nor can be "
139+ "cast to an Integer." )
140+ if tag is not None :
141+ api_call += "/tag/%s" % tag
142+
143+ return _list_tasks (api_call )
217144
218145
219146def _list_tasks (api_call ):
0 commit comments