* [Docs][PyOV] update python snippets * first snippet * Fix samples debug * Fix linter * part1 * Fix speech sample * update model state snippet * add serialize * add temp dir * CPU snippets update (#134) * snippets CPU 1/6 * snippets CPU 2/6 * snippets CPU 3/6 * snippets CPU 4/6 * snippets CPU 5/6 * snippets CPU 6/6 * make module TODO: REMEMBER ABOUT EXPORTING PYTONPATH ON CIs ETC * Add static model creation in snippets for CPU * export_comp_model done * leftovers * apply comments * apply comments -- properties * small fixes * rempve debug info * return IENetwork instead of Function * apply comments * revert precision change in common snippets * update opset * [PyOV] Edit docs for the rest of plugins (#136) * modify main.py * GNA snippets * GPU snippets * AUTO snippets * MULTI snippets * HETERO snippets * Added properties * update gna * more samples * Update docs/OV_Runtime_UG/model_state_intro.md * Update docs/OV_Runtime_UG/model_state_intro.md * attempt1 fix ci * new approach to test * temporary remove some files from run * revert cmake changes * fix ci * fix snippet * fix py_exclusive snippet * fix preprocessing snippet * clean-up main * remove numpy installation in gha * check for GPU * add logger * iexclude main * main update * temp * Temp2 * Temp2 * temp * Revert temp * add property execution devices * hide output from samples --------- Co-authored-by: p-wysocki <przemyslaw.wysocki@intel.com> Co-authored-by: Jan Iwaszkiewicz <jan.iwaszkiewicz@intel.com> Co-authored-by: Karol Blaszczak <karol.blaszczak@intel.com>
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
# Copyright (C) 2018-2023 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
import sys
|
|
import os
|
|
import io
|
|
import importlib
|
|
from contextlib import redirect_stdout, redirect_stderr
|
|
|
|
|
|
skip_snippets = ["main.py", "__init__.py", "utils.py", "ie_common.py", "ov_common.py"]
|
|
|
|
def import_python_modules(directory, subdirectory=""):
|
|
for item in os.listdir(directory):
|
|
if item.endswith('.py') and item not in skip_snippets:
|
|
imported_item = item[:-3]
|
|
if subdirectory != "":
|
|
imported_item=subdirectory + "." + imported_item
|
|
print(f"Snippet {item} is executing...")
|
|
with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()):
|
|
mod = importlib.import_module(imported_item)
|
|
|
|
try:
|
|
with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()):
|
|
mod.main()
|
|
except AttributeError as e:
|
|
pass
|
|
|
|
print(f"Snippet {item} succesfully executed.")
|
|
|
|
|
|
if os.path.isdir(os.path.join(directory, item)):
|
|
dir_path = os.path.join(directory, item)
|
|
import_python_modules(dir_path, item)
|
|
|
|
|
|
def main():
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
import_python_modules(dir_path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main() or 0)
|