Skip to content

Convert TaskType Class to a TaskType Enum #951

Closed

Description

@PGijsbers

OpenML features different task types (e.g. classification, regression), which we map to integers through this class.
Since Python 3.4 added Enums to the language, so we can update our code!

In particular, we should:

  • convert the TaskType to an Enum
  • refactor the name (just TaskType is sufficient)
  • update every use and type hint and doc string where TaskType is an int to use the enum TaskType instead, for example here:
def create_task(
    task_type_id: TaskType,
    ...
)
  • bonus: make OpenMLTask.task_type (a string representation of the task type) based on the enum directly: if task_type is your stored TaskType enum variable, the string name is accessed with task_type.name.

This issue requires little knowledge of the modules, but might be a bit of work to find different spellings of task_type.
Make sure to use your IDE for renaming (e.g. shift+F6 in PyCharm on Windows) to rename all references to a variable at once!
Use find across multiple files (e.g. PyCharm ctrl+shift+F) through all files for terms like "task_type_id" to help find variables and documentation to update.

Activity

  1. added
    Good First IssueIssues suitable for people new to contributing to openml-python!
    on Oct 1, 2020
  2. changed the title [-]Convert TaskType class to a TaskTypeEnum[/-] [+]Convert TaskType Class to a TaskType Enum[/+] on Oct 1, 2020
  3. fsabr commented on Oct 1, 2020

    @fsabr
    Contributor

    Hey can I take this up?

  4. PGijsbers commented on Oct 1, 2020

    @PGijsbers
    CollaboratorAuthor

    Absolutely! I assigned you to this issue now 👍 let us know if you need help, otherwise we are looking forward to a PR!

  5. fsabr commented on Oct 2, 2020

    @fsabr
    Contributor

    Thanks for assigning it to me. I have started working on it.

    I am failing a few tests now. Right now, there is an issue where I get this error
    ValueError: 9 is not a valid TaskType

    Look like some of the values in proc_["oml:ttid"]) is 9, when I run the test tests/test_tasks/test_task_functions.py.
    And nothing is mapped to 9 in TaskType.

    What do you suggest I do about this? Is something supposed to be mapped to 9?

  6. PGijsbers commented on Oct 2, 2020

    @PGijsbers
    CollaboratorAuthor

    Cool! 9 is not a valid task type id (based on rest API docs, which I assume is up to date @sahithyaravi1493?).
    Can you tell me what the proc_["oml:type"] and proc_["oml:id"] values are of the proc_ that causes the failure?

  7. fsabr commented on Oct 2, 2020

    @fsabr
    Contributor

    Wait, there's only one faulty proc. Here,

    id: 29
    task_type_id: 9
    name: 10-fold Crossvalidation
    type: crossvalidation
    

    Btw, if I make task_type_id None when there is no mapping in TaskType, all the tests pass.

  8. PGijsbers commented on Oct 2, 2020

    @PGijsbers
    CollaboratorAuthor

    Sorry for the delay. It turns out it is MultitaskRegression. It's odd that the name does not match with your observed values. For now just add "multitask regression" to the enum. I'll need a bit more information (from other devs) to decide what the right course of action should be. I don't think setting the task_type_id to None is correct here, an explicit error is probably preferred if the task type is truly unknown.

    @janvanrijn It looks like you are the creator of the "Multitask Regression" task type. Why is it only on the test server? If there are no plans to have it on the live server, is it possible to remove it from the test server? There are no tasks currently associated with the task type on the test server (according to this query).

  9. fsabr commented on Oct 2, 2020

    @fsabr
    Contributor

    Hey I've made a pr. I think I covered all usage of the class.
    I made the changes you said, I added a MULTITASK_REGRESSION field in the enum and mapped it to 9.
    Tell me if there are any issues or something I need to change.

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

Metadata

Metadata

Assignees

Labels

Good First IssueIssues suitable for people new to contributing to openml-python!

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions