Skip to content

Printing the result of a run gives an error when flow_name is None #536

@ledell

Description

@ledell

Description

TypeError thrown when calling the print method on a openml.runs.run.OpenMLRun object when flow_name is None.

Steps/Code to Reproduce

from sklearn import ensemble
from openml import tasks, flows, runs
import openml

task = tasks.get_task(3954)
clf = ensemble.RandomForestClassifier()
flow = flows.sklearn_to_flow(clf)
run = runs.run_flow_on_task(task, flow)
print(run)   #error

Validating that the flow_name is None:

In [87]: run.flow_name is None
Out[87]: True

Expected Results

In [88]: print(run)
Out[88]: 
[run id: None, task id: 3954, flow id: 8656, flow name: None]

Actual Results

In [74]: print(run)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-74-7667ec7d87d4> in <module>()
----> 1 print(run)

/usr/local/lib/python3.6/site-packages/openml/runs/run.py in __str__(self)
     57     def __str__(self):
     58         flow_name = self.flow_name
---> 59         if len(flow_name) > 26:
     60             # long enough to show sklearn.pipeline.Pipeline
     61             flow_name = flow_name[:26] + "..."

TypeError: object of type 'NoneType' has no len()

Versions

Darwin-17.4.0-x86_64-i386-64bit
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]
NumPy 1.15.0
SciPy 1.1.0
Scikit-Learn 0.19.2
OpenML 0.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions