Skip to content

Commit bd0175a

Browse files
committed
FIX work around missing JSONDecodeError in python 2.7/3.4
1 parent 7cd5741 commit bd0175a

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json.decoder
66
import six
77
import warnings
8+
import sys
89

910
import numpy as np
1011
import scipy.stats.distributions
@@ -19,6 +20,12 @@
1920
MAXIMAL_FLOW_LENGTH = 1024
2021

2122

23+
if sys.version_info >= (3, 5):
24+
from json.decoder import JSONDecodeError
25+
else:
26+
JSONDecodeError = ValueError
27+
28+
2229
class SklearnToFlowConverter(object):
2330

2431
def serialize_object(self, o):
@@ -92,7 +99,7 @@ def deserialize_object(self, o, **kwargs):
9299
if isinstance(o, six.string_types):
93100
try:
94101
o = json.loads(o)
95-
except json.decoder.JSONDecodeError:
102+
except JSONDecodeError:
96103
pass
97104

98105
if isinstance(o, dict):

openml/runs/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from .. import config
77
from ..flows import create_flow_from_model
8-
from ..flows.sklearn import SklearnToFlowConverter
8+
from ..flows.sklearn_converter import SklearnToFlowConverter
99
from ..exceptions import OpenMLCacheException
1010
from ..util import URLError
1111
from ..tasks.functions import _create_task_from_xml

tests/flows/test_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from openml.testing import TestBase
1818
from openml._api_calls import _perform_api_call
1919
import openml
20-
from openml.flows.sklearn import SklearnToFlowConverter
20+
from openml.flows.sklearn_converter import SklearnToFlowConverter
2121

2222
if sys.version_info[0] >= 3:
2323
from unittest import mock

tests/flows/test_sklearn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import sklearn.preprocessing
1616
import sklearn.tree
1717

18-
from openml.flows.sklearn import SklearnToFlowConverter
18+
from openml.flows.sklearn_converter import SklearnToFlowConverter
1919
from openml.flows import OpenMLFlow
2020

2121

0 commit comments

Comments
 (0)