From 23e63429aeeb03c7d3b8b728730abf3c3cdc5572 Mon Sep 17 00:00:00 2001 From: yancong <32220263+ice-tong@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:33:31 +0800 Subject: [PATCH] use mmengine.Config instead of mmcv.Config (#155) * use mmengine.Config instead of mmcv.Config * install mmengine in CI * fix mmengine install issue --- mim/commands/download.py | 6 +++++- mim/commands/gridsearch.py | 4 ++-- tests/test_download.py | 6 ++++++ tests/test_gridsearch.py | 6 ++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mim/commands/download.py b/mim/commands/download.py index 0a9ea1f..a4941f8 100644 --- a/mim/commands/download.py +++ b/mim/commands/download.py @@ -86,7 +86,11 @@ def download(package: str, highlighted_error(f'Expected configs: {valid_configs}, but got ' f'{invalid_configs}')) - from mmcv import Config + try: + from mmengine import Config + except ImportError: + msg = 'Please install mmengine to use the download command.' + raise ImportError(highlighted_error(msg)) for config in configs: click.echo(f'processing {config}...') diff --git a/mim/commands/gridsearch.py b/mim/commands/gridsearch.py index daaaabe..5f99ac6 100644 --- a/mim/commands/gridsearch.py +++ b/mim/commands/gridsearch.py @@ -270,9 +270,9 @@ def gridsearch( raise ValueError(highlighted_error(msg)) try: - from mmcv import Config + from mmengine import Config except ImportError: - msg = 'Please install mmcv to use the gridsearch command.' + msg = 'Please install mmengine to use the gridsearch command.' raise ImportError(highlighted_error(msg)) cfg = Config.fromfile(config) diff --git a/tests/test_download.py b/tests/test_download.py index e231455..7413303 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -11,6 +11,8 @@ def setup_module(): runner = CliRunner() result = runner.invoke(uninstall, ['mmcv-full', '--yes']) assert result.exit_code == 0 + result = runner.invoke(uninstall, ['mmengine', '--yes']) + assert result.exit_code == 0 result = runner.invoke(uninstall, ['mmcls', '--yes']) assert result.exit_code == 0 @@ -19,6 +21,8 @@ def test_download(tmp_path): runner = CliRunner() result = runner.invoke(install, ['mmcv-full', '--yes']) assert result.exit_code == 0 + result = runner.invoke(install, ['mmengine', '--yes']) + assert result.exit_code == 0 with pytest.raises(ValueError): # version is not allowed @@ -54,5 +58,7 @@ def teardown_module(): runner = CliRunner() result = runner.invoke(uninstall, ['mmcv-full', '--yes']) assert result.exit_code == 0 + result = runner.invoke(uninstall, ['mmengine', '--yes']) + assert result.exit_code == 0 result = runner.invoke(uninstall, ['mmcls', '--yes']) assert result.exit_code == 0 diff --git a/tests/test_gridsearch.py b/tests/test_gridsearch.py index 75bb5e4..445a1d8 100644 --- a/tests/test_gridsearch.py +++ b/tests/test_gridsearch.py @@ -13,6 +13,8 @@ def setup_module(): runner = CliRunner() result = runner.invoke(uninstall, ['mmcv-full', '--yes']) assert result.exit_code == 0 + result = runner.invoke(uninstall, ['mmengine', '--yes']) + assert result.exit_code == 0 result = runner.invoke(uninstall, ['mmcls', '--yes']) assert result.exit_code == 0 @@ -28,6 +30,8 @@ def test_gridsearch(gpus, tmp_path): runner = CliRunner() result = runner.invoke(install, ['mmcls', '--yes']) assert result.exit_code == 0 + result = runner.invoke(install, ['mmengine', '--yes']) + assert result.exit_code == 0 # Since `mminstall.txt` is not included in the distribution of # mmcls<=0.23.1, we need to install mmcv-full manually. result = runner.invoke(install, ['mmcv-full', '--yes']) @@ -68,5 +72,7 @@ def teardown_module(): runner = CliRunner() result = runner.invoke(uninstall, ['mmcv-full', '--yes']) assert result.exit_code == 0 + result = runner.invoke(uninstall, ['mmengine', '--yes']) + assert result.exit_code == 0 result = runner.invoke(uninstall, ['mmcls', '--yes']) assert result.exit_code == 0