Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[OVC] Update imports (#28356)

Anastasia Kuporosovaa6ea83404178
diff --git a/tools/ovc/openvino/tools/ovc/cli_parser.py b/tools/ovc/openvino/tools/ovc/cli_parser.py
index 48a396c508b..6163658f00e 100644
--- a/tools/ovc/openvino/tools/ovc/cli_parser.py
+++ b/tools/ovc/openvino/tools/ovc/cli_parser.py
@@ -10,7 +10,7 @@ from collections import OrderedDict, namedtuple
from typing import List, Union
import openvino
-from openvino.runtime import PartialShape, Dimension, Type # pylint: disable=no-name-in-module,import-error
+from openvino import PartialShape, Dimension, Type # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.error import Error
from openvino.tools.ovc.help import get_convert_model_help_specifics
from openvino.tools.ovc.moc_frontend.shape_utils import to_partial_shape, is_shape_type
diff --git a/tools/ovc/openvino/tools/ovc/convert.py b/tools/ovc/openvino/tools/ovc/convert.py
index 1bd61ff567e..9aa6d363598 100644
--- a/tools/ovc/openvino/tools/ovc/convert.py
+++ b/tools/ovc/openvino/tools/ovc/convert.py
@@ -4,7 +4,7 @@
import pathlib
from typing import Any
-from openvino.runtime import Model # pylint: disable=no-name-in-module,import-error
+from openvino import Model # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.cli_parser import get_all_cli_parser
from openvino.tools.ovc.convert_impl import _convert
from openvino.tools.ovc.logger import get_logger_state, restore_logger_state
@@ -97,7 +97,7 @@ def convert_model(
are reused for weights in the converted model.
Returns:
- openvino.runtime.Model
+ openvino.Model
"""
params = locals()
logger_state = get_logger_state()
diff --git a/tools/ovc/openvino/tools/ovc/convert_impl.py b/tools/ovc/openvino/tools/ovc/convert_impl.py
index c690df9d4a0..0c01145533e 100644
--- a/tools/ovc/openvino/tools/ovc/convert_impl.py
+++ b/tools/ovc/openvino/tools/ovc/convert_impl.py
@@ -44,8 +44,8 @@ except:
# pylint: disable=no-name-in-module,import-error
from openvino.frontend import FrontEndManager, OpConversionFailure, TelemetryExtension
-from openvino.runtime import get_version as get_rt_version
-from openvino.runtime import PartialShape
+from openvino import get_version as get_rt_version
+from openvino import PartialShape
try:
from openvino.frontend.tensorflow.utils import create_tf_graph_iterator, type_supported_by_tf_fe, \
diff --git a/tools/ovc/openvino/tools/ovc/main.py b/tools/ovc/openvino/tools/ovc/main.py
index 1118999dcd5..762ecb258f0 100644
--- a/tools/ovc/openvino/tools/ovc/main.py
+++ b/tools/ovc/openvino/tools/ovc/main.py
@@ -17,7 +17,7 @@ from openvino.tools.ovc.utils import import_openvino_tokenizers
import_openvino_tokenizers()
# pylint: disable=no-name-in-module,import-error
-from openvino.runtime import save_model
+from openvino import save_model
def main():
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/analysis.py b/tools/ovc/openvino/tools/ovc/moc_frontend/analysis.py
index 827a8e4338a..c4b40f3c062 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/analysis.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/analysis.py
@@ -3,8 +3,8 @@
import json
-from openvino.runtime import PartialShape, Model, Type # pylint: disable=no-name-in-module,import-error
-from openvino.runtime.utils.types import get_dtype # pylint: disable=no-name-in-module,import-error
+from openvino import PartialShape, Model, Type # pylint: disable=no-name-in-module,import-error
+from openvino.utils.types import get_dtype # pylint: disable=no-name-in-module,import-error
def json_model_analysis_dump(framework_model: Model):
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py b/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py
index 3693a54230f..344d5f70e81 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/extractor.py
@@ -368,7 +368,7 @@ def convert_params_lists_to_dicts(input_model,
"""
Convert lists of unnamed params to dicts using input names from input_model.
- :param input_model: openvino.runtime.InputModel
+ :param input_model: openvino.InputModel
:param input_user_shapes: list of input shapes or dictionary where key is input name, value is input shape from user.
:param input_user_data_types: list of input types or dictionary where key is input name, value is input type from user.
@@ -377,7 +377,7 @@ def convert_params_lists_to_dicts(input_model,
input_user_data_types_dict - dictionary where key is input name, value is type from user;
freeze_placeholder - dictionary where key is input name, value is input value from user;
"""
- from openvino.runtime import PartialShape # pylint: disable=no-name-in-module,import-error
+ from openvino import PartialShape # pylint: disable=no-name-in-module,import-error
model_inputs = input_model.get_inputs()
input_user_data_types_dict = {}
input_user_shapes_dict = {}
@@ -396,7 +396,7 @@ def convert_params_lists_to_dicts(input_model,
# input_user_data_types is list only if unnamed inputs were used
if isinstance(input_user_data_types, list):
- from openvino.runtime import Type # pylint: disable=no-name-in-module,import-error
+ from openvino import Type # pylint: disable=no-name-in-module,import-error
if input_user_shapes_dict is None:
input_user_shapes_dict = {}
@@ -404,7 +404,7 @@ def convert_params_lists_to_dicts(input_model,
# this cycle adds each unnamed type to dictionary using name from model_inputs
for idx, node_type in enumerate(input_user_data_types):
assert isinstance(node_type, (type, np.dtype, Type)), "Got incorrect format of input types. " \
- "Expected numpy type or openvino.runtime.Type, " \
+ "Expected numpy type or openvino.Type, " \
"got {}.".format(type(node_type))
inp_name = find_first_unused_input(model_inputs, input_user_data_types_dict, "type")
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py
index 68c4406622f..62d85d18d0d 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/layout_utils.py
@@ -3,7 +3,7 @@
from typing import Callable
-from openvino.runtime import PartialShape # pylint: disable=no-name-in-module,import-error
+from openvino import PartialShape # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.error import Error
from openvino.tools.ovc.utils import refer_to_faq_msg
@@ -62,7 +62,7 @@ def get_dimension_index_by_label(input_shape: PartialShape, input_names: list, l
layout = layout_value.get('source_layout', None)
if layout is None:
return default_dim, True
- from openvino.runtime import Layout # pylint: disable=no-name-in-module,import-error
+ from openvino import Layout # pylint: disable=no-name-in-module,import-error
layout_parsed = Layout(layout)
if layout_parsed.has_name(dimension_label):
return layout_parsed.get_index_by_name(dimension_label), False
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/moc_emit_ir.py b/tools/ovc/openvino/tools/ovc/moc_frontend/moc_emit_ir.py
index 9e8e2507dea..b786a59b02a 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/moc_emit_ir.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/moc_emit_ir.py
@@ -3,7 +3,7 @@
import argparse
-from openvino.runtime import Model # pylint: disable=no-name-in-module,import-error
+from openvino import Model # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.moc_frontend.preprocessing import apply_preprocessing
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py b/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py
index 9b7ea2bbf35..2e85d44e21f 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/offline_transformations.py
@@ -78,7 +78,7 @@ def get_available_transformations():
return {}
-# net should be openvino.runtime.Model type, but OV Engine is still optional dependency
+# net should be openvino.Model type, but OV Engine is still optional dependency
def apply_user_transformations(func: object, transforms: list):
available_transformations = get_available_transformations()
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py
index 4a297707a0e..58cc07ed5dc 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pipeline.py
@@ -11,8 +11,8 @@ import os
from openvino.frontend import FrontEnd, InputModel, NotImplementedFailure, \
Place # pylint: disable=no-name-in-module,import-error
-from openvino.runtime import PartialShape, Type # pylint: disable=no-name-in-module,import-error
-from openvino.runtime.utils.types import get_element_type, \
+from openvino import PartialShape, Type # pylint: disable=no-name-in-module,import-error
+from openvino.utils.types import get_element_type, \
get_numpy_ctype # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.moc_frontend.analysis import json_model_analysis_dump
from openvino.tools.ovc.moc_frontend.extractor import fe_user_data_repack, convert_params_lists_to_dicts, \
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/preprocessing.py b/tools/ovc/openvino/tools/ovc/moc_frontend/preprocessing.py
index 0195960065d..a182cfa7f44 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/preprocessing.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/preprocessing.py
@@ -6,7 +6,7 @@ import logging as log
from openvino.preprocess import PrePostProcessor # pylint: disable=no-name-in-module,import-error
# pylint: disable=no-name-in-module,import-error
-from openvino.runtime import Model, Layout, PartialShape
+from openvino import Model, Layout, PartialShape
from openvino.tools.ovc.error import Error
from openvino.tools.ovc.moc_frontend.layout_utils import update_layout_to_dict
from openvino.tools.ovc.utils import refer_to_faq_msg
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py
index 486f72d87fd..830a066562a 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py
@@ -8,7 +8,7 @@ import sys
import numpy as np
# pylint: disable=no-name-in-module,import-error
-from openvino.runtime import Tensor, PartialShape
+from openvino import Tensor, PartialShape
from openvino.tools.ovc.cli_parser import single_input_to_input_cut_info, _InputCutInfo
from openvino.tools.ovc.error import Error
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py
index 739f0f53b0e..9145fad3b1b 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py
@@ -4,7 +4,7 @@
import sys
import numpy as np
-from openvino.runtime import Shape, PartialShape, Dimension # pylint: disable=no-name-in-module,import-error
+from openvino import Shape, PartialShape, Dimension # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.error import Error
diff --git a/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py b/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py
index b7f7c8b0abc..50a3ffdc3e9 100644
--- a/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py
+++ b/tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py
@@ -6,7 +6,7 @@ import sys
import numpy as np
import openvino as ov
-from openvino.runtime import Type
+from openvino import Type
def is_type(val):
diff --git a/tools/ovc/openvino/tools/ovc/telemetry_utils.py b/tools/ovc/openvino/tools/ovc/telemetry_utils.py
index f68a92be5d2..98769357d69 100644
--- a/tools/ovc/openvino/tools/ovc/telemetry_utils.py
+++ b/tools/ovc/openvino/tools/ovc/telemetry_utils.py
@@ -4,7 +4,7 @@
import argparse
import numbers
import os
-from openvino.runtime import get_version as get_rt_version # pylint: disable=no-name-in-module,import-error
+from openvino import get_version as get_rt_version # pylint: disable=no-name-in-module,import-error
from openvino.tools.ovc.cli_parser import get_params_with_paths_list
from openvino.tools.ovc.telemetry_params import telemetry_params
from openvino.tools.ovc.utils import check_values_equal
@@ -95,7 +95,7 @@ def send_conversion_result(conversion_result: str, need_shutdown=False):
def arg_to_str(arg):
# This method converts to string only known types, otherwise returns string with name of the type
- from openvino.runtime import PartialShape, Shape, Type, Layout # pylint: disable=no-name-in-module,import-error
+ from openvino import PartialShape, Shape, Type, Layout # pylint: disable=no-name-in-module,import-error
if isinstance(arg, (PartialShape, Shape, Type, Layout)):
return str(arg)
if isinstance(arg, (str, numbers.Number, bool)):
diff --git a/tools/ovc/openvino/tools/ovc/version.py b/tools/ovc/openvino/tools/ovc/version.py
index 34e0128af92..f7509efa7ab 100644
--- a/tools/ovc/openvino/tools/ovc/version.py
+++ b/tools/ovc/openvino/tools/ovc/version.py
@@ -3,7 +3,7 @@
import re
-from openvino.runtime import get_version as get_ie_version # pylint: disable=no-name-in-module,import-error
+from openvino import get_version as get_ie_version # pylint: disable=no-name-in-module,import-error
def extract_release_version(version: str):
@@ -29,7 +29,7 @@ def simplify_version(version: str):
def get_simplified_ie_version(version=None):
- from openvino.runtime import get_version # pylint: disable=no-name-in-module,import-error
+ from openvino import get_version # pylint: disable=no-name-in-module,import-error
if version is None:
version = get_version()
diff --git a/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py b/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py
index dc29b439b61..f10b5d32209 100644
--- a/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py
+++ b/tools/ovc/unit_tests/moc_tf_fe/conversion_basic_models_test.py
@@ -4,7 +4,7 @@
import numpy as np
import os
import pytest
-from openvino.runtime import Core
+from openvino import Core
from openvino.tools.ovc.convert import convert_model
diff --git a/tools/ovc/unit_tests/moc_tf_fe/utils.py b/tools/ovc/unit_tests/moc_tf_fe/utils.py
index f68c3ef0559..78fa88d26f5 100644
--- a/tools/ovc/unit_tests/moc_tf_fe/utils.py
+++ b/tools/ovc/unit_tests/moc_tf_fe/utils.py
@@ -5,7 +5,7 @@ import os
import numpy as np
-from openvino.runtime import Core
+from openvino import Core
from openvino.tools.ovc.convert import convert_model
diff --git a/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py b/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py
index 526942ccf71..1b7ddcc675f 100644
--- a/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py
+++ b/tools/ovc/unit_tests/ovc/convert/import_from_mo_test.py
@@ -3,7 +3,7 @@
import os
import tempfile
-from openvino.runtime import serialize
+from openvino import serialize
from pathlib import Path
from unit_tests.ovc.convert.utils import create_onnx_model, save_to_onnx
from unit_tests.ovc.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
diff --git a/tools/ovc/unit_tests/ovc/convert/meta_data_test.py b/tools/ovc/unit_tests/ovc/convert/meta_data_test.py
index d28afb507d3..cf10d217523 100644
--- a/tools/ovc/unit_tests/ovc/convert/meta_data_test.py
+++ b/tools/ovc/unit_tests/ovc/convert/meta_data_test.py
@@ -3,8 +3,8 @@
import os
import tempfile
-from openvino.runtime import get_version as get_rt_version
-from openvino.runtime import serialize
+from openvino import get_version as get_rt_version
+from openvino import serialize
from openvino.tools.ovc import convert_model
from pathlib import Path
from unit_tests.ovc.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
diff --git a/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py b/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py
index 337853942d8..0413b3467c7 100644
--- a/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py
+++ b/tools/ovc/unit_tests/ovc/convert/meta_data_test_actual.py
@@ -6,8 +6,8 @@ import tempfile
import unittest
from pathlib import Path
-from openvino.runtime import get_version as get_rt_version
-from openvino.runtime import serialize, convert_model
+from openvino import get_version as get_rt_version
+from openvino import serialize, convert_model
from openvino.tools.mo.utils.ir_reader.restore_graph import restore_graph_from_ir, save_restored_graph
@@ -74,7 +74,7 @@ class MetaDataTestTF(unittest.TestCase):
serialize(ov_model, out_xml.encode('utf-8'), out_xml.replace('.xml', '.bin').encode('utf-8'))
- from openvino.runtime import Core
+ from openvino import Core
core = Core()
deserialized_model = core.read_model(out_xml)
self.check_meta_data(deserialized_model, ref_meta)
diff --git a/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py b/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py
index 735acf6544d..9eab60dcdab 100644
--- a/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py
+++ b/tools/ovc/unit_tests/ovc/utils/cli_parser_test.py
@@ -7,8 +7,8 @@ import shutil
import tempfile
import unittest
-import openvino.runtime as ov
-from openvino.runtime import PartialShape
+import openvino as ov
+from openvino import PartialShape
from openvino.tools.ovc.cli_parser import _InputCutInfo
from openvino.tools.ovc.cli_parser import input_to_input_cut_info, \