!20607 fix bug of run check

Merge pull request !20607 from wangnan39/modify_run_check
This commit is contained in:
i-robot 2021-07-21 03:06:46 +00:00 committed by Gitee
commit 4a3d4fdfa2
2 changed files with 13 additions and 21 deletions

View File

@ -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']

View File

@ -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: