diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index 2093c315a06691..8a572f89a0f47e 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -123,17 +123,8 @@ ov_check_python_build_conditions() # check __init__.py files alignment -function(ov_check_init_files_alignment) +function(ov_check_init_files_alignment init_files) # check the files in pairs - list(APPEND init_files - "${OpenVINOPython_SOURCE_DIR}/src/openvino/__init__.py" - "${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/mo/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/pot/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/ovc/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/benchmark_tool/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/openvino_dev/src/openvino/__init__.py") - list(LENGTH init_files init_files_count) math(EXPR file_loop_range "${init_files_count}-2") foreach(init_file_idx RANGE 0 ${file_loop_range}) @@ -145,12 +136,18 @@ function(ov_check_init_files_alignment) RESULT_VARIABLE compare_result ) if(compare_result EQUAL 1) - message(FATAL_ERROR "The __init__.py files are misaligned: ${file1} and ${file2}") + message(FATAL_ERROR "The runtime __init__.py files are misaligned: ${file1} and ${file2}") endif() endforeach() endfunction() -ov_check_init_files_alignment() +set(INIT_FILES_RUNTIME +"${OpenVINOPython_SOURCE_DIR}/src/openvino/__init__.py" +"${OpenVINOPython_SOURCE_DIR}/src/compatibility/openvino/__init__.py" +"${OpenVINO_SOURCE_DIR}/tools/ovc/openvino/__init__.py" +"${OpenVINO_SOURCE_DIR}/tools/benchmark_tool/openvino/__init__.py") + +ov_check_init_files_alignment("${INIT_FILES_RUNTIME}") ov_option(ENABLE_PYTHON "Enables OpenVINO Python API build" ${ENABLE_PYTHON_DEFAULT}) diff --git a/src/bindings/python/src/compatibility/openvino/__init__.py b/src/bindings/python/src/compatibility/openvino/__init__.py index 90552e0befed68..b7dc434f3148cc 100644 --- a/src/bindings/python/src/compatibility/openvino/__init__.py +++ b/src/bindings/python/src/compatibility/openvino/__init__.py @@ -12,47 +12,47 @@ except ImportError: pass -# API 2.0 -try: - # Import all public modules - from openvino import runtime as runtime - from openvino import frontend as frontend - from openvino import helpers as helpers - from openvino import preprocess as preprocess - from openvino import utils as utils - from openvino.runtime import properties as properties - - # Import most important classes and functions from openvino.runtime - from openvino.runtime import Model - from openvino.runtime import Core - from openvino.runtime import CompiledModel - from openvino.runtime import InferRequest - from openvino.runtime import AsyncInferQueue - - from openvino.runtime import Dimension - from openvino.runtime import Strides - from openvino.runtime import PartialShape - from openvino.runtime import Shape - from openvino.runtime import Layout - from openvino.runtime import Type - from openvino.runtime import Tensor - from openvino.runtime import OVAny - - from openvino.runtime import compile_model - from openvino.runtime import get_batch - from openvino.runtime import set_batch - from openvino.runtime import serialize - from openvino.runtime import shutdown - from openvino.runtime import tensor_from_file - from openvino.runtime import save_model - from openvino.runtime import layout_helpers - - # Set version for openvino package - from openvino.runtime import get_version - __version__ = get_version() -except ImportError: - import warnings - warnings.warn("openvino package has problems with imports!", ImportWarning, stacklevel=2) +# # +# # API 2.0 +# # This __init__.py forces checking of runtime modules to propagate errors. +# # It is not compared with init files from openvino-dev package. +# # +# Import all public modules +from openvino import runtime as runtime +from openvino import frontend as frontend +from openvino import helpers as helpers +from openvino import preprocess as preprocess +from openvino import utils as utils +from openvino.runtime import properties as properties + +# Import most important classes and functions from openvino.runtime +from openvino.runtime import Model +from openvino.runtime import Core +from openvino.runtime import CompiledModel +from openvino.runtime import InferRequest +from openvino.runtime import AsyncInferQueue + +from openvino.runtime import Dimension +from openvino.runtime import Strides +from openvino.runtime import PartialShape +from openvino.runtime import Shape +from openvino.runtime import Layout +from openvino.runtime import Type +from openvino.runtime import Tensor +from openvino.runtime import OVAny + +from openvino.runtime import compile_model +from openvino.runtime import get_batch +from openvino.runtime import set_batch +from openvino.runtime import serialize +from openvino.runtime import shutdown +from openvino.runtime import tensor_from_file +from openvino.runtime import save_model +from openvino.runtime import layout_helpers + +# Set version for openvino package +from openvino.runtime import get_version +__version__ = get_version() # Tools try: diff --git a/src/bindings/python/src/openvino/__init__.py b/src/bindings/python/src/openvino/__init__.py index 90552e0befed68..b7dc434f3148cc 100644 --- a/src/bindings/python/src/openvino/__init__.py +++ b/src/bindings/python/src/openvino/__init__.py @@ -12,47 +12,47 @@ except ImportError: pass -# API 2.0 -try: - # Import all public modules - from openvino import runtime as runtime - from openvino import frontend as frontend - from openvino import helpers as helpers - from openvino import preprocess as preprocess - from openvino import utils as utils - from openvino.runtime import properties as properties - - # Import most important classes and functions from openvino.runtime - from openvino.runtime import Model - from openvino.runtime import Core - from openvino.runtime import CompiledModel - from openvino.runtime import InferRequest - from openvino.runtime import AsyncInferQueue - - from openvino.runtime import Dimension - from openvino.runtime import Strides - from openvino.runtime import PartialShape - from openvino.runtime import Shape - from openvino.runtime import Layout - from openvino.runtime import Type - from openvino.runtime import Tensor - from openvino.runtime import OVAny - - from openvino.runtime import compile_model - from openvino.runtime import get_batch - from openvino.runtime import set_batch - from openvino.runtime import serialize - from openvino.runtime import shutdown - from openvino.runtime import tensor_from_file - from openvino.runtime import save_model - from openvino.runtime import layout_helpers - - # Set version for openvino package - from openvino.runtime import get_version - __version__ = get_version() -except ImportError: - import warnings - warnings.warn("openvino package has problems with imports!", ImportWarning, stacklevel=2) +# # +# # API 2.0 +# # This __init__.py forces checking of runtime modules to propagate errors. +# # It is not compared with init files from openvino-dev package. +# # +# Import all public modules +from openvino import runtime as runtime +from openvino import frontend as frontend +from openvino import helpers as helpers +from openvino import preprocess as preprocess +from openvino import utils as utils +from openvino.runtime import properties as properties + +# Import most important classes and functions from openvino.runtime +from openvino.runtime import Model +from openvino.runtime import Core +from openvino.runtime import CompiledModel +from openvino.runtime import InferRequest +from openvino.runtime import AsyncInferQueue + +from openvino.runtime import Dimension +from openvino.runtime import Strides +from openvino.runtime import PartialShape +from openvino.runtime import Shape +from openvino.runtime import Layout +from openvino.runtime import Type +from openvino.runtime import Tensor +from openvino.runtime import OVAny + +from openvino.runtime import compile_model +from openvino.runtime import get_batch +from openvino.runtime import set_batch +from openvino.runtime import serialize +from openvino.runtime import shutdown +from openvino.runtime import tensor_from_file +from openvino.runtime import save_model +from openvino.runtime import layout_helpers + +# Set version for openvino package +from openvino.runtime import get_version +__version__ = get_version() # Tools try: diff --git a/tools/benchmark_tool/openvino/__init__.py b/tools/benchmark_tool/openvino/__init__.py index 90552e0befed68..b7dc434f3148cc 100644 --- a/tools/benchmark_tool/openvino/__init__.py +++ b/tools/benchmark_tool/openvino/__init__.py @@ -12,47 +12,47 @@ except ImportError: pass -# API 2.0 -try: - # Import all public modules - from openvino import runtime as runtime - from openvino import frontend as frontend - from openvino import helpers as helpers - from openvino import preprocess as preprocess - from openvino import utils as utils - from openvino.runtime import properties as properties - - # Import most important classes and functions from openvino.runtime - from openvino.runtime import Model - from openvino.runtime import Core - from openvino.runtime import CompiledModel - from openvino.runtime import InferRequest - from openvino.runtime import AsyncInferQueue - - from openvino.runtime import Dimension - from openvino.runtime import Strides - from openvino.runtime import PartialShape - from openvino.runtime import Shape - from openvino.runtime import Layout - from openvino.runtime import Type - from openvino.runtime import Tensor - from openvino.runtime import OVAny - - from openvino.runtime import compile_model - from openvino.runtime import get_batch - from openvino.runtime import set_batch - from openvino.runtime import serialize - from openvino.runtime import shutdown - from openvino.runtime import tensor_from_file - from openvino.runtime import save_model - from openvino.runtime import layout_helpers - - # Set version for openvino package - from openvino.runtime import get_version - __version__ = get_version() -except ImportError: - import warnings - warnings.warn("openvino package has problems with imports!", ImportWarning, stacklevel=2) +# # +# # API 2.0 +# # This __init__.py forces checking of runtime modules to propagate errors. +# # It is not compared with init files from openvino-dev package. +# # +# Import all public modules +from openvino import runtime as runtime +from openvino import frontend as frontend +from openvino import helpers as helpers +from openvino import preprocess as preprocess +from openvino import utils as utils +from openvino.runtime import properties as properties + +# Import most important classes and functions from openvino.runtime +from openvino.runtime import Model +from openvino.runtime import Core +from openvino.runtime import CompiledModel +from openvino.runtime import InferRequest +from openvino.runtime import AsyncInferQueue + +from openvino.runtime import Dimension +from openvino.runtime import Strides +from openvino.runtime import PartialShape +from openvino.runtime import Shape +from openvino.runtime import Layout +from openvino.runtime import Type +from openvino.runtime import Tensor +from openvino.runtime import OVAny + +from openvino.runtime import compile_model +from openvino.runtime import get_batch +from openvino.runtime import set_batch +from openvino.runtime import serialize +from openvino.runtime import shutdown +from openvino.runtime import tensor_from_file +from openvino.runtime import save_model +from openvino.runtime import layout_helpers + +# Set version for openvino package +from openvino.runtime import get_version +__version__ = get_version() # Tools try: diff --git a/tools/openvino_dev/CMakeLists.txt b/tools/openvino_dev/CMakeLists.txt index 12a24082a83a8e..494ac86c725acf 100644 --- a/tools/openvino_dev/CMakeLists.txt +++ b/tools/openvino_dev/CMakeLists.txt @@ -56,17 +56,8 @@ endforeach() # check __init__.py files alignment -function(ov_check_init_files_alignment) +function(ov_check_init_files_alignment init_files) # check the files in pairs - list(APPEND init_files - "${OpenVINO_SOURCE_DIR}/src/bindings/python/src/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/src/bindings/python/src/compatibility/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/mo/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/pot/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/ovc/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/benchmark_tool/openvino/__init__.py" - "${OpenVINO_SOURCE_DIR}/tools/openvino_dev/src/openvino/__init__.py") - list(LENGTH init_files init_files_count) math(EXPR file_loop_range "${init_files_count}-2") foreach(init_file_idx RANGE 0 ${file_loop_range}) @@ -78,14 +69,17 @@ function(ov_check_init_files_alignment) RESULT_VARIABLE compare_result ) if(compare_result EQUAL 1) - message(STATUS ${file1}) - message(STATUS ${file2}) - message(FATAL_ERROR "The __init__.py files are misaligned: ${file1} and ${file2}") + message(FATAL_ERROR "The tools __init__.py files are misaligned: ${file1} and ${file2}") endif() endforeach() endfunction() -ov_check_init_files_alignment() +set(INIT_FILES_TOOLS +"${OpenVINO_SOURCE_DIR}/tools/mo/openvino/__init__.py" +"${OpenVINO_SOURCE_DIR}/tools/pot/openvino/__init__.py" +"${OpenVINO_SOURCE_DIR}/tools/openvino_dev/src/openvino/__init__.py") + +ov_check_init_files_alignment("${INIT_FILES_TOOLS}") # openvino_dev build diff --git a/tools/ovc/openvino/__init__.py b/tools/ovc/openvino/__init__.py index 90552e0befed68..b7dc434f3148cc 100644 --- a/tools/ovc/openvino/__init__.py +++ b/tools/ovc/openvino/__init__.py @@ -12,47 +12,47 @@ except ImportError: pass -# API 2.0 -try: - # Import all public modules - from openvino import runtime as runtime - from openvino import frontend as frontend - from openvino import helpers as helpers - from openvino import preprocess as preprocess - from openvino import utils as utils - from openvino.runtime import properties as properties - - # Import most important classes and functions from openvino.runtime - from openvino.runtime import Model - from openvino.runtime import Core - from openvino.runtime import CompiledModel - from openvino.runtime import InferRequest - from openvino.runtime import AsyncInferQueue - - from openvino.runtime import Dimension - from openvino.runtime import Strides - from openvino.runtime import PartialShape - from openvino.runtime import Shape - from openvino.runtime import Layout - from openvino.runtime import Type - from openvino.runtime import Tensor - from openvino.runtime import OVAny - - from openvino.runtime import compile_model - from openvino.runtime import get_batch - from openvino.runtime import set_batch - from openvino.runtime import serialize - from openvino.runtime import shutdown - from openvino.runtime import tensor_from_file - from openvino.runtime import save_model - from openvino.runtime import layout_helpers - - # Set version for openvino package - from openvino.runtime import get_version - __version__ = get_version() -except ImportError: - import warnings - warnings.warn("openvino package has problems with imports!", ImportWarning, stacklevel=2) +# # +# # API 2.0 +# # This __init__.py forces checking of runtime modules to propagate errors. +# # It is not compared with init files from openvino-dev package. +# # +# Import all public modules +from openvino import runtime as runtime +from openvino import frontend as frontend +from openvino import helpers as helpers +from openvino import preprocess as preprocess +from openvino import utils as utils +from openvino.runtime import properties as properties + +# Import most important classes and functions from openvino.runtime +from openvino.runtime import Model +from openvino.runtime import Core +from openvino.runtime import CompiledModel +from openvino.runtime import InferRequest +from openvino.runtime import AsyncInferQueue + +from openvino.runtime import Dimension +from openvino.runtime import Strides +from openvino.runtime import PartialShape +from openvino.runtime import Shape +from openvino.runtime import Layout +from openvino.runtime import Type +from openvino.runtime import Tensor +from openvino.runtime import OVAny + +from openvino.runtime import compile_model +from openvino.runtime import get_batch +from openvino.runtime import set_batch +from openvino.runtime import serialize +from openvino.runtime import shutdown +from openvino.runtime import tensor_from_file +from openvino.runtime import save_model +from openvino.runtime import layout_helpers + +# Set version for openvino package +from openvino.runtime import get_version +__version__ = get_version() # Tools try: