Skip to content

[BUG] create_task() hardcodes task_type="None" instead of inferring type string from TaskType #1766

Open

Description

@shellyco-code

Description

When creating an OpenML task locally using openml.tasks.create_task(), the task object is initialized with task_type="None".

In openml/tasks/functions.py:575, the function hardcodes this placeholder string literal:

return task_cls(
    task_id=None,
    task_type_id=task_type,
    task_type="None",  # TODO: refactor to get task type string from ID.
    data_set_id=dataset_id,
    target_name=target_name,
    estimation_procedure_id=estimation_procedure_id,
    evaluation_measure=evaluation_measure,
    **kwargs,
)
Because of this, task.task_type is literally the string "None" rather than the canonical task type name (e.g., "Supervised Classification", "Supervised Regression", "Clustering", "Learning Curve").

This causes:

Equality checks like if task.task_type == "Supervised Classification" (used in client code and in tests/test_runs/test_run.py:290) to evaluate to False.
Error messages and representations to display Task type 'None' (such as in openml/tasks/task.py:315).
Steps/Code to Reproduce
python
import openml
from openml.tasks import TaskType, create_task
task = create_task(
    TaskType.SUPERVISED_CLASSIFICATION,
    dataset_id=1,
    target_name="class",
    estimation_procedure_id=1,
)
print("task.task_type:", repr(task.task_type))
print("Is Supervised Classification?", task.task_type == "Supervised Classification")
Expected Results
task.task_type should be "Supervised Classification", and task.task_type == "Supervised Classification" should evaluate to True.

Actual Results
task.task_type: 'None'
Is Supervised Classification? False
Versions
OpenML: 0.16.0
Python: 3.10+
OS: Windows / Linux / macOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions