-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Py OV] Change approach to openvino.runtime lazy loading (#29053)
### Details: - In current approach for lazy import, we use `importlib.util.LazyLoader`. This approach first creates a module, adds it to python `sys.module`s, and then LazyLoader executes the module when sb tries to access e.g. `openvino.runtime` attribute. - The issue is that in this approach `openvino.runtime` might be initialized too early, e.g. by [`inspect` module](https://github.com/python/cpython/blob/140e69c4a878d7a0a26d4406bdad55e56ddae0b7/Lib/inspect.py#L915) which iterates over modules present in `sys.modules`, e.g.:  Proposal: - Change the lazy loading approach. Import `openvino.runtime` and add it to `sys.modules` only when an attribute is accessed. Possible thanks to overloading `__getattr__` and `__dir__` methods.  ### Tickets: - *ticket-id* --------- Signed-off-by: Alicja Miloszewska <alicja.miloszewska@intel.com>
- Loading branch information
Showing
4 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters