[MO] Activate pylint checker in CI (#15012)
* Fixed mo workflow * Update pylint config with import os * Update .github/workflows/mo.yml * Install extras for pylint checker * Fix pylint reported errors * Add torch to the environment * Add torch into whitelist * Ignore torch * Localize torch code * Fix syntax error * Remove MO unit-test from Pylint flow Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
This commit is contained in:
44
.github/workflows/mo.yml
vendored
44
.github/workflows/mo.yml
vendored
@@ -2,15 +2,15 @@ name: MO
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'openvino/tools/mo/**'
|
||||
- '.github/workflows/mo.py'
|
||||
- 'tools/mo/**'
|
||||
- '.github/workflows/mo.yml'
|
||||
branches:
|
||||
- 'master'
|
||||
- 'releases/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'openvino/tools/mo/**'
|
||||
- '.github/workflows/mo.py'
|
||||
- 'tools/mo/**'
|
||||
- '.github/workflows/mo.yml'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -24,48 +24,34 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.7
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('openvino/tools/mo/requirements*.txt') }}
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('tools/mo/requirements*.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
${{ runner.os }}-
|
||||
|
||||
# tensorflow 1.15 causes modules import
|
||||
# errors, most likely due to https://github.com/PyCQA/pylint/issues/2603
|
||||
# for tensorflow.core.framework and tensorflow.contrib
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip setuptools
|
||||
# For UT
|
||||
pip install unittest-xml-reporting==3.0.2
|
||||
# MO requirements
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements_mxnet.txt
|
||||
pip install -r requirements_caffe.txt
|
||||
pip install -r requirements_kaldi.txt
|
||||
pip install -r requirements_onnx.txt
|
||||
pip install -r requirements_tf2.txt
|
||||
pip install -r requirements_dev.txt
|
||||
# requrements for CMake
|
||||
sudo apt update
|
||||
sudo apt --assume-yes install libusb-1.0-0-dev
|
||||
working-directory: openvino/tools/mo
|
||||
working-directory: tools/mo
|
||||
|
||||
- name: Pylint
|
||||
run: pylint -d C,R,W openvino/tools/mo/ openvino/tools/mo/mo.py
|
||||
working-directory: openvino/tools/mo
|
||||
|
||||
- name: CMake configure
|
||||
run: cmake -B build
|
||||
|
||||
- name: UT
|
||||
run: |
|
||||
export PYTHONPATH=$PYTHONPATH:`pwd`
|
||||
export MO_ROOT=`pwd`
|
||||
env
|
||||
mkdir ../mo-ut-logs
|
||||
python3 -m xmlrunner discover -p *_test.py --output=../mo-ut-logs
|
||||
working-directory: openvino/tools/mo
|
||||
run: pylint -d C,R,W openvino/tools/mo
|
||||
working-directory: tools/mo
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
# Python code to execute, usually for sys.path manipulation such as
|
||||
# pygtk.require().
|
||||
init-hook='sys.path.append(os.path.abspath(os.path.curdir))'
|
||||
init-hook='import os; import sys; sys.path.append(os.path.abspath(os.path.curdir))'
|
||||
|
||||
# Add files or directories to the blacklist. They should be base names, not
|
||||
# paths.
|
||||
@@ -202,7 +202,7 @@ ignore-mixin-members=yes
|
||||
# (useful for modules/projects where namespaces are manipulated during runtime
|
||||
# and thus existing member attributes cannot be deduced by static analysis. It
|
||||
# supports qualified module names, as well as Unix pattern matching.
|
||||
ignored-modules=flask_sqlalchemy,app.extensions.flask_sqlalchemy,distutils
|
||||
ignored-modules=flask_sqlalchemy,app.extensions.flask_sqlalchemy,distutils,openvino,torch
|
||||
|
||||
# List of class names for which member attributes should not be checked (useful
|
||||
# for classes with dynamically set attributes). This supports the use of
|
||||
|
||||
@@ -696,10 +696,15 @@ def parse_input_shapes(argv):
|
||||
return [input_shapes]
|
||||
else:
|
||||
return input_shapes
|
||||
elif isinstance(shapes, PartialShape) or isinstance(shapes, torch.Size):
|
||||
elif isinstance(shapes, PartialShape):
|
||||
return [shapes]
|
||||
else:
|
||||
raise Error("Unknown type of input shape {}.".format(type(shapes)))
|
||||
try:
|
||||
import torch
|
||||
if isinstance(shapes, torch.Size):
|
||||
return [shapes]
|
||||
except ImportError:
|
||||
raise Error("Unknown type of input shape {}.".format(type(shapes)))
|
||||
|
||||
return input_shapes
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ def freeze_tf2_concrete_function(model, concrete_func, env_setup):
|
||||
|
||||
|
||||
def prepare_graph_def(model):
|
||||
from tensorflow.python.training.tracking.base import Trackable
|
||||
from tensorflow.python.training.tracking.base import Trackable # pylint: disable=no-name-in-module,import-error
|
||||
if isinstance(model, tf_v1.GraphDef):
|
||||
nodes_to_clear_device = model.node
|
||||
for node in nodes_to_clear_device:
|
||||
|
||||
@@ -18,7 +18,7 @@ except ImportError:
|
||||
tf_v1.get_logger().setLevel("ERROR")
|
||||
|
||||
from google.protobuf import text_format
|
||||
from tensorflow.python.eager.context import graph_mode
|
||||
from tensorflow.python.eager.context import graph_mode # pylint: disable=no-name-in-module,import-error
|
||||
|
||||
from openvino.tools.mo.front.extractor import node_defs_to_str
|
||||
from openvino.tools.mo.front.tf.extractors.utils import tf_dtype_extractor, tf_tensor_shape, get_tf_node_port
|
||||
|
||||
@@ -96,7 +96,7 @@ class QuantizeLinearResolver(MiddleReplacementPattern):
|
||||
rename_nodes([(quantize_node, node_name + '/TBD'), (cast, node_name)])
|
||||
|
||||
assert scale_y_shape is not None, "{0} contains scale(input with port 1) with shape None".\
|
||||
format(quantize_node.soft_get('name', soft_get('id')))
|
||||
format(quantize_node.soft_get('name', quantize_node.id))
|
||||
if axis is not None and len(scale_y_shape) > 0 and scale_y_shape[0] > 1:
|
||||
input_shape = fake_quantize.in_port(0).data.get_shape()
|
||||
target_shape = np.ones(len(input_shape), int)
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
if __name__ == "__main__":
|
||||
from openvino.tools.mo.utils.telemetry_utils import init_mo_telemetry
|
||||
init_mo_telemetry()
|
||||
from subprocess_main import subprocess_main # nosec; pylint: disable=no-name-in-module
|
||||
from openvino.tools.mo.subprocess_main import subprocess_main # nosec; pylint: disable=no-name-in-module
|
||||
subprocess_main(framework=None)
|
||||
|
||||
@@ -10,9 +10,9 @@ try:
|
||||
except ImportError:
|
||||
import tensorflow as tf_v1
|
||||
|
||||
#in some environment suppressing through TF_CPP_MIN_LOG_LEVEL does not work
|
||||
# in some environment suppressing through TF_CPP_MIN_LOG_LEVEL does not work
|
||||
tf_v1.get_logger().setLevel("ERROR")
|
||||
from tensorflow.python.eager.context import graph_mode
|
||||
from tensorflow.python.eager.context import graph_mode # pylint: disable=no-name-in-module,import-error
|
||||
|
||||
try:
|
||||
import tensorflow.contrib # pylint: disable=no-name-in-module,import-error
|
||||
|
||||
Reference in New Issue
Block a user