Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TypeError raised by trying to get the __repr__ of a locally created task #1100

Copy link
Copy link
@PGijsbers

Description

@PGijsbers
Issue body actions

When creating a task locally the __repr__ function raises a TypeError due to the class_labels attribute being None. This persists even after publishing it, which makes exposure of this bug more prevalent (because the task.publish() returns itself which invokes __repr__ if ran in an interactive shell without assigning the result to a variable):

import openml
openml.config.start_configuration_for_example()
t = openml.tasks.create_task(openml.tasks.task.TaskType.SUPERVISED_CLASSIFICATION, 128, 2, "class", "weighted_recall")
t.publish()
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\repositories\openml-python\openml\base.py", line 19, in __repr__
    body_fields = self._get_repr_body_fields()
  File "D:\repositories\openml-python\openml\tasks\task.py", line 101, in _get_repr_body_fields
    fields["# of Classes"] = len(getattr(self, "class_labels"))
TypeError: object of type 'NoneType' has no len()

Suggested expected behavior: leave it out of the __repr__ if class_labels is None, i.e. extend the check of task#100 to skip assignment if class_labels is None. I don't think it's worth the added complexity to support an accurate class_labels in this niche scenario.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.