[PyOV] Propagate errors on imports from runtime module (#20273)

Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
This commit is contained in:
Jan Iwaszkiewicz 2023-10-11 09:53:34 +02:00 committed by GitHub
parent 346893fe6f
commit 6a326455b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 165 additions and 174 deletions

View File

@ -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})

View File

@ -12,47 +12,47 @@ try:
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
# #
# # 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
# 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 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
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)
# Set version for openvino package
from openvino.runtime import get_version
__version__ = get_version()
# Tools
try:

View File

@ -12,47 +12,47 @@ try:
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
# #
# # 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
# 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 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
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)
# Set version for openvino package
from openvino.runtime import get_version
__version__ = get_version()
# Tools
try:

View File

@ -12,47 +12,47 @@ try:
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
# #
# # 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
# 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 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
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)
# Set version for openvino package
from openvino.runtime import get_version
__version__ = get_version()
# Tools
try:

View File

@ -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

View File

@ -12,47 +12,47 @@ try:
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
# #
# # 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
# 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 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
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)
# Set version for openvino package
from openvino.runtime import get_version
__version__ = get_version()
# Tools
try: