From 4564867a44ea936658dd4e9d068dd671e565d708 Mon Sep 17 00:00:00 2001 From: Liubov Talamanova Date: Mon, 20 Dec 2021 09:10:39 +0300 Subject: [PATCH] Update POT tests for OMZ location in openvino/thirdparty (#9171) * Move OMZ to thirdparty/open_model_zoo * Improve diagnostic of issues * Update path to OMZ in the Python wheel setup.py * Update POT tests for OMZ location in openvino/thirdparty * fix mo path Co-authored-by: azhogov --- .gitmodules | 2 +- .../thirdparty => thirdparty}/open_model_zoo | 0 tools/openvino_dev/setup.py | 8 +++- .../openvino/tools/pot/utils/ac_imports.py | 39 +++++++------------ tools/pot/setup.py | 1 - tools/pot/tests/utils/path.py | 4 +- tools/pot/thirdparty/__init__.py | 2 - 7 files changed, 23 insertions(+), 33 deletions(-) rename {tools/pot/thirdparty => thirdparty}/open_model_zoo (100%) delete mode 100644 tools/pot/thirdparty/__init__.py diff --git a/.gitmodules b/.gitmodules index 16915b5aa7a..f13e3c9db7e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -57,7 +57,7 @@ path = thirdparty/onednn_gpu url = https://github.com/oneapi-src/oneDNN.git [submodule "tools/pot/thirdparty/open_model_zoo"] - path = tools/pot/thirdparty/open_model_zoo + path = thirdparty/open_model_zoo url = https://github.com/openvinotoolkit/open_model_zoo.git [submodule "thirdparty/json/nlohmann_json"] path = thirdparty/json/nlohmann_json diff --git a/tools/pot/thirdparty/open_model_zoo b/thirdparty/open_model_zoo similarity index 100% rename from tools/pot/thirdparty/open_model_zoo rename to thirdparty/open_model_zoo diff --git a/tools/openvino_dev/setup.py b/tools/openvino_dev/setup.py index 44861d6a3ed..28982ea3b1c 100644 --- a/tools/openvino_dev/setup.py +++ b/tools/openvino_dev/setup.py @@ -42,13 +42,13 @@ PKG_INSTALL_CFG = { 'extract_entry_points': True, }, "accuracy_checker": { - 'src_dir': OPENVINO_DIR / 'tools' / 'pot' / 'thirdparty' / 'open_model_zoo' / 'tools' / 'accuracy_checker', # noqa:E501 + 'src_dir': OPENVINO_DIR / 'thirdparty' / 'open_model_zoo' / 'tools' / 'accuracy_checker', # noqa:E501 'black_list': ['*tests*'], 'prefix': 'accuracy_checker', 'extract_entry_points': True, }, "omz_tools": { - 'src_dir': OPENVINO_DIR / 'tools' / 'pot' / 'thirdparty' / 'open_model_zoo' / 'tools' / 'model_tools', # noqa:E501 + 'src_dir': OPENVINO_DIR / 'thirdparty' / 'open_model_zoo' / 'tools' / 'model_tools', # noqa:E501 'black_list': [], 'prefix': 'omz_tools', 'extract_requirements': True, @@ -80,6 +80,10 @@ class CustomBuild(build): self.announce('Installing packages', level=log.INFO) for cmp, cmp_data in PKG_INSTALL_CFG.items(): self.announce(f'Processing package: {cmp}', level=log.INFO) + if not cmp_data['src_dir'].is_dir(): + raise FileNotFoundError( + f'The source directory was not found: {cmp_data["src_dir"]}' + ) subprocess.call([sys.executable, 'setup.py', 'install', '--root', str(SCRIPT_DIR), '--prefix', str(cmp_data.get("prefix"))], diff --git a/tools/pot/openvino/tools/pot/utils/ac_imports.py b/tools/pot/openvino/tools/pot/utils/ac_imports.py index c6999b9bb26..7d870c2346e 100644 --- a/tools/pot/openvino/tools/pot/utils/ac_imports.py +++ b/tools/pot/openvino/tools/pot/utils/ac_imports.py @@ -1,28 +1,19 @@ # Copyright (C) 2020-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -try: - from thirdparty.open_model_zoo.tools.accuracy_checker.\ - openvino.tools.accuracy_checker.evaluators.quantization_model_evaluator import create_model_evaluator - from thirdparty.open_model_zoo.tools.accuracy_checker.openvino.tools.accuracy_checker.config import ConfigReader - from thirdparty.open_model_zoo.tools.accuracy_checker.openvino.tools.accuracy_checker.dataset import\ - Dataset, DataProvider as DatasetWrapper - from thirdparty.open_model_zoo.tools.accuracy_checker.openvino.tools.accuracy_checker.logging\ - import _DEFAULT_LOGGER_NAME +import sys +import importlib +from pathlib import Path -except ImportError: - try: - from openvino.tools.accuracy_checker.evaluators.quantization_model_evaluator import create_model_evaluator - from openvino.tools.accuracy_checker.config import ConfigReader - from openvino.tools.accuracy_checker.dataset import Dataset - from openvino.tools.accuracy_checker.logging import _DEFAULT_LOGGER_NAME - from openvino.tools.accuracy_checker.dataset import DataProvider as DatasetWrapper - except ImportError: - from accuracy_checker.evaluators.quantization_model_evaluator import create_model_evaluator - from accuracy_checker.config import ConfigReader - from accuracy_checker.dataset import Dataset - from accuracy_checker.logging import _DEFAULT_LOGGER_NAME - try: - from accuracy_checker.dataset import DataProvider as DatasetWrapper - except ImportError: - from accuracy_checker.dataset import DatasetWrapper +import openvino + +LIBS_ROOT = Path(__file__).resolve().parents[6] / 'thirdparty' +sys.path.append(str(LIBS_ROOT / 'open_model_zoo' / 'tools' / 'accuracy_checker')) +# pylint: disable=E0611,C0413,C0411,E0401 +importlib.reload(openvino) + +from openvino.tools.accuracy_checker.evaluators.quantization_model_evaluator import create_model_evaluator +from openvino.tools.accuracy_checker.config import ConfigReader +from openvino.tools.accuracy_checker.dataset import Dataset +from openvino.tools.accuracy_checker.logging import _DEFAULT_LOGGER_NAME +from openvino.tools.accuracy_checker.dataset import DataProvider as DatasetWrapper diff --git a/tools/pot/setup.py b/tools/pot/setup.py index ee4615c6b29..12c86283f31 100644 --- a/tools/pot/setup.py +++ b/tools/pot/setup.py @@ -111,7 +111,6 @@ setup( long_description_content_type='text/markdown', url='https://software.intel.com/openvino-toolkit', packages=find_packages(exclude=["tests", "tests.*", - "thirdparty", "thirdparty.*", "tools", "tools.*"]), package_data={"openvino.tools.pot.configs.hardware": ['*.json'], "openvino.tools.pot.api.samples": ['*.md', '*/*.md']}, diff --git a/tools/pot/tests/utils/path.py b/tools/pot/tests/utils/path.py index 0b632253cfa..ffc44fc4cc7 100644 --- a/tools/pot/tests/utils/path.py +++ b/tools/pot/tests/utils/path.py @@ -7,10 +7,8 @@ from openvino.tools.mo import mo TEST_ROOT = Path(__file__).parent.parent.absolute() -PROJECT_ROOT = TEST_ROOT.parent -LIBS_ROOT = PROJECT_ROOT / 'thirdparty' +LIBS_ROOT = Path(__file__).resolve().parents[4] / 'thirdparty' MO_PATH = Path(mo.__file__).parent -AC_PATH = LIBS_ROOT / 'open_model_zoo' / 'tools' / 'accuracy_checker' MODELS_PATH = TEST_ROOT / 'data' / 'models' REFERENCE_MODELS_PATH = TEST_ROOT / 'data' / 'reference_models' diff --git a/tools/pot/thirdparty/__init__.py b/tools/pot/thirdparty/__init__.py deleted file mode 100644 index 6e02c1c9510..00000000000 --- a/tools/pot/thirdparty/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (C) 2020-2021 Intel Corporation -# SPDX-License-Identifier: Apache-2.0