From 852dd938031e7ebc516908d8f9142bc3be14d494 Mon Sep 17 00:00:00 2001 From: Victor Kuznetsov Date: Wed, 10 Nov 2021 16:59:58 +0300 Subject: [PATCH] Refactor work with env variables (#8208) * del MO_ROOT * del MO_ROOT from common_utils.py * add MO_PATH to common_utils.py * change mo_path --- tests/layer_tests/common/constants.py | 8 -------- tests/layer_tests/common/utils/common_utils.py | 14 +++++++------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/layer_tests/common/constants.py b/tests/layer_tests/common/constants.py index cf570fc40c2d88..26e6942d791db7 100644 --- a/tests/layer_tests/common/constants.py +++ b/tests/layer_tests/common/constants.py @@ -4,14 +4,6 @@ import os -if 'MO_ROOT' in os.environ: - mo_bin = os.environ['MO_ROOT'] - if not os.path.exists(mo_bin): - raise EnvironmentError( - "Environment variable MO_ROOT points to non existing path {}".format(mo_bin)) -else: - raise EnvironmentError("MO_ROOT variable is not set") - if os.environ.get('OUTPUT_DIR') is not None: out_path = os.environ['OUTPUT_DIR'] else: diff --git a/tests/layer_tests/common/utils/common_utils.py b/tests/layer_tests/common/utils/common_utils.py index f92daf51c26bcc..e5fc5d93f3773b 100644 --- a/tests/layer_tests/common/utils/common_utils.py +++ b/tests/layer_tests/common/utils/common_utils.py @@ -2,24 +2,24 @@ # SPDX-License-Identifier: Apache-2.0 import logging -import os import subprocess import sys +from pathlib import Path +import mo import numpy as np - logger = logging.getLogger(__name__) def generate_ir(coverage=False, **kwargs): - # Get default mo args - mo = os.path.join(os.environ.get("MO_ROOT"), "mo.py") + mo_path = Path(mo.__file__).parent + mo_runner = mo_path.joinpath('main.py').as_posix() if coverage: - params = [sys.executable, '-m', 'coverage', 'run', '-p', '--source={}'.format(os.environ.get("MO_ROOT")), - '--omit=*_test.py', mo] + params = [sys.executable, '-m', 'coverage', 'run', '-p', '--source={}'.format(mo_path.parent), + '--omit=*_test.py', mo_runner] else: - params = [sys.executable, mo] + params = [sys.executable, mo_runner] for key, value in kwargs.items(): if key == "batch": params.extend(("-b", str(value)))