Skip to content

Commit 496ac32

Browse files
satvshrgeetu040PGijsbersmfeurerpre-commit-ci[bot]
authored
[ENH] V1 → V2 API Migration - Tasks (#1611)
#### Metadata * Reference Issue: stacks on #1576, fixes #1621 * New Tests Added: No * Documentation Updated: No --------- Co-authored-by: geetu040 <raoarmaghanshakir040@gmail.com> Co-authored-by: PGijsbers <p.gijsbers@tue.nl> Co-authored-by: Matthias Feurer <lists@matthiasfeurer.de> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Franz Király <fkiraly@gcos.ai>
1 parent f4fd28e commit 496ac32

18 files changed

Lines changed: 881 additions & 456 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ tests/files/org/openml/test/datasets/1/
2424
tests/files/org/openml/test/datasets/2/features.xml.pkl
2525
tests/files/org/openml/test/datasets/2/qualities.xml.pkl
2626
tests/files/org/openml/test/locks/
27-
tests/files/org/openml/test/tasks/1/datasplits.pkl.py3
28-
tests/files/org/openml/test/tasks/1882/datasplits.pkl.py3
27+
tests/files/org/openml/test/api_splits/get/1/Task_1_splits.arff/body.pkl.py3
28+
tests/files/org/openml/test/api_splits/get/1882/Task_1882_splits.arff/body.pkl.py3
2929

3030
# Distribution / packaging
3131

‎openml/_api/resources/base/resources.py‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
from openml.datasets.data_feature import OpenMLDataFeature
1818
from openml.datasets.dataset import OpenMLDataset
1919
from openml.estimation_procedures import OpenMLEstimationProcedure
20-
from openml.evaluations import OpenMLEvaluation
20+
from openml.evaluations.evaluation import OpenMLEvaluation
2121
from openml.flows.flow import OpenMLFlow
2222
from openml.runs.run import OpenMLRun
2323
from openml.setups.setup import OpenMLSetup
24-
from openml.tasks.task import TaskType
24+
from openml.tasks.task import OpenMLTask, TaskType
2525

2626

2727
class DatasetAPI(ResourceAPI):
@@ -146,6 +146,51 @@ class TaskAPI(ResourceAPI):
146146

147147
resource_type: ResourceType = ResourceType.TASK
148148

149+
@abstractmethod
150+
def get(
151+
self,
152+
task_id: int,
153+
) -> OpenMLTask:
154+
"""
155+
API v1:
156+
GET /task/{task_id}
157+
158+
API v2:
159+
GET /tasks/{task_id}
160+
"""
161+
...
162+
163+
@abstractmethod
164+
def download_split(self, url: str, *, refresh_cache: bool = False) -> Path:
165+
"""Download a task's split file and return its path in the cache."""
166+
...
167+
168+
# Task listing (V1 only)
169+
@abstractmethod
170+
def list(
171+
self,
172+
limit: int,
173+
offset: int,
174+
task_type: TaskType | int | None = None,
175+
*,
176+
estimation_procedures: builtins.list[dict[str, Any]],
177+
**kwargs: Any,
178+
) -> pd.DataFrame:
179+
"""
180+
List tasks with filters.
181+
182+
API v1:
183+
GET /task/list
184+
185+
API v2:
186+
Not available.
187+
188+
Returns
189+
-------
190+
pandas.DataFrame
191+
"""
192+
...
193+
149194

150195
class EvaluationMeasureAPI(ResourceAPI):
151196
"""Abstract API interface for evaluation measure resources."""

0 commit comments

Comments
 (0)