openml-python
openml-python copied to clipboard
__repr__ for OpenML objects are not protected against missing class attributed
Description
The __repr__
print for OpenML objects is called from here. The _get_repr_body_fields
function contains formatters for printing each object. However, if for certain reasons, some of the attributes are missing the print fails by throwing an error, while other functions of the API may work as-is. This can be a confusing behaviour for users.
Having checks to catch and handle such errors in _get_repr_body_fields
will be useful to have.
Steps/Code to Reproduce
Representative example:
import openml
task = openml.tasks.get_task(146806)
print(task) # fails
Expected Results
OpenML Classification Task
==========================
Task Type Description: https://www.openml.org/tt/TaskType.SUPERVISED_CLASSIFICATION
Task ID..............: 146806
Task URL.............: https://www.openml.org/t/146806
Estimation Procedure.: holdout
Target Feature.......: label
# of Classes.........: 2
Cost Matrix..........: Available
Actual Results
TypeError: object of type 'NoneType' has no len()
Versions
OpenML 0.12.1
.