Skip to content

Commit

Permalink
OVC pylint fix (openvinotoolkit#22558)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Roman Kazantsev <[email protected]>
  • Loading branch information
popovaan and rkazants authored Feb 1, 2024
1 parent 42ea606 commit ff6795e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 14 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/mo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 54 additions & 0 deletions .github/workflows/ovc.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions tools/mo/openvino/tools/mo/front/tf/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ 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."

model_inputs = []
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)))
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/ovc/openvino/tools/ovc/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tools/ovc/openvino/tools/ovc/moc_frontend/shape_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tools/ovc/openvino/tools/ovc/moc_frontend/type_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit ff6795e

Please sign in to comment.