Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#1,766 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@shellyco-code 已经在做这个了。

开始于 2026年10月6日。

  • #1767 来自 @shellyco-code —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
80/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
api

调研方向

从 openml/tasks/functions.py 中第 575 行附近的 create_task() 开始,然后阅读 TaskType 值如何映射到规范名称。检查 tests/test_runs/test_run.py 中第 290 行附近的任务类型比较,并添加或更新回归测试。完成的标准是:本地创建的任务显示预期的规范任务类型字符串,而不是 "None"。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Python
星标
366
派生
306
平均合并
2 天 9 小时
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openml/openml-python 的其他 Issue

查看 openml/openml-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。