镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(tasks): infer task_type string from TaskType in create_task - #1767

Open
shellyco-code wants to merge 1 commit into
openml:mainfrom
shellyco-code:fix/create-task-type-string
Open

shellyco-code wants to merge 1 commit into
openml:mainfrom
shellyco-code:fix/create-task-type-string

Conversation

@shellyco-code

Copy link
Copy Markdown
Contributor

Metadata

Details

  • What does this PR implement/fix?

    • Adds @property def type_str(self) -> str to TaskType mapping each enum member to its canonical OpenML string name (e.g., "Supervised Classification", "Supervised Regression", "Clustering", "Learning Curve", etc.).
    • Resolves # TODO: refactor to get task type string from ID. in openml/tasks/functions.py:create_task by passing task_type=task_type.type_str to task_cls.
    • Ensures OpenMLTask.__init__ defaults self.task_type = task_type if task_type is not None else task_type_id.type_str.
    • Adds offline unit tests test_create_task_sets_task_type() and test_task_type_str() in tests/test_tasks/test_task_functions.py.
  • Why is this change necessary?
    Previously, any task created via create_task() received task_type="None" as a literal string. This caused checks like task.task_type == "Supervised Classification" to fail and resulted in representations and error messages outputting 'None'.

  • How can I reproduce the issue this PR is solving and its solution?
    Run pytest tests/test_tasks/test_task_functions.py -k "test_create_task_sets_task_type or test_task_type_str". Both tests pass offline in < 0.2s.

…ml#1766)

- Add type_str property to TaskType enum mapping members to OpenML task strings

- Resolve TODO in create_task() by passing task_type.type_str instead of hardcoded 'None'

- Default task_type to task_type_id.type_str in OpenMLTask.__init__ if not provided

- Add unit tests for task_type assignment and TaskType.type_str

Signed-off-by: Shelly Chahar <shellychahar57@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.34%. Comparing base (4a25027) to head (9e3388b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1767      +/-   ##
==========================================
- Coverage   81.50%   81.34%   -0.16%     
==========================================
  Files          63       63              
  Lines        5238     5242       +4     
==========================================
- Hits         4269     4264       -5     
- Misses        969      978       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants