From ed39903028a879dcb5ec539d530d018b5c3917c4 Mon Sep 17 00:00:00 2001 From: Jan Iwaszkiewicz Date: Thu, 11 Aug 2022 10:53:54 +0200 Subject: [PATCH] [PyOV] Fix error handling for Debug builds and extend configs for CI (#12417) --- src/bindings/python/setup.cfg | 2 +- .../python/src/pyopenvino/core/async_infer_queue.cpp | 6 +++++- src/bindings/python/tests/conftest.py | 2 +- .../python/tests/test_runtime/test_compiled_model.py | 1 + src/bindings/python/tests/test_runtime/test_core.py | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bindings/python/setup.cfg b/src/bindings/python/setup.cfg index 49df558fb58..33d593c29dd 100644 --- a/src/bindings/python/setup.cfg +++ b/src/bindings/python/setup.cfg @@ -17,7 +17,7 @@ passenv = commands= {envbindir}/python setup.py bdist_wheel {envbindir}/pip install --no-index --pre --find-links=dist/ openvino - pytest --backend={env:OV_BACKEND} tests -v -k 'not _cuda' --ignore=tests/test_onnx/test_zoo_models.py --ignore=tests/test_utils --ignore=tests/test_runtime + pytest --backend={env:OV_BACKEND} tests -m "not template_plugin" -v -k 'not _cuda' --ignore=tests/test_onnx/test_zoo_models.py --ignore=tests/test_utils pytest --backend={env:OV_BACKEND} tests_compatibility/test_ngraph -v -k 'not _cuda' --ignore=tests_compatibility/test_onnx/test_zoo_models.py [testenv:zoo_models] diff --git a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp index 334eea77c63..dbb9a8c05c6 100644 --- a/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp +++ b/src/bindings/python/src/pyopenvino/core/async_infer_queue.cpp @@ -113,7 +113,11 @@ public: try { f_callback(_requests[handle], _user_ids[handle]); } catch (py::error_already_set py_error) { - assert(PyErr_Occurred()); + // This should behave the same as assert(!PyErr_Occurred()) + // since constructor for pybind11's error_already_set is + // performing PyErr_Fetch which clears error indicator and + // saves it inside itself. + assert(py_error.type()); // acquire the mutex to access _errors std::lock_guard lock(_mutex); _errors.push(py_error); diff --git a/src/bindings/python/tests/conftest.py b/src/bindings/python/tests/conftest.py index 5d3d6aa7fbb..184c59c8bf6 100644 --- a/src/bindings/python/tests/conftest.py +++ b/src/bindings/python/tests/conftest.py @@ -131,7 +131,7 @@ def pytest_configure(config): config.addinivalue_line("markers", "skip_on_hetero: Skip test on HETERO") config.addinivalue_line("markers", "skip_on_template: Skip test on TEMPLATE") config.addinivalue_line("markers", "onnx_coverage: Collect ONNX operator coverage") - config.addinivalue_line("markers", "template_extension") + config.addinivalue_line("markers", "template_plugin") config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case") diff --git a/src/bindings/python/tests/test_runtime/test_compiled_model.py b/src/bindings/python/tests/test_runtime/test_compiled_model.py index 873a81d3a30..c082096a026 100644 --- a/src/bindings/python/tests/test_runtime/test_compiled_model.py +++ b/src/bindings/python/tests/test_runtime/test_compiled_model.py @@ -345,6 +345,7 @@ def test_direct_infer(device): assert np.array_equal(ref[comp_model.outputs[0]], res[comp_model.outputs[0]]) +@pytest.mark.template_plugin() def test_compiled_model_after_core_destroyed(device): core = Core() with open(test_net_bin, "rb") as f: diff --git a/src/bindings/python/tests/test_runtime/test_core.py b/src/bindings/python/tests/test_runtime/test_core.py index eebeb61f335..548404d7c35 100644 --- a/src/bindings/python/tests/test_runtime/test_core.py +++ b/src/bindings/python/tests/test_runtime/test_core.py @@ -322,7 +322,7 @@ def test_unregister_plugin(device): ) -@pytest.mark.template_extension() +@pytest.mark.template_plugin() def test_add_extension_template_extension(device): core, model = get_model_with_template_extension() assert isinstance(model, Model)