|
3 | 3 | from .._api_calls import _perform_api_call |
4 | 4 | from ..evaluations import OpenMLEvaluation |
5 | 5 |
|
6 | | -def list_evaluations(function, task_id): |
| 6 | +def list_runs(function, offset=None, size=None, id=None, task=None, setup=None, |
| 7 | + flow=None, uploader=None, tag=None): |
| 8 | + """List all run-evaluation pairs matching all of the given filters. |
| 9 | +
|
| 10 | + Perform API call `/evaluation/function{function}/{filters} |
| 11 | + |
| 12 | + Parameters |
| 13 | + ---------- |
| 14 | + function : str |
| 15 | + the evaluation function. e.g., predictive_accuracy |
| 16 | + offset : int, optional |
| 17 | + the number of runs to skip, starting from the first |
| 18 | + size : int, optional |
| 19 | + the maximum number of runs to show |
| 20 | +
|
| 21 | + id : list, optional |
| 22 | +
|
| 23 | + task : list, optional |
| 24 | +
|
| 25 | + setup: list, optional |
| 26 | +
|
| 27 | + flow : list, optional |
| 28 | +
|
| 29 | + uploader : list, optional |
| 30 | +
|
| 31 | + tag : str, optional |
| 32 | +
|
| 33 | + Returns |
| 34 | + ------- |
| 35 | + list |
| 36 | + List of found evaluations. |
| 37 | + """ |
| 38 | + |
| 39 | + api_call = "evaluation/list/function/%s" %function |
| 40 | + if offset is not None: |
| 41 | + api_call += "/offset/%d" % int(offset) |
| 42 | + if size is not None: |
| 43 | + api_call += "/limit/%d" % int(size) |
| 44 | + if id is not None: |
| 45 | + api_call += "/run/%s" % ','.join([str(int(i)) for i in id]) |
| 46 | + if task is not None: |
| 47 | + api_call += "/task/%s" % ','.join([str(int(i)) for i in task]) |
| 48 | + if setup is not None: |
| 49 | + api_call += "/setup/%s" % ','.join([str(int(i)) for i in setup]) |
| 50 | + if flow is not None: |
| 51 | + api_call += "/flow/%s" % ','.join([str(int(i)) for i in flow]) |
| 52 | + if uploader is not None: |
| 53 | + api_call += "/uploader/%s" % ','.join([str(int(i)) for i in uploader]) |
| 54 | + if tag is not None: |
| 55 | + api_call += "/tag/%s" % tag |
| 56 | + |
| 57 | + return _list_evaluations(api_call) |
| 58 | + |
| 59 | + |
| 60 | +def _list_evaluations(api_call): |
7 | 61 | """Helper function to parse API calls which are lists of runs""" |
8 | 62 |
|
9 | | - xml_string = _perform_api_call("evaluation/list/function/%s/task/%d" %(function, task_id)) |
| 63 | + xml_string = _perform_api_call(api_call) |
10 | 64 |
|
11 | 65 | evals_dict = xmltodict.parse(xml_string) |
12 | 66 | # Minimalistic check if the XML is useful |
|
0 commit comments