diff --git a/onnxruntime/test/python/onnxruntime_test_python.py b/onnxruntime/test/python/onnxruntime_test_python.py index e30371e5a2..e188d31e47 100644 --- a/onnxruntime/test/python/onnxruntime_test_python.py +++ b/onnxruntime/test/python/onnxruntime_test_python.py @@ -9,6 +9,7 @@ import onnxruntime as onnxrt import threading import sys from helper import get_name +from onnxruntime.capi.onnxruntime_pybind11_state import Fail class TestInferenceSession(unittest.TestCase): @@ -20,12 +21,19 @@ class TestInferenceSession(unittest.TestCase): np.testing.assert_allclose(output_expected, res[0], rtol=1e-05, atol=1e-08) def testModelSerialization(self): - so = onnxrt.SessionOptions() - so.log_verbosity_level = 1 - so.logid = "TestModelSerialization" - so.optimized_model_filepath = "./PythonApiTestOptimizedModel.onnx" - onnxrt.InferenceSession(get_name("mul_1.onnx"), sess_options=so) - self.assertTrue(os.path.isfile(so.optimized_model_filepath)) + try: + so = onnxrt.SessionOptions() + so.log_verbosity_level = 1 + so.logid = "TestModelSerialization" + so.optimized_model_filepath = "./PythonApiTestOptimizedModel.onnx" + onnxrt.InferenceSession(get_name("mul_1.onnx"), sess_options=so) + self.assertTrue(os.path.isfile(so.optimized_model_filepath)) + except Fail as onnxruntime_error: + if str(onnxruntime_error) == "[ONNXRuntimeError] : 1 : FAIL : Unable to serialize model as it contains" \ + " compiled nodes. Please disable any execution providers which generate compiled nodes.": + pass + else: + raise onnxruntime_error def testGetProviders(self): self.assertTrue('CPUExecutionProvider' in onnxrt.get_available_providers()) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index e9b113ef94..9f31a2796c 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -1457,7 +1457,7 @@ def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs): # Disable python tests in a reduced build as we don't know which ops have been included and which # models can run - if args.include_ops_by_model or args.include_ops_by_config or args.minimal_build: + if args.include_ops_by_model or args.include_ops_by_config or args.minimal_build != 'off': return if is_windows():