Skip to content

Commit

Permalink
use mmengine.Config instead of mmcv.Config (#155)
Browse files Browse the repository at this point in the history
* use mmengine.Config instead of mmcv.Config

* install mmengine in CI

* fix mmengine install issue
  • Loading branch information
ice-tong authored Sep 1, 2022
1 parent 2d9e2da commit 23e6342
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion mim/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}...')
Expand Down
4 changes: 2 additions & 2 deletions mim/commands/gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions tests/test_gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'])
Expand Down Expand Up @@ -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

0 comments on commit 23e6342

Please sign in to comment.