Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Deprecate the use of strings for identifying tasks
  • Loading branch information
PGijsbers committed May 20, 2021
commit 1fb8b640d12ba448fcae271126dd2ad913fa6002
17 changes: 10 additions & 7 deletions openml/tasks/functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# License: BSD 3-Clause

import warnings
from collections import OrderedDict
import io
import re
Expand Down Expand Up @@ -298,16 +298,16 @@ def __list_tasks(api_call, output_format="dict"):


def get_tasks(
task_ids: List[Union[str, int]], download_data: bool = True, download_qualities: bool = True
task_ids: List[int], download_data: bool = True, download_qualities: bool = True
) -> List[OpenMLTask]:
"""Download tasks.

This function iterates :meth:`openml.tasks.get_task`.

Parameters
----------
task_ids : iterable
Integers/Strings representing task ids.
task_ids : List[int]
A list of task ids to download.
download_data : bool (default = True)
Option to trigger download of data along with the meta data.
download_qualities : bool (default=True)
Expand Down Expand Up @@ -335,8 +335,8 @@ def get_task(

Parameters
----------
task_id : int or str
The OpenML task id.
task_id : int
The OpenML task id of the task to download.
download_data : bool (default=True)
Option to trigger download of data along with the meta data.
download_qualities : bool (default=True)
Expand All @@ -346,10 +346,13 @@ def get_task(
-------
task
"""
if not isinstance(task_id, int):
warnings.warn("Task id must be specified as `int` from 0.14.0 onwards.", DeprecationWarning)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with (what I remember to be) scikit-learn's default behavior of having at least one full minor release with the deprecation warning.


try:
task_id = int(task_id)
except (ValueError, TypeError):
raise ValueError("Dataset ID is neither an Integer nor can be " "cast to an Integer.")
raise ValueError("Dataset ID is neither an Integer nor can be cast to an Integer.")

tid_cache_dir = openml.utils._create_cache_directory_for_id(TASKS_CACHE_DIR_NAME, task_id,)

Expand Down