99
1010import openml
1111from openml ._api .resources .base import ResourceV1API , ResourceV2API , RunAPI
12- from openml .exceptions import OpenMLNotSupportedError
1312from openml .tasks .task import TaskType
1413
1514if TYPE_CHECKING :
@@ -52,7 +51,7 @@ def get(
5251 xml_content = response .text
5352 return openml .runs .functions ._create_run_from_xml (xml_content )
5453
55- def list ( # type: ignore[valid-type] # noqa: PLR0913, C901, PLR0912
54+ def list ( # type: ignore[valid-type] # noqa: PLR0913
5655 self ,
5756 limit : int ,
5857 offset : int ,
@@ -105,6 +104,37 @@ def list( # type: ignore[valid-type] # noqa: PLR0913, C901, PLR0912
105104 ValueError
106105 If the server response is invalid or malformed.
107106 """
107+ path = self ._build_url (
108+ limit = limit ,
109+ offset = offset ,
110+ ids = ids ,
111+ task = task ,
112+ setup = setup ,
113+ flow = flow ,
114+ uploader = uploader ,
115+ study = study ,
116+ tag = tag ,
117+ display_errors = display_errors ,
118+ task_type = task_type ,
119+ )
120+ xml_string = self ._http .get (path , use_api_key = True ).text
121+ return self ._parse_list_xml (xml_string )
122+
123+ def _build_url ( # noqa: PLR0913, C901
124+ self ,
125+ limit : int ,
126+ offset : int ,
127+ * ,
128+ ids : builtins .list [int ] | None = None ,
129+ task : builtins .list [int ] | None = None ,
130+ setup : builtins .list [int ] | None = None ,
131+ flow : builtins .list [int ] | None = None ,
132+ uploader : builtins .list [int ] | None = None ,
133+ study : int | None = None ,
134+ tag : str | None = None ,
135+ display_errors : bool = False ,
136+ task_type : TaskType | int | None = None ,
137+ ) -> str :
108138 path = "run/list"
109139 if limit is not None :
110140 path += f"/limit/{ limit } "
@@ -129,8 +159,9 @@ def list( # type: ignore[valid-type] # noqa: PLR0913, C901, PLR0912
129159 if task_type is not None :
130160 tvalue = task_type .value if isinstance (task_type , TaskType ) else task_type
131161 path += f"/task_type/{ tvalue } "
162+ return path
132163
133- xml_string = self . _http . get ( path , use_api_key = True ). text
164+ def _parse_list_xml ( self , xml_string : str ) -> pd . DataFrame :
134165 runs_dict = xmltodict .parse (xml_string , force_list = ("oml:run" ,))
135166 # Minimalistic check if the XML is useful
136167 if "oml:runs" not in runs_dict :
@@ -211,7 +242,7 @@ def get(
211242 OpenMLNotSupportedError
212243 V2 server API not yet available for this operation.
213244 """
214- raise OpenMLNotSupportedError ( "not implemented yet on V2 server " )
245+ self . _not_supported ( method = "get " )
215246
216247 def list ( # type: ignore[valid-type] # noqa: PLR0913
217248 self ,
@@ -235,7 +266,7 @@ def list( # type: ignore[valid-type] # noqa: PLR0913
235266 OpenMLNotSupportedError
236267 V2 server API not yet available for this operation.
237268 """
238- raise OpenMLNotSupportedError ( "not implemented yet on V2 server " )
269+ self . _not_supported ( method = "list " )
239270
240271 def publish (self , path : str , files : Mapping [str , Any ] | None = None ) -> int : # noqa: ARG002
241272 """Publish a run on the V2 server.
@@ -258,4 +289,4 @@ def publish(self, path: str, files: Mapping[str, Any] | None = None) -> int: #
258289 V2 server does not yet support POST /runs/ endpoint.
259290 Expected availability: Q2 2025
260291 """
261- raise OpenMLNotSupportedError ( "not implemented yet on V2 server " )
292+ self . _not_supported ( method = "publish " )
0 commit comments