Updated requirements for MO with telemetry. (#9431)
* Updated requirements for MO and POT with telemetry. * Added mock telemetry common class for unit tests. * Used mock telemetry in preprocessing unit tests. * Small correction.
This commit is contained in:
parent
3e9ae4bea7
commit
1a8506f205
@ -10,4 +10,5 @@ defusedxml>=0.7.1
|
||||
urllib3>=1.26.4
|
||||
requests>=2.25.1
|
||||
fastjsonschema~=2.15.1
|
||||
openvino-telemetry>=2022.1.0
|
||||
importlib-metadata; python_version < "3.8" and sys_platform == "win32"
|
@ -40,7 +40,7 @@ py_modules.append(prefix.replace('/', '.') + 'subprocess_main')
|
||||
py_modules.append(prefix.replace('/', '.') + '__main__')
|
||||
|
||||
# Minimal set of dependencies
|
||||
deps_whitelist = ['networkx', 'defusedxml', 'numpy']
|
||||
deps_whitelist = ['networkx', 'defusedxml', 'numpy', 'openvino-telemetry']
|
||||
|
||||
# for py37 and less on Windows need importlib-metadata in order to use entry_point *.exe files
|
||||
if sys.platform == 'win32' and sys.version_info[1] < 8:
|
||||
|
@ -1,13 +1,11 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
from argparse import Namespace
|
||||
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
|
||||
try:
|
||||
# pylint: disable=no-name-in-module,import-error
|
||||
@ -52,8 +50,9 @@ def process_function(ov_function: Model, argv: Namespace):
|
||||
apply_preprocessing(ov_function=ov_function, argv=argv)
|
||||
|
||||
|
||||
class TestPreprocessingMOC(unittest.TestCase):
|
||||
class TestPreprocessingMOC(UnitTestWithMockedTelemetry):
|
||||
def setUp(self):
|
||||
super(TestPreprocessingMOC, self).setUp()
|
||||
pass
|
||||
|
||||
def check_constant(self, const_node, expected, shape=None):
|
||||
|
@ -1,8 +1,6 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
from google.protobuf import text_format
|
||||
|
||||
@ -10,6 +8,7 @@ from openvino.tools.mo.front.caffe.loader import caffe_pb_to_nx
|
||||
from openvino.tools.mo.front.caffe.proto import caffe_pb2
|
||||
from openvino.tools.mo.graph.graph import Graph
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
|
||||
proto_str_one_input = 'name: "network" ' \
|
||||
'layer { ' \
|
||||
@ -89,7 +88,7 @@ proto_same_name_layers = 'layer { ' \
|
||||
'top: "conv1_2" ' \
|
||||
'}'
|
||||
|
||||
class TestLoader(unittest.TestCase):
|
||||
class TestLoader(UnitTestWithMockedTelemetry):
|
||||
def test_caffe_pb_to_nx_one_input(self):
|
||||
proto = caffe_pb2.NetParameter()
|
||||
text_format.Merge(proto_str_one_input, proto)
|
||||
|
@ -5,7 +5,6 @@ import unittest
|
||||
|
||||
import numpy as np
|
||||
from generator import generator, generate
|
||||
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import strict_compare_tensors
|
||||
from openvino.tools.mo.front.extractor import input_user_data_repack, output_user_data_repack, update_ie_fields, add_input_op, \
|
||||
get_node_id_with_ports
|
||||
@ -14,6 +13,7 @@ from openvino.tools.mo.front.extractor import spatial_attr_getter, add_input_ops
|
||||
from openvino.tools.mo.graph.graph import Node
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from openvino.tools.mo.utils.ir_engine.compare_graphs import compare_graphs
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.extractors import FakeMultiParam
|
||||
from unit_tests.utils.graph import build_graph, build_graph_with_edge_attrs, build_graph_with_attrs
|
||||
|
||||
@ -174,7 +174,7 @@ class TestAddInputOp(unittest.TestCase):
|
||||
self.assertTrue(flag, resp)
|
||||
|
||||
|
||||
class TestInputAddition(unittest.TestCase):
|
||||
class TestInputAddition(UnitTestWithMockedTelemetry):
|
||||
# Tests for input
|
||||
nodes = {'node_1': {'type': 'Identity', 'kind': 'op', 'op': 'Parameter'},
|
||||
'conv_1': {'type': 'Convolution', 'kind': 'op', 'op': 'NotPlaceholder'},
|
||||
@ -480,7 +480,7 @@ class TestOutputCut(unittest.TestCase):
|
||||
self.assertEqual(len(graph.nodes()), 2)
|
||||
|
||||
|
||||
class TestUserDataRepack(unittest.TestCase):
|
||||
class TestUserDataRepack(UnitTestWithMockedTelemetry):
|
||||
nodes = {'A': {'name': 'Aa', 'op': 'Parameter', 'kind': 'op'},
|
||||
'B': {'name': 'Bb', 'op': 'Parameter', 'kind': 'op'},
|
||||
'C': {'name': 'Cc', 'type': 'Identity', 'value': None, 'kind': 'op', 'op': 'Identity'},
|
||||
|
@ -7,16 +7,18 @@ import numpy as np
|
||||
|
||||
from openvino.tools.mo.graph.graph import Node, Graph
|
||||
from unit_tests.mo.front.kaldi.loader.utils_test import TestKaldiUtilsLoading
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
|
||||
class KaldiFrontExtractorTest(unittest.TestCase):
|
||||
class KaldiFrontExtractorTest(UnitTestWithMockedTelemetry):
|
||||
graph = Graph()
|
||||
nodes_attributes = {}
|
||||
test_node = None
|
||||
|
||||
@classmethod
|
||||
def setUp(cls):
|
||||
super().setUp(cls)
|
||||
cls.nodes_attributes = {
|
||||
'input_data_node': {
|
||||
'name': 'input_data_node',
|
||||
|
@ -1,16 +1,15 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openvino.tools.mo.front.mxnet.RNN_ext import RNNFrontExtractor
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.extractors import PB
|
||||
|
||||
|
||||
class RNNFrontExtractorTest(unittest.TestCase):
|
||||
class RNNFrontExtractorTest(UnitTestWithMockedTelemetry):
|
||||
@staticmethod
|
||||
def _create_node(**attrs):
|
||||
params = {'attrs': {
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from openvino.tools.mo.front.mxnet.loader import load_symbol_nodes, parse_input_model
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
|
||||
|
||||
class MockSymbolLoadObj():
|
||||
@ -12,7 +12,7 @@ class MockSymbolLoadObj():
|
||||
pass
|
||||
|
||||
|
||||
class TestLoader(unittest.TestCase):
|
||||
class TestLoader(UnitTestWithMockedTelemetry):
|
||||
@patch('json.load')
|
||||
@patch('json.loads')
|
||||
@patch('os.path.isfile')
|
||||
|
@ -11,6 +11,7 @@ from openvino.tools.mo.graph.graph import Node, Graph, add_opoutput, dict_includ
|
||||
from openvino.tools.mo.ops.const import Const
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from openvino.tools.mo.utils.ir_engine.compare_graphs import compare_graphs
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import build_graph, build_graph_with_edge_attrs
|
||||
|
||||
nodes = {
|
||||
@ -33,8 +34,9 @@ edges = {
|
||||
}
|
||||
|
||||
|
||||
class TestGetNodeById(unittest.TestCase):
|
||||
class TestGetNodeById(UnitTestWithMockedTelemetry):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.graph = build_graph(nodes, edges)
|
||||
|
||||
def test_get_node_id_by_name(self):
|
||||
|
@ -1,7 +1,6 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
from argparse import Namespace
|
||||
|
||||
import numpy as np
|
||||
@ -11,6 +10,7 @@ from openvino.tools.mo.middle.ScaleInput import ScaleInput
|
||||
from openvino.tools.mo.graph.graph import Graph, Node
|
||||
from openvino.tools.mo.utils.cli_parser import get_mean_scale_dictionary, parse_tuple_pairs
|
||||
from openvino.tools.mo.utils.ir_engine.compare_graphs import compare_graphs
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import build_graph, regular_op_with_shaped_data, result, connect, connect_data, \
|
||||
valued_const_with_data
|
||||
|
||||
@ -36,7 +36,7 @@ nodes = {
|
||||
}
|
||||
|
||||
|
||||
class AddMeanScaleValuesTest(unittest.TestCase):
|
||||
class AddMeanScaleValuesTest(UnitTestWithMockedTelemetry):
|
||||
def check_graph_attrs(self, graph: Graph, graph_ref: Graph, parameter_node_names: list):
|
||||
for node in graph.get_op_nodes():
|
||||
if node.soft_get('name') in parameter_node_names:
|
||||
|
@ -1,10 +1,9 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
from openvino.tools.mo.middle.CheckForCycle import CheckForCycle
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
nodes_attributes = {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op'},
|
||||
@ -35,7 +34,7 @@ nodes_attributes = {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op'},
|
||||
}
|
||||
|
||||
|
||||
class CycleTest(unittest.TestCase):
|
||||
class CycleTest(UnitTestWithMockedTelemetry):
|
||||
def test_check_for_cycle1(self):
|
||||
# cyclic case
|
||||
graph = build_graph(nodes_attributes,
|
||||
|
@ -8,13 +8,14 @@ import numpy as np
|
||||
from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.middle.passes.convert_data_type import convert_blobs, SUPPORTED_DATA_TYPES
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
nodes_attributes = {'data_node': {'kind': 'data', 'value': None, 'shape': int64_array([5])},
|
||||
'op_node': { 'kind': 'op', 'op': 'Result'}}
|
||||
|
||||
|
||||
class TestConvertBlob(unittest.TestCase):
|
||||
class TestConvertBlob(UnitTestWithMockedTelemetry):
|
||||
def test_convert_blob_to_fp32_from_fp64(self):
|
||||
graph = build_graph(nodes_attributes,
|
||||
[('data_node', 'op_node', {'bin': 1})],
|
||||
|
@ -9,6 +9,7 @@ from openvino.tools.mo.front.common.partial_infer.concat import concat_infer
|
||||
from openvino.tools.mo.graph.graph import Node
|
||||
from openvino.tools.mo.middle.passes.infer import override_placeholder_shapes, partial_infer
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import build_graph
|
||||
|
||||
nodes_attributes = {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op'},
|
||||
@ -39,7 +40,7 @@ nodes_attributes = {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op'},
|
||||
}
|
||||
|
||||
|
||||
class TestInferPass(unittest.TestCase):
|
||||
class TestInferPass(UnitTestWithMockedTelemetry):
|
||||
def test_override_placeholder_shapes(self):
|
||||
"""
|
||||
Test for overriding shape in placeholder by shape from user_shapes.
|
||||
@ -243,7 +244,7 @@ class TestInferPass(unittest.TestCase):
|
||||
self.assertRaises(Error, partial_infer, graph, start_node)
|
||||
|
||||
|
||||
class CycleTest(unittest.TestCase):
|
||||
class CycleTest(UnitTestWithMockedTelemetry):
|
||||
def test_is_not_fully_inferred_param(self):
|
||||
# Node that have is_not_fully_inferred=True
|
||||
graph = build_graph(nodes_attributes,
|
||||
|
@ -1,8 +1,6 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy.testing as npt
|
||||
|
||||
from openvino.tools.mo.ops.gather import Gather
|
||||
@ -10,11 +8,12 @@ from openvino.tools.mo.front.common.partial_infer.utils import int64_array
|
||||
from openvino.tools.mo.graph.graph import Node
|
||||
from openvino.tools.mo.middle.passes.infer import partial_infer
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import valued_const_with_data, result, regular_op_with_empty_data, connect, \
|
||||
shaped_parameter, build_graph
|
||||
|
||||
|
||||
class TestGatherPartialInfer(unittest.TestCase):
|
||||
class TestGatherPartialInfer(UnitTestWithMockedTelemetry):
|
||||
|
||||
@staticmethod
|
||||
def build_and_test_value_inference(data, indices, axis, batch_dims, ref_value, negative_test_string=None):
|
||||
|
@ -1,8 +1,6 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openvino.tools.mo.ops.sparse_reshape import SparseReshape
|
||||
@ -10,13 +8,14 @@ from openvino.tools.mo.front.common.partial_infer.utils import shape_array, dyna
|
||||
from openvino.tools.mo.graph.graph import Node
|
||||
from openvino.tools.mo.middle.passes.infer import partial_infer
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import valued_const_with_data, result, regular_op_with_empty_data, connect, \
|
||||
shaped_parameter, build_graph, empty_data
|
||||
|
||||
dyn = dynamic_dimension
|
||||
|
||||
|
||||
class TestSparseReshape(unittest.TestCase):
|
||||
class TestSparseReshape(UnitTestWithMockedTelemetry):
|
||||
|
||||
def build_and_test_shape_inference(self, input_indices_sparse_shape, input_actual_shape, new_shape, ref_out_shape,
|
||||
input_indices=None, ref_out_indices=None):
|
||||
|
15
tools/mo/unit_tests/mo/unit_test_with_mocked_telemetry.py
Normal file
15
tools/mo/unit_tests/mo/unit_test_with_mocked_telemetry.py
Normal file
@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
from unittest.mock import Mock
|
||||
|
||||
try:
|
||||
import openvino_telemetry as tm
|
||||
except ImportError:
|
||||
import openvino.tools.mo.utils.telemetry_stub as tm
|
||||
|
||||
|
||||
class UnitTestWithMockedTelemetry(unittest.TestCase):
|
||||
def setUp(self):
|
||||
tm.Telemetry.__init__ = Mock(return_value=None)
|
||||
tm.Telemetry.send_event = Mock()
|
@ -16,9 +16,10 @@ from openvino.tools.mo.utils.cli_parser import get_placeholder_shapes, get_tuple
|
||||
parse_tuple_pairs, check_positive, writable_dir, readable_dirs, \
|
||||
readable_file, get_freeze_placeholder_values, parse_transform, check_available_transforms, get_layout_values, get_data_type_from_input_value
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
|
||||
|
||||
class TestingMeanScaleGetter(unittest.TestCase):
|
||||
class TestingMeanScaleGetter(UnitTestWithMockedTelemetry):
|
||||
def test_tuple_parser(self):
|
||||
tuple_values = "data(1.1,22.22,333.333),info[2.2,33.33,444.444]"
|
||||
result = parse_tuple_pairs(tuple_values)
|
||||
@ -381,7 +382,7 @@ class TestingMeanScaleGetter(unittest.TestCase):
|
||||
self.assertRaises(Error, parse_tuple_pairs, "input1,input2")
|
||||
|
||||
|
||||
class TestSingleTupleParsing(unittest.TestCase):
|
||||
class TestSingleTupleParsing(UnitTestWithMockedTelemetry):
|
||||
def test_get_values_ideal(self):
|
||||
values = "(1.11, 22.22, 333.333)"
|
||||
result = get_tuple_values(values)
|
||||
@ -443,7 +444,7 @@ class TestSingleTupleParsing(unittest.TestCase):
|
||||
self.assertEqual(exp_res, result)
|
||||
|
||||
|
||||
class TestShapesParsing(unittest.TestCase):
|
||||
class TestShapesParsing(UnitTestWithMockedTelemetry):
|
||||
def test_get_shapes_several_inputs_several_shapes(self):
|
||||
argv_input = "inp1,inp2"
|
||||
input_shapes = "(1,22,333,123), (-1,45,7,1)"
|
||||
|
@ -2,13 +2,13 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from fnmatch import fnmatch
|
||||
from generator import generator, generate
|
||||
|
||||
from openvino.tools.mo.utils.custom_replacement_config import load_and_validate_json_config
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from openvino.tools.mo.utils.utils import get_mo_root_dir
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
|
||||
|
||||
def get_json_configs(mo_root_dir):
|
||||
@ -22,7 +22,7 @@ def get_json_configs(mo_root_dir):
|
||||
return config_files_list
|
||||
|
||||
@generator
|
||||
class TestSchema(unittest.TestCase):
|
||||
class TestSchema(UnitTestWithMockedTelemetry):
|
||||
base_dir = get_mo_root_dir()
|
||||
schema_file = os.path.join(base_dir, 'mo', 'utils', 'schema.json')
|
||||
transformation_configs = get_json_configs(base_dir)
|
||||
|
@ -1,15 +1,14 @@
|
||||
# Copyright (C) 2018-2021 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
from openvino.tools.mo.graph.graph import Graph, Node
|
||||
from openvino.tools.mo.utils.error import Error
|
||||
from openvino.tools.mo.utils.graph import bfs_search, is_connected_component, sub_graph_between_nodes, backward_bfs_for_operation
|
||||
from unit_tests.mo.unit_test_with_mocked_telemetry import UnitTestWithMockedTelemetry
|
||||
from unit_tests.utils.graph import regular_op, result, build_graph_with_edge_attrs
|
||||
|
||||
|
||||
class TestGraphUtils(unittest.TestCase):
|
||||
class TestGraphUtils(UnitTestWithMockedTelemetry):
|
||||
def test_simple_dfs(self):
|
||||
graph = Graph()
|
||||
graph.add_nodes_from(list(range(1, 5)))
|
||||
|
Loading…
Reference in New Issue
Block a user