From 328f43efe42339e69dda5e8d4fb0507b15784858 Mon Sep 17 00:00:00 2001 From: VVsssssk Date: Mon, 24 Jan 2022 16:40:56 +0800 Subject: [PATCH 1/2] fix check_env --- tools/check_env.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tools/check_env.py b/tools/check_env.py index 8851926ef3..1d74916003 100644 --- a/tools/check_env.py +++ b/tools/check_env.py @@ -1,4 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. + from mmcv.utils import collect_env as collect_base_env from mmcv.utils import get_git_hash @@ -54,8 +55,81 @@ def check_backend(): logger.info(f'openvino_is_avaliable: {openvino_apis.is_available()}') +def get_version(s): + return ''.join([c for c in s if c.isdigit() or c == '.']) + + +def get_op(s): + return ''.join([c for c in s if c in '><=']) + + +def check_codebase(): + ops = { + '>=': (lambda x, y: x >= y), + '==': (lambda x, y: x == y), + '<=': (lambda x, y: x <= y), + '': (lambda x, y: True) + } + with open('../requirements/optional.txt', 'r') as file: + try: + import mmcls + except ImportError: + mmcls_version = None + else: + mmcls_version = mmcls.__version__ + requirement = file.readline() + is_available = ops[get_op(requirement)](mmcls_version, + get_version(requirement)) + logger.info(f'mmcls: {mmcls_version} is_avaliable : {is_available}') + + try: + import mmdet + except ImportError: + mmdet_version = None + else: + mmdet_version = mmdet.__version__ + requirement = file.readline() + is_available = ops[get_op(requirement)](mmdet_version, + get_version(requirement)) + logger.info(f'mmdet: {mmdet_version} is_avaliable : {is_available}') + + try: + import mmedit + except ImportError: + mmedit_version = None + else: + mmedit_version = mmedit.__version__ + requirement = file.readline() + is_available = ops[get_op(requirement)](mmedit_version, + get_version(requirement)) + logger.info(f'mmedit: {mmedit_version} is_avaliable : {is_available}') + + try: + import mmocr + except ImportError: + mmocr_version = None + else: + mmocr_version = mmocr.__version__ + requirement = file.readline() + is_available = ops[get_op(requirement)](mmocr_version, + get_version(requirement)) + logger.info(f'mmocr: {mmocr_version} is_avaliable : {is_available}') + + try: + import mmseg + except ImportError: + mmseg_version = None + else: + mmseg_version = mmseg.__version__ + requirement = file.readline() + is_available = ops[get_op(requirement)](mmseg_version, + get_version(requirement)) + logger.info(f'mmseg: {mmseg_version} is_avaliable : {is_available}') + + if __name__ == '__main__': logger = get_root_logger() for name, val in collect_env().items(): logger.info('{}: {}'.format(name, val)) check_backend() + check_codebase() From 2df3822d0efd4aa94904eb2d397ac1ee8071f0c1 Mon Sep 17 00:00:00 2001 From: VVsssssk Date: Tue, 25 Jan 2022 13:55:11 +0800 Subject: [PATCH 2/2] update --- tools/check_env.py | 108 ++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 66 deletions(-) diff --git a/tools/check_env.py b/tools/check_env.py index 1d74916003..68aa2799e7 100644 --- a/tools/check_env.py +++ b/tools/check_env.py @@ -55,81 +55,57 @@ def check_backend(): logger.info(f'openvino_is_avaliable: {openvino_apis.is_available()}') -def get_version(s): - return ''.join([c for c in s if c.isdigit() or c == '.']) +def check_codebase(): + try: + import mmcls + except ImportError: + mmcls_version = None + else: + mmcls_version = mmcls.__version__ + logger.info(f'mmcls: {mmcls_version}') + try: + import mmdet + except ImportError: + mmdet_version = None + else: + mmdet_version = mmdet.__version__ + logger.info(f'mmdet: {mmdet_version}') -def get_op(s): - return ''.join([c for c in s if c in '><=']) + try: + import mmedit + except ImportError: + mmedit_version = None + else: + mmedit_version = mmedit.__version__ + logger.info(f'mmedit: {mmedit_version}') + try: + import mmocr + except ImportError: + mmocr_version = None + else: + mmocr_version = mmocr.__version__ + logger.info(f'mmocr: {mmocr_version}') -def check_codebase(): - ops = { - '>=': (lambda x, y: x >= y), - '==': (lambda x, y: x == y), - '<=': (lambda x, y: x <= y), - '': (lambda x, y: True) - } - with open('../requirements/optional.txt', 'r') as file: - try: - import mmcls - except ImportError: - mmcls_version = None - else: - mmcls_version = mmcls.__version__ - requirement = file.readline() - is_available = ops[get_op(requirement)](mmcls_version, - get_version(requirement)) - logger.info(f'mmcls: {mmcls_version} is_avaliable : {is_available}') - - try: - import mmdet - except ImportError: - mmdet_version = None - else: - mmdet_version = mmdet.__version__ - requirement = file.readline() - is_available = ops[get_op(requirement)](mmdet_version, - get_version(requirement)) - logger.info(f'mmdet: {mmdet_version} is_avaliable : {is_available}') - - try: - import mmedit - except ImportError: - mmedit_version = None - else: - mmedit_version = mmedit.__version__ - requirement = file.readline() - is_available = ops[get_op(requirement)](mmedit_version, - get_version(requirement)) - logger.info(f'mmedit: {mmedit_version} is_avaliable : {is_available}') - - try: - import mmocr - except ImportError: - mmocr_version = None - else: - mmocr_version = mmocr.__version__ - requirement = file.readline() - is_available = ops[get_op(requirement)](mmocr_version, - get_version(requirement)) - logger.info(f'mmocr: {mmocr_version} is_avaliable : {is_available}') - - try: - import mmseg - except ImportError: - mmseg_version = None - else: - mmseg_version = mmseg.__version__ - requirement = file.readline() - is_available = ops[get_op(requirement)](mmseg_version, - get_version(requirement)) - logger.info(f'mmseg: {mmseg_version} is_avaliable : {is_available}') + try: + import mmseg + except ImportError: + mmseg_version = None + else: + mmseg_version = mmseg.__version__ + logger.info(f'mmseg: {mmseg_version}') if __name__ == '__main__': logger = get_root_logger() + logger.info('\n') + logger.info('**********Environmental information**********') for name, val in collect_env().items(): logger.info('{}: {}'.format(name, val)) + logger.info('\n') + logger.info('**********Backend information**********') check_backend() + logger.info('\n') + logger.info('**********Codebase information**********') check_codebase()