[Python API] Move old python bindings (#9134)

* [Python API] Remove offline transformations from old python api

* [Python API] Move wheel folder to the python dir

* codestyle files

* [Python API] Move old python bindings

* move api

* one more codestyle

* fix install stage

* remove unexisting file from gitignore

* flake8 style

* try to fix jenkins

* undo comments

* return variable

* remove cpack

* fix after merge

* try to fix version

* fix test

* remove debug info

* version of python

* try to fix pyversion

* update tests

Co-authored-by: Alexander Zhogov <alexander.zhogov@intel.com>
This commit is contained in:
Anastasia KuporosovaandAlexander Zhogov authored and GitHub committed 2022-01-24 13:16:07 +03:00
1 parent 40b4356537
commit a8b59458d1
48 files changed
+98 -183

No files matched your search

+3 -3
View File
@@ -112,10 +112,10 @@ jobs:
sudo apt --assume-yes install openjdk-11-jdk
# For opencv-python: python3-setuptools and pip upgrade
python3 -m pip install --upgrade pip
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/requirements.txt
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/wheel/requirements-dev.txt
# For running Python API tests
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/src/requirements-dev.txt
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements-dev.txt
# For running Paddle frontend unit tests
python3 -m pip install -r $(REPO_DIR)/src/core/tests/frontend/paddle/requirements_dev.txt
# For running ONNX frontend unit tests
@@ -344,7 +344,7 @@ jobs:
- script: |
export DATA_PATH=$(MODELS_PATH)
export MODELS_PATH=$(MODELS_PATH)
cd $(REPO_DIR)/inference-engine/ie_bridges/python/tests
cd $(REPO_DIR)/src/bindings/python/tests_compatibility/test_inference_engine
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml $(PYTHON_STATIC_ARGS)
displayName: 'Python API Tests'
continueOnError: false
+1 -1
View File
@@ -63,7 +63,7 @@ jobs:
- script: |
set -e
$(REPO_DIR)/install_build_dependencies.sh
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/requirements.txt
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt
# Speed up build
wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip
unzip ninja-linux.zip
+2 -2
View File
@@ -73,9 +73,9 @@ jobs:
set -e
$(REPO_DIR)/install_build_dependencies.sh
python3 -m pip install --upgrade pip
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/requirements.txt
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements.txt
# For running Python API tests
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/src/requirements-dev.txt
python3 -m pip install -r $(REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements-dev.txt
# Speed up build
wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip
unzip ninja-linux.zip
+2 -2
View File
@@ -108,8 +108,8 @@ jobs:
- script: |
python -m pip install --upgrade pip
rem For running Python API tests
python -m pip install -r $(REPO_DIR)\inference-engine\ie_bridges\python\src\requirements-dev.txt
python -m pip install -r $(REPO_DIR)\inference-engine\ie_bridges\python\wheel\requirements-dev.txt
python -m pip install -r $(REPO_DIR)\src\bindings\python\src\compatibility\openvino\requirements-dev.txt
python -m pip install -r $(REPO_DIR)\src\bindings\python\wheel\requirements-dev.txt
rem For running Paddle frontend unit tests
python -m pip install -r $(REPO_DIR)\src\core\tests\frontend\paddle\requirements_dev.txt
rem For running ONNX frontend unit tests
+3 -3
View File
@@ -19,9 +19,9 @@ jobs:
sudo apt update
sudo apt --assume-yes install libusb-1.0-0-dev
python3 -m pip install --upgrade pip
python3 -m pip install -r ./inference-engine/ie_bridges/python/requirements.txt
python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements.txt
# Add for -DENABLE_PYTHON=ON, no cython
python3 -m pip install -r ./inference-engine/ie_bridges/python/src/requirements-dev.txt
python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements-dev.txt
# Run cmake with -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT in order to enable codestyle check for ITT collector
- name: CMake
@@ -60,7 +60,7 @@ jobs:
sudo apt --assume-yes install shellcheck
- name: Install dependencies
run: python3 -m pip install -r ./inference-engine/ie_bridges/python/requirements.txt
run: python3 -m pip install -r ./src/bindings/python/src/compatibility/openvino/requirements.txt
- name: CMake
run: |
+8 -8
View File
@@ -4,11 +4,11 @@ on:
workflow_dispatch:
push:
paths:
- 'inference-engine/ie_bridges/python/**'
- 'src/bindings/python/**'
- 'samples/python/**'
pull_request:
paths:
- 'inference-engine/ie_bridges/python/**'
- 'src/bindings/python/**'
- 'samples/python/**'
jobs:
linters:
@@ -23,7 +23,7 @@ jobs:
with:
python-version: '3.6'
- name: Install dependencies
run: python -m pip install -r inference-engine/ie_bridges/python/requirements_dev.txt
run: python -m pip install -r src/bindings/python/src/compatibility/openvino/requirements_dev.txt
- name: Run Flake on samples
run: python -m flake8 ./ --config=setup.cfg
working-directory: samples/python
@@ -39,14 +39,14 @@ jobs:
name: samples_diff
path: samples_diff.diff
- name: Run Flake on src
run: python -m flake8 ./ --config=../setup.cfg
working-directory: inference-engine/ie_bridges/python/src
run: python -m flake8 ./ --config=setup.cfg
working-directory: src/bindings/python/src/compatibility/openvino
- name: Create code style diff for Python src
if: failure()
run: |
python -m black -l 160 -S ./
git diff > src_diff.diff
working-directory: inference-engine/ie_bridges/python/src
working-directory: src/bindings/python/src/compatibility/openvino
- uses: actions/upload-artifact@v2
if: failure()
with:
@@ -69,9 +69,9 @@ jobs:
- name: Run MyPy
run: python -m mypy ./ --config-file ./setup.cfg
working-directory: inference-engine/ie_bridges/python
working-directory: src/bindings/python/src/compatibility/openvino
- name: Run Bandit
run: python -m bandit -r ./ -f screen
working-directory: inference-engine/ie_bridges/python
working-directory: src/bindings/python/src/compatibility/openvino
-1
View File
@@ -28,7 +28,6 @@ temp/
docs/template_plugin/html/
CMakeLists.txt.user
docs/IE_PLUGIN_DG/html/
inference-engine/ie_bridges/python/wheel/.env
*.project
*.cproject
+1 -1
View File
@@ -29,7 +29,7 @@ Jenkinsfile @openvinotoolkit/openvino-admins
# IE Core:
/inference-engine/ @openvinotoolkit/openvino-ie-maintainers
/inference-engine/ie_bridges/python @openvinotoolkit/openvino-ie-python-api-maintainers
/src/bindings/python/ @openvinotoolkit/openvino-ie-python-api-maintainers
/src/common/transformations/ @GlebKazantaev @ilyachur
/src/common/legacy/ @openvinotoolkit/openvino-ngraph-maintainers
/src/common/ @openvinotoolkit/openvino-ie-maintainers
-4
View File
@@ -3,7 +3,3 @@
#
project(InferenceEngine)
if(ENABLE_PYTHON)
add_subdirectory(ie_bridges/python)
endif()
@@ -1,28 +0,0 @@
BasedOnStyle: Google
IndentWidth: 4
UseTab: Never
ColumnLimit: 120
Language: Cpp
Standard: Cpp11
AccessModifierOffset: -4
AlignConsecutiveMacros: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
CommentPragmas: '^#'
DerivePointerAlignment: false
FixNamespaceComments: true
IndentCaseLabels: false
IndentPPDirectives: AfterHash
ForEachMacros:
- foreach
- FOREACH_CHILD
@@ -1,90 +0,0 @@
# Copyright (C) 2018-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import pytest
import numpy as np
import ngraph as ng
def model_path(is_myriad=False):
path_to_repo = os.environ["MODELS_PATH"]
if not is_myriad:
test_xml = os.path.join(path_to_repo, "models", "test_model", 'test_model_fp32.xml')
test_bin = os.path.join(path_to_repo, "models", "test_model", 'test_model_fp32.bin')
else:
test_xml = os.path.join(path_to_repo, "models", "test_model", 'test_model_fp16.xml')
test_bin = os.path.join(path_to_repo, "models", "test_model", 'test_model_fp16.bin')
return (test_xml, test_bin)
def model_onnx_path():
path_to_repo = os.environ["MODELS_PATH"]
test_onnx = os.path.join(path_to_repo, "models", "test_model", 'test_model.onnx')
return test_onnx
def image_path():
path_to_repo = os.environ["DATA_PATH"]
path_to_img = os.path.join(path_to_repo, 'validation_set', '224x224', 'dog.bmp')
return path_to_img
def plugins_path():
path_to_repo = os.environ["DATA_PATH"]
plugins_xml = os.path.join(path_to_repo, 'ie_class', 'plugins.xml')
plugins_win_xml = os.path.join(path_to_repo, 'ie_class', 'plugins_win.xml')
plugins_osx_xml = os.path.join(path_to_repo, 'ie_class', 'plugins_apple.xml')
return (plugins_xml, plugins_win_xml, plugins_osx_xml)
@pytest.fixture(scope='session')
def device():
return os.environ.get("TEST_DEVICE") if os.environ.get("TEST_DEVICE") else "CPU"
def pytest_configure(config):
# register an additional markers
config.addinivalue_line("markers", "template_plugin: Skip test on Template plugin")
config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case")
def create_encoder(input_shape, levels = 4):
# input
input_node = ng.parameter(input_shape, np.float32, name="data")
padding_begin = padding_end = [0, 0]
strides = [1, 1]
dilations = [1, 1]
input_channels = [input_shape[1]]
last_output = input_node
# convolution layers
for i in range(levels):
input_c = input_channels[-1]
output_c = input_c * 2
conv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32)
conv_node = ng.convolution(last_output, conv_w, strides, padding_begin, padding_end, dilations)
input_channels.append(output_c)
last_output = conv_node
# deconvolution layers
for i in range(levels):
input_c = input_channels[-2]
output_c = input_channels.pop(-1)
deconv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32)
deconv_node = ng.convolution_backprop_data(last_output, deconv_w, strides)
last_output = deconv_node
# result
last_output.set_friendly_name("out")
result_node = ng.result(last_output)
return ng.Function(result_node, [input_node], "Encoder")
def create_relu(input_shape):
input_shape = ng.impl.PartialShape(input_shape)
param = ng.parameter(input_shape, dtype=np.float32, name="data")
result = ng.relu(param, name="out")
function = ng.Function(result, [param], "TestFunction")
return function
+7 -3
View File
@@ -10,11 +10,15 @@ if(NOT DEFINED OpenVINO_SOURCE_DIR)
find_package(InferenceEngineDeveloperPackage REQUIRED)
endif()
set(LIBRARY_OUTPUT_DIRECTORY_BIN ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(PYTHON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_subdirectory(src/compatibility/openvino)
add_subdirectory(thirdparty/pybind11 EXCLUDE_FROM_ALL)
set(LIBRARY_OUTPUT_DIRECTORY_BIN ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
add_subdirectory(src)
add_subdirectory(src/compatibility/pyngraph)
add_subdirectory(src/pyopenvino)
if(ENABLE_WHEEL)
add_subdirectory(wheel)
-1
View File
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0
#
set(PYTHON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(compatibility)
add_subdirectory(pyopenvino)
@@ -3,3 +3,4 @@
#
add_subdirectory(pyngraph)
add_subdirectory(openvino)
@@ -6,7 +6,7 @@
from typing import Union
from ngraph.impl import Function, PartialShape
from openvino.inference_engine import IENetwork, DataPtr, CDataPtr
from openvino.inference_engine import IENetwork, DataPtr, CDataPtr # type: ignore
def function_from_cnn(cnn_network: IENetwork) -> Function:
@@ -31,13 +31,7 @@ else()
message(STATUS "Found Cython version ${CYTHON_VERSION}")
endif()
if(PYTHONLIBS_VERSION_STRING MATCHES "^([0-9]+)\.([0-9]+).*")
set(PYTHON_VERSION_MAJOR ${CMAKE_MATCH_1})
set(PYTHON_VERSION_MINOR ${CMAKE_MATCH_2})
set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
else()
message(FATAL_ERROR "Failed to extract python major.minor from ${PYTHONLIBS_VERSION_STRING}")
endif()
set(PYTHON_VERSION python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
if(ENABLE_CONDA_FOLDER)
set(PYTHON_COMPONENT conda_${PYTHON_VERSION})
@@ -63,7 +57,7 @@ function(ov_python_disable_intel_warnings target)
endfunction()
set (PYTHON_BRIDGE_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory (src/openvino/inference_engine)
add_subdirectory (inference_engine)
if(TARGET _pyngraph)
add_dependencies(ie_api _pyngraph)
@@ -77,10 +71,6 @@ install(FILES requirements.txt
DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}
COMPONENT ${PYTHON_COMPONENT})
install(PROGRAMS ${PYTHON_BRIDGE_SRC_ROOT}/src/openvino/__init__.py
install(PROGRAMS ${PYTHON_BRIDGE_SRC_ROOT}/__init__.py
DESTINATION ${PYTHON_BRIDGE_CPACK_PATH}/${PYTHON_VERSION}/openvino
COMPONENT ${PYTHON_COMPONENT})
# package Python samples
ie_cpack(${PYTHON_COMPONENT})
@@ -88,7 +88,9 @@ find_package( Cython REQUIRED
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH )
find_package(PythonLibs 3 REQUIRED)
find_package(PythonInterp 3 REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)
set( CYTHON_CXX_EXTENSION "cxx" )
set( CYTHON_C_EXTENSION "c" )
@@ -283,8 +285,8 @@ function( cython_add_module _name )
endif()
endforeach()
compile_pyx( ${_name} generated_file ${pyx_module_sources} )
include_directories( ${PYTHON_INCLUDE_DIRS} )
python_add_module ( ${_name} ${generated_file} ${other_module_sources} )
target_include_directories( ${_name} PRIVATE ${PYTHON_INCLUDE_DIRS})
# set_target_properties(${_name} PROPERTIES PREFIX "" SUFFIX "${PYTHON_MODULE_EXTENSION}")
if( APPLE )
set_target_properties( ${_name} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup" )
@@ -60,8 +60,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${TARGET_NAME} PRIVATE "-Wno-error=register")
endif()
find_package(Python COMPONENTS Interpreter Development)
# perform copy
add_custom_command(TARGET ${TARGET_NAME}
POST_BUILD
@@ -3,7 +3,9 @@
import os
import pytest
import numpy as np
import ngraph as ng
import tests_compatibility
from pathlib import Path
@@ -78,6 +80,8 @@ def pytest_configure(config):
config.addinivalue_line("markers", "skip_on_hetero: Skip test on HETERO")
config.addinivalue_line("markers", "skip_on_template: Skip test on TEMPLATE")
config.addinivalue_line("markers", "onnx_coverage: Collect ONNX operator coverage")
config.addinivalue_line("markers", "template_plugin")
config.addinivalue_line("markers", "dynamic_library: Runs tests only in dynamic libraries case")
def pytest_collection_modifyitems(config, items):
@@ -112,3 +116,44 @@ def pytest_collection_modifyitems(config, items):
@pytest.fixture(scope="session")
def device():
return os.environ.get("TEST_DEVICE") if os.environ.get("TEST_DEVICE") else "CPU"
def create_encoder(input_shape, levels=4):
# input
input_node = ng.parameter(input_shape, np.float32, name="data")
padding_begin = padding_end = [0, 0]
strides = [1, 1]
dilations = [1, 1]
input_channels = [input_shape[1]]
last_output = input_node
# convolution layers
for _ in range(levels):
input_c = input_channels[-1]
output_c = input_c * 2
conv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32)
conv_node = ng.convolution(last_output, conv_w, strides, padding_begin, padding_end, dilations)
input_channels.append(output_c)
last_output = conv_node
# deconvolution layers
for _ in range(levels):
input_c = input_channels[-2]
output_c = input_channels.pop(-1)
deconv_w = np.random.uniform(0, 1, [output_c, input_c, 5, 5]).astype(np.float32)
deconv_node = ng.convolution_backprop_data(last_output, deconv_w, strides)
last_output = deconv_node
# result
last_output.set_friendly_name("out")
result_node = ng.result(last_output)
return ng.Function(result_node, [input_node], "Encoder")
def create_relu(input_shape):
input_shape = ng.impl.PartialShape(input_shape)
param = ng.parameter(input_shape, dtype=np.float32, name="data")
result = ng.relu(param, name="out")
function = ng.Function(result, [param], "TestFunction")
return function
@@ -0,0 +1,2 @@
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
@@ -7,7 +7,7 @@ import numpy as np
import os
from openvino.inference_engine import TensorDesc, Blob, IECore
from conftest import image_path, create_encoder
from tests_compatibility.conftest import image_path, create_encoder
import ngraph as ng
@@ -4,7 +4,7 @@
import pytest
from openvino.inference_engine import CDataPtr, IECore
from conftest import model_path, create_relu
from tests_compatibility.conftest import model_path, create_relu
import ngraph as ng
@@ -4,7 +4,7 @@
import pytest
from openvino.inference_engine import IECore, DataPtr
from conftest import model_path, create_relu
from tests_compatibility.conftest import model_path, create_relu
import ngraph as ng
@@ -8,7 +8,7 @@ import warnings
import time
from openvino.inference_engine import ie_api as ie
from conftest import model_path, image_path
from tests_compatibility.conftest import model_path, image_path
is_myriad = os.environ.get("TEST_DEVICE") == "MYRIAD"
@@ -11,7 +11,7 @@ from time import sleep, time
from queue import Queue
from openvino.inference_engine import IENetwork, IECore, ExecutableNetwork
from conftest import model_path, plugins_path, model_onnx_path
from tests_compatibility.conftest import model_path, plugins_path, model_onnx_path
import ngraph as ng
@@ -6,7 +6,7 @@ import pytest
import ngraph as ng
from openvino.inference_engine import IECore, IENetwork, DataPtr, InputInfoPtr, PreProcessInfo
from conftest import model_path, create_relu
from tests_compatibility.conftest import model_path, create_relu
test_net_xml, test_net_bin = model_path()
@@ -9,7 +9,7 @@ from datetime import datetime
import time
from openvino.inference_engine import ie_api as ie
from conftest import model_path, image_path, create_encoder
from tests_compatibility.conftest import model_path, image_path, create_encoder
import ngraph as ng
from ngraph.impl import Function, Type
@@ -4,7 +4,7 @@
import pytest
from openvino.inference_engine import InputInfoCPtr, DataPtr, IECore, TensorDesc
from conftest import model_path
from tests_compatibility.conftest import model_path
test_net_xml, test_net_bin = model_path()
@@ -4,7 +4,7 @@
import pytest
from openvino.inference_engine import InputInfoPtr, PreProcessInfo, DataPtr, IECore, TensorDesc, ColorFormat
from conftest import model_path
from tests_compatibility.conftest import model_path
test_net_xml, test_net_bin = model_path()
@@ -6,7 +6,7 @@ import ngraph as ng
from ngraph.impl.op import Parameter
from ngraph.impl import Function, Shape, Type
from conftest import model_path, create_relu
from tests_compatibility.conftest import model_path, create_relu
test_net_xml, test_net_bin = model_path()
@@ -5,7 +5,7 @@ import pytest
from openvino.inference_engine import PreProcessInfo, IECore, TensorDesc, Blob, PreProcessChannel,\
MeanVariant, ResizeAlgorithm, ColorFormat
from conftest import model_path
from tests_compatibility.conftest import model_path
test_net_xml, test_net_bin = model_path()
+4 -7
View File
@@ -17,11 +17,11 @@ passenv =
commands=
{envbindir}/python setup.py bdist_wheel
{envbindir}/pip install --no-index --pre --find-links=dist/ openvino
flake8 {posargs:src/ setup.py}
flake8 --ignore=D100,D101,D102,D103,D104,D105,D107,D212,W503 tests/ tests_compatibility/ # ignore lack of docs in tests
mypy --config-file=tox.ini {posargs:src/}
flake8 {posargs:src/ setup.py} --exclude=src/compatibility/openvino
flake8 --ignore=D100,D101,D102,D103,D104,D105,D107,D212,W503 tests/ tests_compatibility/ --exclude=tests_compatibility/test_inference_engine # ignore lack of docs in tests
mypy --config-file=tox.ini {posargs:src/} --exclude=src/compatibility/openvino
pytest --backend={env:NGRAPH_BACKEND} tests -v -k 'not _cuda' --ignore=tests/test_onnx/test_zoo_models.py --ignore=tests/test_utils --ignore=tests/test_inference_engine
pytest --backend={env:NGRAPH_BACKEND} tests_compatibility -v -k 'not _cuda' --ignore=tests_compatibility/test_onnx/test_zoo_models.py
pytest --backend={env:NGRAPH_BACKEND} tests_compatibility/test_ngraph -v -k 'not _cuda' --ignore=tests_compatibility/test_onnx/test_zoo_models.py
[testenv:zoo_models]
commands=
@@ -73,6 +73,3 @@ line_length=100
default_section=FIRSTPARTY
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
known_third_party=openvino
[pytest]
addopts = --strict-markers