From f7908858d7f945e26892cb24edd7dac8e6c003a6 Mon Sep 17 00:00:00 2001
From: Alicja Miloszewska <alicja.miloszewska@intel.com>
Date: Fri, 13 Dec 2024 17:46:52 +0100
Subject: [PATCH] [Py OV] Move ie_api.py and exceptions.py files to openvino
 module (#28007)

### Details:
- move `runtime/ie_api.py` and rename it to `_ov_api.py` as ie_api is a
legacy name.
- add `runtime/ie_apy/__init__.py` as proxy
- update `openvino/__init__` to import from `_ov_api.py`.

- move `runtime/exceptions.py` and add proxy in `runtime`
- update `test_ovdict` to use `OVDict` defined in
`openvino.runtime.utils.data_helpers`
- update `tensor_from_file` import in `openvino/__init__.py`. This
function is located in `openvino.runtime.utils.data_helpers`

Part of `openvino.runtime` deprecation

### Tickets:
 - [CVS-129459](https://jira.devtools.intel.com/browse/CVS-129459)

---------

Signed-off-by: Alicja Miloszewska <alicja.miloszewska@intel.com>
---
 src/bindings/python/src/openvino/__init__.py      | 15 ++++++++-------
 .../openvino/{runtime/ie_api.py => _ov_api.py}    |  0
 .../src/openvino/{runtime => }/exceptions.py      |  0
 src/bindings/python/src/openvino/opset8/ops.py    |  2 +-
 .../src/openvino/runtime/exceptions/__init__.py   |  7 +++++++
 .../src/openvino/runtime/ie_api/__init__.py       | 12 ++++++++++++
 .../python/tests/test_runtime/test_ovdict.py      |  2 +-
 tools/benchmark_tool/openvino/__init__.py         | 15 ++++++++-------
 tools/ovc/openvino/__init__.py                    | 15 ++++++++-------
 9 files changed, 45 insertions(+), 23 deletions(-)
 rename src/bindings/python/src/openvino/{runtime/ie_api.py => _ov_api.py} (100%)
 rename src/bindings/python/src/openvino/{runtime => }/exceptions.py (100%)
 create mode 100644 src/bindings/python/src/openvino/runtime/exceptions/__init__.py
 create mode 100644 src/bindings/python/src/openvino/runtime/ie_api/__init__.py

diff --git a/src/bindings/python/src/openvino/__init__.py b/src/bindings/python/src/openvino/__init__.py
index e4d1a247520332..69c678909b1c9e 100644
--- a/src/bindings/python/src/openvino/__init__.py
+++ b/src/bindings/python/src/openvino/__init__.py
@@ -27,11 +27,11 @@
 from openvino 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._ov_api import Model
+from openvino._ov_api import Core
+from openvino._ov_api import CompiledModel
+from openvino._ov_api import InferRequest
+from openvino._ov_api import AsyncInferQueue
 
 from openvino.runtime import Symbol
 from openvino.runtime import Dimension
@@ -43,12 +43,13 @@
 from openvino.runtime import Tensor
 from openvino.runtime import OVAny
 
-from openvino.runtime import compile_model
+# Helper functions for openvino module
+from openvino.runtime.utils.data_helpers import tensor_from_file
+from openvino._ov_api 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
 
diff --git a/src/bindings/python/src/openvino/runtime/ie_api.py b/src/bindings/python/src/openvino/_ov_api.py
similarity index 100%
rename from src/bindings/python/src/openvino/runtime/ie_api.py
rename to src/bindings/python/src/openvino/_ov_api.py
diff --git a/src/bindings/python/src/openvino/runtime/exceptions.py b/src/bindings/python/src/openvino/exceptions.py
similarity index 100%
rename from src/bindings/python/src/openvino/runtime/exceptions.py
rename to src/bindings/python/src/openvino/exceptions.py
diff --git a/src/bindings/python/src/openvino/opset8/ops.py b/src/bindings/python/src/openvino/opset8/ops.py
index 05b97390baa780..6995d55a28a776 100644
--- a/src/bindings/python/src/openvino/opset8/ops.py
+++ b/src/bindings/python/src/openvino/opset8/ops.py
@@ -7,7 +7,7 @@
 from typing import List, Optional, Tuple
 
 import numpy as np
-from openvino.runtime.exceptions import UserInputError
+from openvino.exceptions import UserInputError
 from openvino.op import Constant, Parameter, if_op
 from openvino.runtime import Node
 from openvino.runtime.opset_utils import _get_node_factory
diff --git a/src/bindings/python/src/openvino/runtime/exceptions/__init__.py b/src/bindings/python/src/openvino/runtime/exceptions/__init__.py
new file mode 100644
index 00000000000000..18524a21f7d468
--- /dev/null
+++ b/src/bindings/python/src/openvino/runtime/exceptions/__init__.py
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2018-2024 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+from openvino.exceptions import OVError
+from openvino.exceptions import UserInputError
+from openvino.exceptions import OVTypeError
diff --git a/src/bindings/python/src/openvino/runtime/ie_api/__init__.py b/src/bindings/python/src/openvino/runtime/ie_api/__init__.py
new file mode 100644
index 00000000000000..a861224b67eded
--- /dev/null
+++ b/src/bindings/python/src/openvino/runtime/ie_api/__init__.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# Copyright (C) 2018-2024 Intel Corporation
+# SPDX-License-Identifier: Apache-2.0
+
+from openvino._ov_api import Core
+from openvino._ov_api import CompiledModel
+from openvino._ov_api import InferRequest
+from openvino._ov_api import Model
+from openvino._ov_api import AsyncInferQueue
+
+from openvino._ov_api import tensor_from_file
+from openvino._ov_api import compile_model
diff --git a/src/bindings/python/tests/test_runtime/test_ovdict.py b/src/bindings/python/tests/test_runtime/test_ovdict.py
index e7a5854d66d072..cf332bb0997dfb 100644
--- a/src/bindings/python/tests/test_runtime/test_ovdict.py
+++ b/src/bindings/python/tests/test_runtime/test_ovdict.py
@@ -9,7 +9,7 @@
 import openvino.runtime.opset13 as ops
 from openvino import Core, CompiledModel, InferRequest, Model
 from openvino.runtime import ConstOutput
-from openvino.runtime.ie_api import OVDict
+from openvino.runtime.utils.data_helpers import OVDict
 
 
 def _get_ovdict(
diff --git a/tools/benchmark_tool/openvino/__init__.py b/tools/benchmark_tool/openvino/__init__.py
index e4d1a247520332..69c678909b1c9e 100644
--- a/tools/benchmark_tool/openvino/__init__.py
+++ b/tools/benchmark_tool/openvino/__init__.py
@@ -27,11 +27,11 @@
 from openvino 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._ov_api import Model
+from openvino._ov_api import Core
+from openvino._ov_api import CompiledModel
+from openvino._ov_api import InferRequest
+from openvino._ov_api import AsyncInferQueue
 
 from openvino.runtime import Symbol
 from openvino.runtime import Dimension
@@ -43,12 +43,13 @@
 from openvino.runtime import Tensor
 from openvino.runtime import OVAny
 
-from openvino.runtime import compile_model
+# Helper functions for openvino module
+from openvino.runtime.utils.data_helpers import tensor_from_file
+from openvino._ov_api 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
 
diff --git a/tools/ovc/openvino/__init__.py b/tools/ovc/openvino/__init__.py
index e4d1a247520332..69c678909b1c9e 100644
--- a/tools/ovc/openvino/__init__.py
+++ b/tools/ovc/openvino/__init__.py
@@ -27,11 +27,11 @@
 from openvino 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._ov_api import Model
+from openvino._ov_api import Core
+from openvino._ov_api import CompiledModel
+from openvino._ov_api import InferRequest
+from openvino._ov_api import AsyncInferQueue
 
 from openvino.runtime import Symbol
 from openvino.runtime import Dimension
@@ -43,12 +43,13 @@
 from openvino.runtime import Tensor
 from openvino.runtime import OVAny
 
-from openvino.runtime import compile_model
+# Helper functions for openvino module
+from openvino.runtime.utils.data_helpers import tensor_from_file
+from openvino._ov_api 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