From 9e4f47fa08bdef7dff8e3481ded5e7a318e554cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=97?= Date: Tue, 20 Jul 2021 21:21:08 +0800 Subject: [PATCH] fix bug of run check --- mindspore/run_check/__init__.py | 2 +- mindspore/run_check/run_check.py | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/mindspore/run_check/__init__.py b/mindspore/run_check/__init__.py index e447e82475d..d31d4da6f6d 100644 --- a/mindspore/run_check/__init__.py +++ b/mindspore/run_check/__init__.py @@ -14,7 +14,7 @@ # ============================================================================ """.. run_check package.""" -from .run_check import run_check from ._check_version import check_version_and_env_config +from .run_check import run_check __all__ = ['run_check'] diff --git a/mindspore/run_check/run_check.py b/mindspore/run_check/run_check.py index 0467e10b08b..eaf56dedde8 100644 --- a/mindspore/run_check/run_check.py +++ b/mindspore/run_check/run_check.py @@ -19,21 +19,22 @@ mindspore.run_check The goal is to provide a convenient API to check if the installation is successful or failed. """ -from importlib import import_module -import numpy as np - - -try: - ms = import_module("mindspore") -except ModuleNotFoundError: - ms = None -finally: - pass - def _check_mul(): """ Define the mul method. """ + from importlib import import_module + import numpy as np + + try: + ms = import_module("mindspore") + except ModuleNotFoundError: + ms = None + finally: + pass + + print(f"MindSpore version:", ms.__version__) + input_x = ms.Tensor(np.array([1.0, 2.0, 3.0]), ms.float32) input_y = ms.Tensor(np.array([4.0, 5.0, 6.0]), ms.float32) mul = ms.ops.Mul() @@ -41,14 +42,6 @@ def _check_mul(): print(f"The result of multiplication calculation is correct, MindSpore has been installed successfully!") -def _check_install(): - """ - Define the check install method. - Print MindSpore version. - """ - print(f"MindSpore version:", ms.__version__) - - def run_check(): """ Provide a convenient API to check if the installation is successful or failed. @@ -60,7 +53,6 @@ def run_check(): The result of multiplication calculation is correct, MindSpore has been installed successfully! """ try: - _check_install() _check_mul() # pylint: disable=broad-except except Exception as e: