Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Py OV] Remove imports of openvino.runtime from openvino module #27479

Closed
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
718a304
Add deprecation warning to runtime module __init__
almilosz Nov 4, 2024
c1efcfe
Update msg
almilosz Nov 4, 2024
453c6cb
Update msg
almilosz Nov 4, 2024
c5f2433
Comment out runtime import
almilosz Nov 7, 2024
546135d
Move *.py files up
almilosz Nov 7, 2024
46fa069
Add aliases for opset and fix imports in opsets
almilosz Nov 7, 2024
d9fd073
Move and add alias for exceptions
almilosz Nov 7, 2024
1b93b12
Add aliases for exceptions and utils
almilosz Nov 7, 2024
9bd8066
Update openvino/utils
almilosz Nov 7, 2024
9cd78da
Mv utils.py to ultils/__init__
almilosz Nov 7, 2024
f696c52
Update openvino/files
almilosz Nov 7, 2024
2e5a21a
Restore file structure in runtime/ and remove openvino/opsets/ dir
almilosz Nov 8, 2024
de844f3
Fix codestyle
almilosz Nov 8, 2024
0da0df9
Add empty lines
almilosz Nov 8, 2024
3adfe5c
Merge branch 'master' of https://github.com/openvinotoolkit/openvino …
almilosz Nov 12, 2024
55d8038
fixes after merge
almilosz Nov 12, 2024
e0c86e9
Add classes to ov.__init__
almilosz Nov 12, 2024
ffa6953
Merge branch 'master' into almilosz/ov-rt-deprecation-warn
almilosz Nov 12, 2024
037bcb0
fix linters
almilosz Nov 12, 2024
9142a63
change imports
almilosz Nov 13, 2024
bb03585
Import Node from _pyopenvino
almilosz Nov 14, 2024
b65f2d6
Update relative paths in _add_openvino_libs_to_search_path()
almilosz Nov 14, 2024
8d49825
Fix path for adding dll
almilosz Nov 14, 2024
dfa5172
Move _add_openvino_libs_to_search_path() up
almilosz Nov 14, 2024
fb52f7a
Move get_cmake_path
almilosz Nov 15, 2024
8f878e5
Remove aliases
almilosz Nov 15, 2024
1645918
Fix ie_api.Model import as attribute of openvino.runtime
almilosz Nov 15, 2024
05796c4
Update mo and openvino_dev __init__s
almilosz Nov 15, 2024
ea1f084
Merge branch 'master' into almilosz/ov-rt-deprecation-warn
almilosz Nov 18, 2024
83f4dde
Remove direct imports from _pyopenvino
almilosz Nov 18, 2024
6e857a1
remove circular import and update ovc
almilosz Nov 18, 2024
9141747
fix comment
almilosz Nov 18, 2024
e302e69
Remove direct imports from ie_api.py
almilosz Nov 19, 2024
82cce8e
Merge branch 'master' into almilosz/ov-rt-deprecation-warn
almilosz Nov 19, 2024
fa1416a
Replace .. with os.pardir
almilosz Nov 19, 2024
f05ff74
Rename build_utils.py to package_utils.py
almilosz Nov 19, 2024
3e91a36
Add LazyLoader for runtime
almilosz Nov 21, 2024
a2972ea
Load fixes
almilosz Nov 21, 2024
3f944ec
Rename openvino/ie_api.py to _ov_api.py
almilosz Nov 21, 2024
ff00a3d
Update tools/ovc
almilosz Nov 21, 2024
c07d4bd
remove warning
almilosz Nov 22, 2024
39fcfa6
Merge branch 'master' into almilosz/ov-rt-deprecation-warn
almilosz Nov 26, 2024
6cf7779
Merge branch 'master' into almilosz/ov-rt-deprecation-warn
almilosz Nov 27, 2024
ce8c32d
Revert changes to tools/ovc/openvino/
almilosz Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions src/bindings/python/src/openvino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# # 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 experimental as experimental
Expand All @@ -27,30 +26,30 @@
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.ie_api import Model
almilosz marked this conversation as resolved.
Show resolved Hide resolved
from openvino.ie_api import Core
from openvino.ie_api import CompiledModel
from openvino.ie_api import InferRequest
from openvino.ie_api import AsyncInferQueue

from openvino.runtime import Symbol
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._pyopenvino import Symbol
from openvino._pyopenvino import Dimension
from openvino._pyopenvino import Strides
from openvino._pyopenvino import PartialShape
from openvino._pyopenvino import Shape
from openvino._pyopenvino import Layout
from openvino._pyopenvino import Type
from openvino._pyopenvino import Tensor
from openvino._pyopenvino 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.ie_api import compile_model
from openvino._pyopenvino import get_batch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any logic why some API is in ie_api, while others in _pyopenvino ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,
the ones which are imported from .ie_api have python wrappers above original binded classes from ._pyopenvino.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but why then it's called ie_api ? better name is requried IMO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just legacy internal stuff :)
Ok, we will consider a better name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. _pyopenvino_legacy or _pyopenvino.legacy....

Copy link
Contributor

@akuporos akuporos Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mryzhov the name ie_api is legacy, the file itself contains pretty necessary and state-of-the-art code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to _ov_api.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name of openvino/runtime/ie.api.py shouldn't be renamed in case somebody is using it (even though it's internal)

from openvino._pyopenvino import set_batch
from openvino._pyopenvino import serialize
from openvino._pyopenvino import shutdown
from openvino.ie_api import tensor_from_file
from openvino._pyopenvino import save_model
from openvino._pyopenvino import layout_helpers

from openvino._pyopenvino import RemoteContext
from openvino._pyopenvino import RemoteTensor
Expand All @@ -61,7 +60,7 @@
from openvino._pyopenvino import VASurfaceTensor

# Set version for openvino package
from openvino.runtime import get_version
from openvino._pyopenvino import get_version
__version__ = get_version()

# Tools
Expand Down
17 changes: 17 additions & 0 deletions src/bindings/python/src/openvino/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

"""openvino exceptions hierarchy. All exceptions are descendants of OVError."""


class OVError(Exception):
"""Base class for OV exceptions."""


class UserInputError(OVError):
"""User provided unexpected input."""


class OVTypeError(OVError, TypeError):
"""Type mismatch error."""
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/frontend/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from openvino._pyopenvino import FrontEnd as FrontEndBase
from openvino._pyopenvino import FrontEndManager as FrontEndManagerBase
from openvino._pyopenvino import InputModel
from openvino.runtime import Model
from openvino.ie_api import Model


class FrontEnd(FrontEndBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import jax.core
from openvino.frontend.jax.py_jax_frontend import _FrontEndJaxDecoder as Decoder
from openvino.runtime import PartialShape, Type as OVType, OVAny
from openvino._pyopenvino import PartialShape, Type as OVType, OVAny
from openvino.frontend.jax.utils import jax_array_to_ov_const, get_ov_type_for_value, \
ivalue_to_constant, param_to_constants

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder
from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType
from openvino.runtime import PartialShape, Type as OVType, OVAny, Shape
from openvino._pyopenvino import PartialShape, Type as OVType, OVAny, Shape
from openvino.frontend.pytorch.utils import make_constant, fetch_attr, pt_to_ov_type_map, torch_tensor_to_ov_const

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from torch._decomp import decomposition_table, get_decompositions

from openvino.frontend import FrontEndManager
from openvino.runtime import Core, Type, PartialShape
from openvino.frontend.pytorch.ts_decoder import TorchScriptPythonDecoder
from openvino.frontend.pytorch.torchdynamo import decompositions
from openvino.frontend.pytorch.torchdynamo.decompositions import get_aot_decomposition_list, get_inf_decomposition_list
Expand All @@ -27,7 +26,6 @@
from openvino.frontend.pytorch.torchdynamo.compile import cached_model_name, openvino_compile_cached_model
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_model_caching, _get_decompositions, _get_aot_autograd

from openvino.runtime import Core, Type, PartialShape

logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# mypy: ignore-errors

from typing import Optional, Any
from openvino.runtime import Core
from openvino.ie_api import Core


def _get_device(options) -> Optional[Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

from openvino.frontend import FrontEndManager
from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder
from openvino.runtime import Core, Type, PartialShape, serialize
from openvino.ie_api import Core
from openvino._pyopenvino import Type, PartialShape, serialize
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_config, _is_cache_dir_in_config

from typing import Callable, Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from openvino.frontend.pytorch.fx_decoder import TorchFXPythonDecoder
from openvino.frontend.pytorch.torchdynamo.partition import Partitioner
from openvino.frontend.pytorch.torchdynamo.compile import openvino_compile
from openvino.runtime import Core, Type, PartialShape
from openvino.ie_api import Core
from openvino._pyopenvino import Type, PartialShape
from openvino.frontend.pytorch.torchdynamo.backend_utils import _get_cache_dir, _get_device, _get_aot_autograd

from typing import Callable, Optional, Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from openvino.frontend.pytorch.py_pytorch_frontend import _FrontEndPytorchDecoder as Decoder
from openvino.frontend.pytorch.py_pytorch_frontend import _Type as DecoderType
from openvino.runtime import op, PartialShape, Type as OVType, OVAny
from openvino._pyopenvino import op, PartialShape, Type as OVType, OVAny
from openvino.frontend.pytorch.utils import (
ivalue_to_constant,
get_value_from_getattr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import tensorflow as tf
from openvino.frontend.tensorflow.py_tensorflow_frontend import _FrontEndDecoderBase as DecoderBase
from openvino.runtime import PartialShape, Type, OVAny, Tensor
from openvino._pyopenvino import PartialShape, Type, OVAny, Tensor
almilosz marked this conversation as resolved.
Show resolved Hide resolved


def tf_type_to_ov_type(tf_type_int):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging as log
import numpy as np
import sys
from openvino.runtime import PartialShape, Dimension, Type
from openvino._pyopenvino import PartialShape, Dimension, Type
from packaging.version import parse, Version
from typing import List, Dict, Union

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/src/openvino/helpers/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
from typing import Union
from openvino.runtime import Type, Shape
from openvino._pyopenvino import Type, Shape


def pack_data(array: np.ndarray, type: Type) -> np.ndarray:
Expand Down
Loading
Loading