Skip to content

Commit facefb2

Browse files
authored
update CI to verify onnx 1.12.0 (#564)
* update CI to verify onnx 1.12 rc. Signed-off-by: xiaowuhu <[email protected]> verify onnx 1.12 rc on python 3.9. * Update test_LightGbmTreeEnsembleConverters.py Signed-off-by: xiaowuhu <[email protected]> change StrictVersion to LooseVersion. * Update test_LightGbmTreeEnsembleConverters.py Signed-off-by: xiaowuhu <[email protected]> fix typo. * Update test_LightGbmTreeEnsembleConverters.py Signed-off-by: xiaowuhu <[email protected]> fix typo. * Update tests_helper.py Signed-off-by: xiaowuhu <[email protected]> fix typo. * Update test_LightGbmTreeEnsembleConverters.py Signed-off-by: xiaowuhu <[email protected]> change string condition to bool condition. * Update test_LightGbmTreeEnsembleConverters.py Signed-off-by: xiaowuhu <[email protected]> * change strict to loose Signed-off-by: xiaowuhu <[email protected]> * Update test_SVMConverters.py Signed-off-by: xiaowuhu <[email protected]> * verify onnx 1.12.0 Signed-off-by: xiaowuhu <[email protected]> Verify onnx 1.12.0 release version * change versioning API Signed-off-by: xiaowuhu <[email protected]> change StrictVersion to packaging.version, because StrictVersion will be deprecated.
1 parent 6f59846 commit facefb2

34 files changed

+106
-89
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ jobs:
1414
vmImage: 'ubuntu-latest'
1515
strategy:
1616
matrix:
17+
18+
Python39-1120-RT1110:
19+
python.version: '3.9'
20+
ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4'
21+
ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003'
22+
COREML_PATH: git+https://github.com/apple/[email protected]
23+
1724
Python39-1110-RT1110:
1825
python.version: '3.9'
1926
ONNX_PATH: onnx==1.11.0 # '-i https://test.pypi.org/simple/ onnx==1.9.101'

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ jobs:
1515
strategy:
1616
matrix:
1717

18+
Python39-1120-RT1110:
19+
python.version: '3.9'
20+
ONNX_PATH: 'onnx==1.12.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4'
21+
ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003'
22+
COREML_PATH: git+https://github.com/apple/[email protected]
23+
1824
Python39-1110-RT1110:
1925
python.version: '3.9'
2026
ONNX_PATH: onnx==1.11.0 # '-i https://test.pypi.org/simple/ onnx==1.9.101'

onnxmltools/convert/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
import warnings
4-
from distutils.version import StrictVersion
4+
import packaging.version as pv
55
import onnx
66
from .common import utils
77

@@ -34,7 +34,7 @@ def convert_keras(model, name=None,
3434
if targeted_onnx is not None:
3535
warnings.warn("targeted_onnx is deprecated and unused. Use target_opset.", DeprecationWarning)
3636
import tensorflow as tf
37-
if StrictVersion(tf.__version__) < StrictVersion('2.0'):
37+
if pv.Version(tf.__version__) < pv.Version('2.0'):
3838
# Former converter for tensorflow<2.0.
3939
from keras2onnx import convert_keras as convert
4040
return convert(model, name, doc_string, target_opset, channel_first_inputs)

onnxmltools/utils/tests_helper.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import warnings
66
import numpy
7+
import packaging.version as pv
78
from onnx.defs import onnx_opset_version
89
from onnxconverter_common.onnx_ex import DEFAULT_OPSET_NUMBER
910
from ..convert.common.data_types import FloatTensorType
@@ -40,7 +41,7 @@ def dump_data_and_model(data, model, onnx=None, basename="model", folder=None,
4041
:param allow_failure: None to raise an exception if comparison fails
4142
for the backends, otherwise a string which is then evaluated to check
4243
whether or not the test can fail, example:
43-
``"StrictVersion(onnx.__version__) < StrictVersion('1.3.0')"``
44+
``"pv.Version(onnx.__version__) < pv.Version('1.3.0')"``
4445
:param verbose: prints more information when it fails
4546
:return: the created files
4647
@@ -243,7 +244,7 @@ def dump_one_class_classification(model, suffix="", folder=None, allow_failure=N
243244
:param allow_failure: None to raise an exception if comparison fails
244245
for the backends, otherwise a string which is then evaluated to check
245246
whether or not the test can fail, example:
246-
``"StrictVersion(onnx.__version__) < StrictVersion('1.3.0')"``
247+
``"pv.Version(onnx.__version__) < pv.Version('1.3.0')"``
247248
:return: output of :func:`dump_data_and_model`
248249
249250
Every created filename will follow the pattern:
@@ -269,7 +270,7 @@ def dump_binary_classification(model, suffix="", folder=None, allow_failure=None
269270
:param allow_failure: None to raise an exception if comparison fails
270271
for the backends, otherwise a string which is then evaluated to check
271272
whether or not the test can fail, example:
272-
``"StrictVersion(onnx.__version__) < StrictVersion('1.3.0')"``
273+
``"pv.Version(onnx.__version__) < pv.Version('1.3.0')"``
273274
:param verbose: prints more information when it fails
274275
:return: output of :func:`dump_data_and_model`
275276
@@ -296,7 +297,7 @@ def dump_multiple_classification(model, suffix="", folder=None, allow_failure=No
296297
:param allow_failure: None to raise an exception if comparison fails
297298
for the backends, otherwise a string which is then evaluated to check
298299
whether or not the test can fail, example:
299-
``"StrictVersion(onnx.__version__) < StrictVersion('1.3.0')"``
300+
``"pv.Version(onnx.__version__) < pv.Version('1.3.0')"``
300301
:return: output of :func:`dump_data_and_model`
301302
302303
Every created filename will follow the pattern:
@@ -322,7 +323,7 @@ def dump_multiple_regression(model, suffix="", folder=None, allow_failure=None):
322323
:param allow_failure: None to raise an exception if comparison fails
323324
for the backends, otherwise a string which is then evaluated to check
324325
whether or not the test can fail, example:
325-
``"StrictVersion(onnx.__version__) < StrictVersion('1.3.0')"``
326+
``"pv.Version(onnx.__version__) < pv.Version('1.3.0')"``
326327
:return: output of :func:`dump_data_and_model`
327328
328329
Every created filename will follow the pattern:
@@ -349,7 +350,7 @@ def dump_single_regression(model, suffix="", folder=None, allow_failure=None):
349350
:param allow_failure: None to raise an exception if comparison fails
350351
for the backends, otherwise a string which is then evaluated to check
351352
whether or not the test can fail, example:
352-
``"StrictVersion(onnx.__version__) < StrictVersion('1.3.0')"``
353+
``"pv.Version(onnx.__version__) < pv.Version('1.3.0')"``
353354
:return: output of :func:`dump_data_and_model`
354355
355356
Every created filename will follow the pattern:

onnxmltools/utils/utils_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import sys
88
import glob
99
import pickle
10-
from distutils.version import StrictVersion
10+
import packaging.version as pv
1111
import numpy
1212
from numpy.testing import assert_array_almost_equal, assert_array_equal
1313

@@ -29,7 +29,7 @@ class OnnxRuntimeAssertionError(AssertionError):
2929
def evaluate_condition(backend, condition):
3030
"""
3131
Evaluates a condition such as
32-
``StrictVersion(onnxruntime.__version__) <= StrictVersion('0.1.3')``
32+
``pv.Version(onnxruntime.__version__) <= pv.Version('0.1.3')``
3333
"""
3434
if backend == "onnxruntime":
3535
import onnxruntime

tests/catboost/test_CatBoost_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
import unittest
77
import warnings
8-
from distutils.version import StrictVersion
8+
import packaging.version as pv
99
import numpy
1010
try:
1111
import sklearn
@@ -39,7 +39,7 @@ def test_catboost_regressor(self):
3939
def test_catboost_bin_classifier(self):
4040
import onnxruntime
4141

42-
if StrictVersion('.'.join(onnxruntime.__version__.split('.')[:2])) >= StrictVersion('1.3.0'):
42+
if pv.Version('.'.join(onnxruntime.__version__.split('.')[:2])) >= pv.Version('1.3.0'):
4343
X, y = make_classification(n_samples=100, n_features=4, random_state=0)
4444
catboost_model = catboost.CatBoostClassifier(task_type='CPU', loss_function='CrossEntropy',
4545
n_estimators=10, verbose=0)

tests/coreml/test_cml_AllNeuralNetworkConverters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
import unittest
4-
from distutils.version import StrictVersion
4+
import packaging.version as pv
55
import numpy
66
try:
77
from sklearn.impute import SimpleImputer as Imputer
@@ -480,7 +480,7 @@ def test_image_input_type_converter(self):
480480
dims = [(d.dim_param or d.dim_value) for d in model_onnx.graph.input[0].type.tensor_type.shape.dim]
481481
self.assertEqual(dims, ['None', 1 if onnx_colorspace == 'Gray8' else 3, 15, 25])
482482

483-
if StrictVersion(onnx.__version__) >= StrictVersion('1.2.1'):
483+
if pv.Version(onnx.__version__) >= pv.Version('1.2.1'):
484484
metadata = {prop.key: prop.value for prop in model_onnx.metadata_props}
485485
self.assertEqual(metadata, { 'Image.BitmapPixelFormat': onnx_colorspace })
486486
self.assertEqual(model_onnx.graph.input[0].type.denotation, 'IMAGE')

tests/coreml/test_cml_DictVectorizerConverter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Tests CoreML DictVectorizer converter.
55
"""
66
import sys
7-
from distutils.version import StrictVersion
7+
import packaging.version as pv
88
import unittest
99
import onnx
1010
import sklearn
@@ -30,7 +30,7 @@
3030
class TestCoreMLDictVectorizerConverter(unittest.TestCase):
3131

3232
@unittest.skipIf(
33-
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
33+
pv.Version(coremltools.__version__) > pv.Version("3.1"),
3434
reason="untested")
3535
def test_dict_vectorizer(self):
3636
model = DictVectorizer()
@@ -48,7 +48,7 @@ def test_dict_vectorizer(self):
4848
model_onnx = convert(model_coreml.get_spec(), target_opset=TARGET_OPSET)
4949
self.assertTrue(model_onnx is not None)
5050
dump_data_and_model(data, model, model_onnx, basename="CmlDictVectorizer-OneOff-SkipDim1",
51-
allow_failure="StrictVersion(onnx.__version__) < StrictVersion('1.3.0')")
51+
allow_failure="pv.Version(onnx.__version__) < pv.Version('1.3.0')")
5252

5353

5454
if __name__ == "__main__":

tests/coreml/test_cml_GLMClassifierConverter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Tests CoreML GLMClassifier converter.
55
"""
66
import unittest
7-
from distutils.version import StrictVersion
7+
import packaging.version as pv
88
import numpy
99
from sklearn.datasets import load_iris
1010
from sklearn.linear_model import LogisticRegression
@@ -38,7 +38,7 @@ def validate_zipmap(self, model):
3838
self.assertTrue('classProbability' in node.output)
3939

4040
@unittest.skipIf(
41-
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
41+
pv.Version(coremltools.__version__) > pv.Version("3.1"),
4242
reason="untested")
4343
def test_glm_classifier(self):
4444
iris = load_iris()
@@ -54,7 +54,7 @@ def test_glm_classifier(self):
5454
self.assertTrue(lr_onnx is not None)
5555
self.validate_zipmap(lr_onnx)
5656
dump_data_and_model(X.astype(numpy.float32), lr, lr_onnx, basename="CmlbinLogitisticRegression",
57-
allow_failure="StrictVersion(onnx.__version__) < StrictVersion('1.3.0')")
57+
allow_failure="pv.Version(onnx.__version__) < pv.Version('1.3.0')")
5858

5959
# Ensure there is a probability output
6060
svm = LinearSVC()

tests/coreml/test_cml_GLMRegressorConverter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Tests CoreML GLMRegressor converter.
55
"""
66
import unittest
7-
from distutils.version import StrictVersion
7+
import packaging.version as pv
88
import numpy
99
try:
1010
from sklearn.impute import SimpleImputer as Imputer
@@ -30,7 +30,7 @@
3030
class TestCoreMLGLMRegressorConverter(unittest.TestCase):
3131

3232
@unittest.skipIf(
33-
StrictVersion(coremltools.__version__) > StrictVersion("3.1"),
33+
pv.Version(coremltools.__version__) > pv.Version("3.1"),
3434
reason="untested")
3535
def test_glm_regressor(self):
3636
X, y = make_regression(n_features=4, random_state=0)

0 commit comments

Comments
 (0)