OVC pylint fix (#22558)

* Test change.

* PyLint fix.

* Small fix.

* Separated MO and OVC workflows.

* Corrected ovc workflow.

* Fixed error.

* Fixed error.

* PyLint fix.

* PyLint fix.

* Removed not needed change.

* Temporarily removed changes from OVC.

* Returned changes.

* Returned changes.

* Added merge_group.

* Update tools/ovc/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.py

Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>

---------

Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>
This commit is contained in:
Anastasiia Pnevskaia 2024-02-01 15:47:23 +01:00 committed by GitHub
parent 42ea6068f2
commit ff6795e239
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 64 additions and 14 deletions

View File

@ -53,8 +53,4 @@ jobs:
- name: Pylint-MO
run: pylint -d C,R,W openvino/tools/mo
working-directory: tools/mo
- name: Pylint-OVC
run: pylint -d C,R,W openvino/tools/ovc
working-directory: tools/ovc
working-directory: tools/mo

54
.github/workflows/ovc.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: OVC
on:
merge_group:
push:
paths:
- 'tools/ovc/**'
- '.github/workflows/ovc.yml'
branches:
- 'master'
- 'releases/**'
pull_request:
paths:
- 'tools/ovc/**'
- '.github/workflows/ovc.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Pylint-UT:
runs-on: ubuntu-22.04
steps:
- name: Clone OpenVINO
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('src/bindings/python/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
# For UT
pip install unittest-xml-reporting==3.0.2
pip install pylint>=2.7.0
pip install pyenchant>=3.0.0
pip install -r requirements.txt
working-directory: src/bindings/python/
- name: Pylint-OVC
run: pylint -d C,R,W openvino/tools/ovc
working-directory: tools/ovc

View File

@ -207,7 +207,7 @@ def prepare_graph_def(model):
for node in nodes_to_clear_device:
node.device = ""
return model, {}, "tf", None
if isinstance(model, tf.keras.Model):
if isinstance(model, tf.keras.Model): # pylint: disable=no-member
assert hasattr(model, "inputs") and model.inputs is not None, "Model inputs specification is required."
@ -215,7 +215,7 @@ def prepare_graph_def(model):
for inp in model.inputs:
if isinstance(inp, tf.Tensor):
model_inputs.append(inp)
elif tf.keras.backend.is_keras_tensor(inp):
elif tf.keras.backend.is_keras_tensor(inp): # pylint: disable=no-member
model_inputs.append(inp.type_spec)
else:
raise Error("Unknown input tensor type {}".format(type(input)))
@ -308,7 +308,7 @@ def load_tf_graph_def(graph_file_name: str = "", is_binary: bool = True, checkpo
# Code to extract Keras model.
# tf.keras.models.load_model function throws TypeError,KeyError or IndexError
# for TF 1.x SavedModel format in case TF 1.x installed
imported = tf.keras.models.load_model(model_dir, compile=False)
imported = tf.keras.models.load_model(model_dir, compile=False) # pylint: disable=no-member
except:
imported = tf.saved_model.load(model_dir, saved_model_tags) # pylint: disable=E1120

View File

@ -10,7 +10,7 @@ from copy import copy
# WA for abseil bug that affects logging while importing TF starting 1.14 version
# Link to original issue: https://github.com/abseil/abseil-py/issues/99
if importlib.util.find_spec('absl') is not None:
import absl.logging
import absl.logging # pylint: disable=import-error
log.root.removeHandler(absl.logging._absl_handler)

View File

@ -35,7 +35,7 @@ def get_pytorch_decoder(model, example_inputs, args):
inputs = prepare_torch_inputs(example_inputs)
if not isinstance(model, (TorchScriptPythonDecoder, TorchFXPythonDecoder)):
if isinstance(model, torch.export.ExportedProgram):
raise RuntimeException("Models recieved from torch.export are not yet supported by convert_model.")
raise RuntimeError("Models received from torch.export are not yet supported by convert_model.")
else:
decoder = TorchScriptPythonDecoder(model, example_input=inputs, shared_memory=args.get("share_weights", True))
else:

View File

@ -76,7 +76,7 @@ def tensor_to_int_list(tensor):
def to_partial_shape(shape):
if 'tensorflow' in sys.modules:
import tensorflow as tf
import tensorflow as tf # pylint: disable=import-error
if isinstance(shape, tf.Tensor):
return PartialShape(tensor_to_int_list(shape))
if isinstance(shape, tf.TensorShape):
@ -92,7 +92,7 @@ def is_shape_type(value):
if isinstance(value, PartialShape):
return True
if 'tensorflow' in sys.modules:
import tensorflow as tf
import tensorflow as tf # pylint: disable=import-error
if isinstance(value, (tf.TensorShape, tf.Tensor)):
return True
if 'paddle' in sys.modules:

View File

@ -11,7 +11,7 @@ def is_type(val):
if isinstance(val, (type, Type)):
return True
if 'tensorflow' in sys.modules:
import tensorflow as tf
import tensorflow as tf # pylint: disable=import-error
if isinstance(val, tf.dtypes.DType):
return True
if 'torch' in sys.modules:
@ -31,7 +31,7 @@ def to_ov_type(val):
if isinstance(val, type):
return Type(val)
if 'tensorflow' in sys.modules:
import tensorflow as tf
import tensorflow as tf # pylint: disable=import-error
if isinstance(val, tf.dtypes.DType):
return Type(val.as_numpy_dtype())
if 'torch' in sys.modules: