Skip to content

Commit 3d81a0a

Browse files
authored
Update CI to onnx==1.10.1 (#490)
* check onnx==1.10.1 * better error message * change skipping condition * one condition less strict on lightgbm
1 parent c1651b1 commit 3d81a0a

15 files changed

+108
-10
lines changed

.azure-pipelines/linux-conda-CI.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313
vmImage: 'ubuntu-latest'
1414
strategy:
1515
matrix:
16+
Python39-1101-RT181-xgb11:
17+
python.version: '3.9'
18+
ONNX_PATH: onnx==1.10.1 # '-i https://test.pypi.org/simple/ onnx==1.9.101'
19+
ONNXRT_PATH: onnxruntime==1.8.1
20+
COREML_PATH: git+https://github.com/apple/[email protected]
21+
xgboost.version: '>=1.2'
1622
Python39-190-RT180-xgb11:
1723
python.version: '3.9'
1824
ONNX_PATH: onnx==1.9.0

.azure-pipelines/win32-conda-CI.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ jobs:
1313
vmImage: 'windows-latest'
1414
strategy:
1515
matrix:
16+
Python39-1101-RT181:
17+
python.version: '3.9'
18+
ONNX_PATH: 'onnx==1.10.1' # '-i https://test.pypi.org/simple/ onnx==1.9.101'
19+
ONNXRT_PATH: onnxruntime==1.8.1
20+
COREML_PATH: git+https://github.com/apple/[email protected]
21+
sklearn.version: ''
22+
23+
Python39-190-RT181:
24+
python.version: '3.9'
25+
ONNX_PATH: 'onnx==1.9.0'
26+
ONNXRT_PATH: onnxruntime==1.8.1
27+
COREML_PATH: git+https://github.com/apple/[email protected]
28+
sklearn.version: ''
29+
1630
Python39-190-RT180:
1731
python.version: '3.9'
1832
ONNX_PATH: onnx==1.9.0
@@ -66,15 +80,32 @@ jobs:
6680
call activate py$(python.version)
6781
python -m pip install --upgrade pip numpy
6882
echo Test numpy installation... && python -c "import numpy"
69-
python -m pip install %COREML_PATH% %ONNX_PATH%
83+
python -m pip install scikit-learn
84+
python -m pip install %ONNX_PATH%
7085
python -m pip install humming-bird-ml --no-deps
7186
python -m pip install -r requirements.txt
7287
python -m pip install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
88+
displayName: 'Install dependencies (1)'
89+
90+
- script: |
91+
call activate py$(python.version)
7392
python -m pip install -r requirements-dev.txt
93+
displayName: 'Install dependencies (2)'
94+
95+
- script: |
96+
call activate py$(python.version)
97+
python -m pip install %COREML_PATH%
98+
displayName: 'Install coremltools'
99+
100+
- script: |
101+
call activate py$(python.version)
74102
python -m pip install %ONNXRT_PATH%
103+
displayName: 'Install onnxruntime'
104+
105+
- script: |
106+
call activate py$(python.version)
75107
python -m pip install scikit-learn$(sklearn.version)
76-
python -m pip show pytest
77-
displayName: 'Install dependencies'
108+
displayName: 'Install scikit-learn'
78109
79110
- script: |
80111
call activate py$(python.version)

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-f https://download.pytorch.org/whl/torch_stable.html
22
catboost
33
codecov
4-
coremltools
54
cython
65
dill
76
flake8

tests/coreml/test_cml_DictVectorizerConverter.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"""
44
Tests CoreML DictVectorizer converter.
55
"""
6+
import sys
7+
from distutils.version import StrictVersion
8+
import unittest
9+
import onnx
10+
import sklearn
611
try:
712
from sklearn.impute import SimpleImputer as Imputer
813
import sklearn.preprocessing
@@ -12,19 +17,29 @@
1217
except ImportError:
1318
from sklearn.preprocessing import Imputer
1419
import coremltools
15-
import unittest
1620
from sklearn.feature_extraction import DictVectorizer
1721
from onnxmltools.convert.coreml.convert import convert
1822
from onnxmltools.utils import dump_data_and_model
1923

2024

2125
class TestCoreMLDictVectorizerConverter(unittest.TestCase):
2226

27+
@unittest.skipIf(
28+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
29+
reason="untested")
2330
def test_dict_vectorizer(self):
2431
model = DictVectorizer()
2532
data = [{'amy': 1., 'chin': 200.}, {'nice': 3., 'amy': 1.}]
2633
model.fit_transform(data)
27-
model_coreml = coremltools.converters.sklearn.convert(model)
34+
try:
35+
model_coreml = coremltools.converters.sklearn.convert(model)
36+
except NameError as e:
37+
raise AssertionError(
38+
"Unable to use coremltools, coremltools.__version__=%r, "
39+
"onnx.__version__=%r, sklearn.__version__=%r, "
40+
"sys.platform=%r." % (
41+
coremltools.__version__, onnx.__version__,
42+
sklearn.__version__, sys.platform)) from e
2843
model_onnx = convert(model_coreml.get_spec())
2944
self.assertTrue(model_onnx is not None)
3045
dump_data_and_model(data, model, model_onnx, basename="CmlDictVectorizer-OneOff-SkipDim1",

tests/coreml/test_cml_GLMClassifierConverter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Tests CoreML GLMClassifier converter.
55
"""
66
import unittest
7+
from distutils.version import StrictVersion
78
import numpy
89
from sklearn.datasets import load_iris
910
from sklearn.linear_model import LogisticRegression
@@ -31,6 +32,9 @@ def validate_zipmap(self, model):
3132
self.assertEqual(len(node.output), 1)
3233
self.assertTrue('classProbability' in node.output)
3334

35+
@unittest.skipIf(
36+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
37+
reason="untested")
3438
def test_glm_classifier(self):
3539
iris = load_iris()
3640
X = iris.data[:, :2]

tests/coreml/test_cml_GLMRegressorConverter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Tests CoreML GLMRegressor converter.
55
"""
66
import unittest
7+
from distutils.version import StrictVersion
78
import numpy
89
try:
910
from sklearn.impute import SimpleImputer as Imputer
@@ -23,6 +24,9 @@
2324

2425
class TestCoreMLGLMRegressorConverter(unittest.TestCase):
2526

27+
@unittest.skipIf(
28+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
29+
reason="untested")
2630
def test_glm_regressor(self):
2731
X, y = make_regression(n_features=4, random_state=0)
2832

tests/coreml/test_cml_ImputerConverter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"""
44
Tests CoreML Imputer converter.
55
"""
6-
import numpy as np
76
import unittest
7+
from distutils.version import StrictVersion
8+
import numpy as np
89
try:
910
from sklearn.impute import SimpleImputer as Imputer
1011
import sklearn.preprocessing
@@ -14,11 +15,15 @@
1415
except ImportError:
1516
from sklearn.preprocessing import Imputer
1617
import sklearn.preprocessing
18+
import coremltools
1719
from onnxmltools.utils import dump_data_and_model
1820

1921

2022
class TestCoreMLImputerConverter(unittest.TestCase):
2123

24+
@unittest.skipIf(
25+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
26+
reason="untested")
2227
def test_imputer(self):
2328
try:
2429
model = Imputer(missing_values='NaN', strategy='mean', axis=0)

tests/coreml/test_cml_OneHotEncoderConverter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
"""
44
Main functions to convert machine learned model from *Core ML* model to *ONNX*.
55
"""
6+
import sys
67
import os
78
import unittest
89
import warnings
10+
from distutils.version import StrictVersion
911
import numpy
12+
import onnx
1013
try:
1114
from sklearn.impute import SimpleImputer as Imputer
1215
import sklearn.preprocessing
@@ -23,6 +26,9 @@
2326

2427
class TestCoremlOneHotEncoderConverter(unittest.TestCase):
2528

29+
@unittest.skipIf(
30+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
31+
reason="untested")
2632
def test_one_hot_encoder(self):
2733
script_dir = os.path.dirname(__file__)
2834
relative_path = "../data/onehot_simple.mlmodel"

tests/coreml/test_cml_ScalerConverter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Tests CoreML Scaler converter.
55
"""
66
import unittest
7+
from distutils.version import StrictVersion
78
import numpy
89
try:
910
from sklearn.impute import SimpleImputer as Imputer
@@ -21,6 +22,9 @@
2122

2223
class TestCoreMLScalerConverter(unittest.TestCase):
2324

25+
@unittest.skipIf(
26+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
27+
reason="untested")
2428
def test_scaler(self):
2529
model = StandardScaler()
2630
data = numpy.array([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]], dtype=numpy.float32)

tests/coreml/test_cml_SupportVectorClassifierConverter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44
Tests CoreML SupportVectorClassifier converter.
55
"""
6+
from distutils.version import StrictVersion
67
try:
78
from sklearn.impute import SimpleImputer as Imputer
89
import sklearn.preprocessing
@@ -59,6 +60,9 @@ def validate_zipmap(self, model):
5960
self.assertEqual(len(node.output), 1)
6061
self.assertTrue('classProbability' in node.output)
6162

63+
@unittest.skipIf(
64+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
65+
reason="untested")
6266
def test_support_vector_classifier_binary_no_prob(self):
6367
svm, X = self._fit_binary_classification(SVC(gamma=0.5))
6468
svm_coreml = coremltools.converters.sklearn.convert(svm)
@@ -71,6 +75,9 @@ def test_support_vector_classifier_binary_no_prob(self):
7175
dump_data_and_model(X, svm, svm_onnx, basename="CmlBinSVC-Out0",
7276
allow_failure=True)
7377

78+
@unittest.skipIf(
79+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
80+
reason="untested")
7481
def test_support_vector_classifier_binary_with_prob(self):
7582
svm, X = self._fit_binary_classification(SVC(probability=True, gamma=0.5))
7683
svm_coreml = coremltools.converters.sklearn.convert(svm)
@@ -79,6 +86,9 @@ def test_support_vector_classifier_binary_with_prob(self):
7986
self.validate_zipmap(svm_onnx)
8087
self._check_model_outputs(svm_onnx, ['classLabel', 'classProbability'])
8188

89+
@unittest.skipIf(
90+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
91+
reason="untested")
8292
def test_support_vector_classifier_multiclass_no_prob(self):
8393
svm, X = self._fit_multi_classification(SVC(gamma=0.5))
8494
svm_coreml = coremltools.converters.sklearn.convert(svm)
@@ -88,6 +98,9 @@ def test_support_vector_classifier_multiclass_no_prob(self):
8898
self.assertEqual(len(nodes), 1)
8999
self._check_model_outputs(svm_onnx, ['classLabel'])
90100

101+
@unittest.skipIf(
102+
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
103+
reason="untested")
91104
def test_support_vector_classifier_multiclass_with_prob(self):
92105
svm, X = self._fit_multi_classification(SVC(probability=True, gamma=0.5))
93106
svm_coreml = coremltools.converters.sklearn.convert(svm)

0 commit comments

Comments
 (0)