mirror of
https://github.com/open-mmlab/mmcv.git
synced 2025-06-03 21:54:52 +08:00
Remove pytest from the runtime dependencies (#763)
* update the CI to avoid extra dependencies * remove the dependency of pytest * fix typo * remove skip_no_parrots from __init__
This commit is contained in:
parent
5d488e4a2a
commit
c1acedcc3b
28
.github/workflows/build.yml
vendored
28
.github/workflows/build.yml
vendored
@ -41,12 +41,13 @@ jobs:
|
|||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
|
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
|
||||||
- name: Install unittest dependencies
|
|
||||||
run: pip install -r requirements/test.txt
|
|
||||||
- name: Build and install
|
- name: Build and install
|
||||||
run: rm -rf .eggs && pip install -e .
|
run: rm -rf .eggs && pip install -e .
|
||||||
|
- name: Validate the installation
|
||||||
|
run: python -c "import mmcv"
|
||||||
- name: Run unittests and generate coverage report
|
- name: Run unittests and generate coverage report
|
||||||
run: |
|
run: |
|
||||||
|
pip install -r requirements/test.txt
|
||||||
pytest tests/ --ignore=tests/test_runner --ignore=tests/test_optimizer.py --ignore=tests/test_cnn --ignore=tests/test_parallel.py --ignore=tests/test_ops --ignore=tests/test_load_model_zoo.py --ignore=tests/test_utils/test_logging.py --ignore=tests/test_image/test_io.py --ignore=tests/test_utils/test_registry.py --ignore=tests/test_utils/test_parrots_jit.py
|
pytest tests/ --ignore=tests/test_runner --ignore=tests/test_optimizer.py --ignore=tests/test_cnn --ignore=tests/test_parallel.py --ignore=tests/test_ops --ignore=tests/test_load_model_zoo.py --ignore=tests/test_utils/test_logging.py --ignore=tests/test_image/test_io.py --ignore=tests/test_utils/test_registry.py --ignore=tests/test_utils/test_parrots_jit.py
|
||||||
|
|
||||||
build_without_ops:
|
build_without_ops:
|
||||||
@ -70,12 +71,14 @@ jobs:
|
|||||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
|
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
|
||||||
- name: Install PyTorch
|
- name: Install PyTorch
|
||||||
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||||
- name: Install unittest dependencies
|
|
||||||
run: pip install -r requirements/test.txt
|
|
||||||
- name: Build and install
|
- name: Build and install
|
||||||
run: rm -rf .eggs && pip install -e .
|
run: rm -rf .eggs && pip install -e .
|
||||||
|
- name: Validate the installation
|
||||||
|
run: python -c "import mmcv"
|
||||||
- name: Run unittests
|
- name: Run unittests
|
||||||
run: pytest tests/ --ignore=tests/test_ops
|
run: |
|
||||||
|
pip install -r requirements/test.txt
|
||||||
|
pytest tests/ --ignore=tests/test_ops
|
||||||
|
|
||||||
build_cpu:
|
build_cpu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -107,12 +110,13 @@ jobs:
|
|||||||
if: ${{matrix.torchvision == '0.4.2'}}
|
if: ${{matrix.torchvision == '0.4.2'}}
|
||||||
- name: Install PyTorch
|
- name: Install PyTorch
|
||||||
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||||
- name: Install unittest dependencies
|
|
||||||
run: pip install -r requirements/test.txt
|
|
||||||
- name: Build and install
|
- name: Build and install
|
||||||
run: rm -rf .eggs && pip install -e .
|
run: rm -rf .eggs && pip install -e .
|
||||||
|
- name: Validate the installation
|
||||||
|
run: python -c "import mmcv"
|
||||||
- name: Run unittests and generate coverage report
|
- name: Run unittests and generate coverage report
|
||||||
run: |
|
run: |
|
||||||
|
pip install -r requirements/test.txt
|
||||||
coverage run --branch --source=mmcv -m pytest tests/
|
coverage run --branch --source=mmcv -m pytest tests/
|
||||||
coverage xml
|
coverage xml
|
||||||
coverage report -m
|
coverage report -m
|
||||||
@ -174,12 +178,13 @@ jobs:
|
|||||||
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
|
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
|
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
|
||||||
- name: Install unittest dependencies
|
|
||||||
run: pip install -r requirements/test.txt
|
|
||||||
- name: Build and install
|
- name: Build and install
|
||||||
run: rm -rf .eggs && pip install -e .
|
run: rm -rf .eggs && pip install -e .
|
||||||
|
- name: Validate the installation
|
||||||
|
run: python -c "import mmcv"
|
||||||
- name: Run unittests and generate coverage report
|
- name: Run unittests and generate coverage report
|
||||||
run: |
|
run: |
|
||||||
|
pip install -r requirements/test.txt
|
||||||
coverage run --branch --source=mmcv -m pytest tests/ --ignore=tests/test_ops/test_onnx.py
|
coverage run --branch --source=mmcv -m pytest tests/ --ignore=tests/test_ops/test_onnx.py
|
||||||
coverage xml
|
coverage xml
|
||||||
coverage report -m
|
coverage report -m
|
||||||
@ -216,8 +221,6 @@ jobs:
|
|||||||
python-version: 3.7
|
python-version: 3.7
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: brew install ffmpeg jpeg-turbo
|
run: brew install ffmpeg jpeg-turbo
|
||||||
- name: Install unittest dependencies
|
|
||||||
run: pip install -r requirements/test.txt
|
|
||||||
- name: Install Pillow
|
- name: Install Pillow
|
||||||
run: pip install Pillow==6.2.2
|
run: pip install Pillow==6.2.2
|
||||||
if: ${{matrix.torchvision == '0.4.2'}}
|
if: ${{matrix.torchvision == '0.4.2'}}
|
||||||
@ -227,7 +230,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
rm -rf .eggs
|
rm -rf .eggs
|
||||||
CC=clang CXX=clang++ CFLAGS='-stdlib=libc++' pip install -e .
|
CC=clang CXX=clang++ CFLAGS='-stdlib=libc++' pip install -e .
|
||||||
|
- name: Validate the installation
|
||||||
|
run: python -c "import mmcv"
|
||||||
- name: Run unittests
|
- name: Run unittests
|
||||||
run: |
|
run: |
|
||||||
|
pip install -r requirements/test.txt
|
||||||
# The timing on macos VMs is not precise, so we skip the progressbar tests
|
# The timing on macos VMs is not precise, so we skip the progressbar tests
|
||||||
pytest tests/ --ignore tests/test_utils/test_progressbar.py --ignore tests/test_utils/test_timer.py
|
pytest tests/ --ignore tests/test_utils/test_progressbar.py --ignore tests/test_utils/test_timer.py
|
||||||
|
@ -33,7 +33,7 @@ else:
|
|||||||
DataLoader, PoolDataLoader, SyncBatchNorm, _AdaptiveAvgPoolNd,
|
DataLoader, PoolDataLoader, SyncBatchNorm, _AdaptiveAvgPoolNd,
|
||||||
_AdaptiveMaxPoolNd, _AvgPoolNd, _BatchNorm, _ConvNd,
|
_AdaptiveMaxPoolNd, _AvgPoolNd, _BatchNorm, _ConvNd,
|
||||||
_ConvTransposeMixin, _InstanceNorm, _MaxPoolNd, get_build_config)
|
_ConvTransposeMixin, _InstanceNorm, _MaxPoolNd, get_build_config)
|
||||||
from .parrots_jit import jit, skip_no_elena, skip_no_parrots
|
from .parrots_jit import jit, skip_no_elena
|
||||||
from .registry import Registry, build_from_cfg
|
from .registry import Registry, build_from_cfg
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'Config', 'ConfigDict', 'DictAction', 'collect_env', 'get_logger',
|
'Config', 'ConfigDict', 'DictAction', 'collect_env', 'get_logger',
|
||||||
@ -49,6 +49,5 @@ else:
|
|||||||
'_InstanceNorm', '_MaxPoolNd', 'get_build_config', 'BuildExtension',
|
'_InstanceNorm', '_MaxPoolNd', 'get_build_config', 'BuildExtension',
|
||||||
'CppExtension', 'CUDAExtension', 'DataLoader', 'PoolDataLoader',
|
'CppExtension', 'CUDAExtension', 'DataLoader', 'PoolDataLoader',
|
||||||
'TORCH_VERSION', 'deprecated_api_warning', 'digit_version',
|
'TORCH_VERSION', 'deprecated_api_warning', 'digit_version',
|
||||||
'get_git_hash', 'import_modules_from_strings', 'jit', 'skip_no_elena',
|
'get_git_hash', 'import_modules_from_strings', 'jit', 'skip_no_elena'
|
||||||
'skip_no_parrots'
|
|
||||||
]
|
]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import pytest
|
from .parrots_wrapper import TORCH_VERSION
|
||||||
import torch
|
|
||||||
|
|
||||||
TORCH_VERSION = torch.__version__
|
|
||||||
|
|
||||||
if TORCH_VERSION == 'parrots':
|
if TORCH_VERSION == 'parrots':
|
||||||
from parrots.jit import pat as jit
|
from parrots.jit import pat as jit
|
||||||
@ -37,11 +34,3 @@ else:
|
|||||||
return func(*args, **kargs)
|
return func(*args, **kargs)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def is_using_parrots():
|
|
||||||
return TORCH_VERSION == 'parrots'
|
|
||||||
|
|
||||||
|
|
||||||
skip_no_parrots = pytest.mark.skipif(
|
|
||||||
not is_using_parrots(), reason='test case under parrots environment')
|
|
||||||
|
@ -2,6 +2,10 @@ import pytest
|
|||||||
import torch
|
import torch
|
||||||
|
|
||||||
import mmcv
|
import mmcv
|
||||||
|
from mmcv.utils import TORCH_VERSION
|
||||||
|
|
||||||
|
skip_no_parrots = pytest.mark.skipif(
|
||||||
|
TORCH_VERSION != 'parrots', reason='test case under parrots environment')
|
||||||
|
|
||||||
|
|
||||||
class TestJit(object):
|
class TestJit(object):
|
||||||
@ -55,7 +59,7 @@ class TestJit(object):
|
|||||||
assert f'k{idx}' in rets_t
|
assert f'k{idx}' in rets_t
|
||||||
assert (rets[f'k{idx}'] == rets_t[f'k{idx}']).all()
|
assert (rets[f'k{idx}'] == rets_t[f'k{idx}']).all()
|
||||||
|
|
||||||
@mmcv.skip_no_parrots
|
@skip_no_parrots
|
||||||
def test_jit_cache(self):
|
def test_jit_cache(self):
|
||||||
|
|
||||||
@mmcv.jit
|
@mmcv.jit
|
||||||
@ -88,7 +92,7 @@ class TestJit(object):
|
|||||||
rets_a = (rets_minus_t + rets_plus_t) / 4
|
rets_a = (rets_minus_t + rets_plus_t) / 4
|
||||||
assert torch.allclose(oper['x'], rets_a)
|
assert torch.allclose(oper['x'], rets_a)
|
||||||
|
|
||||||
@mmcv.skip_no_parrots
|
@skip_no_parrots
|
||||||
def test_jit_shape(self):
|
def test_jit_shape(self):
|
||||||
|
|
||||||
@mmcv.jit
|
@mmcv.jit
|
||||||
@ -109,7 +113,7 @@ class TestJit(object):
|
|||||||
assert (r == 2).all()
|
assert (r == 2).all()
|
||||||
assert len(func._cache._cache) == 2
|
assert len(func._cache._cache) == 2
|
||||||
|
|
||||||
@mmcv.skip_no_parrots
|
@skip_no_parrots
|
||||||
def test_jit_kwargs(self):
|
def test_jit_kwargs(self):
|
||||||
|
|
||||||
@mmcv.jit
|
@mmcv.jit
|
||||||
@ -206,7 +210,7 @@ class TestJit(object):
|
|||||||
d = pyfunc(a, b)
|
d = pyfunc(a, b)
|
||||||
assert torch.allclose(c, d)
|
assert torch.allclose(c, d)
|
||||||
|
|
||||||
@mmcv.skip_no_parrots
|
@skip_no_parrots
|
||||||
def test_jit_check_input(self):
|
def test_jit_check_input(self):
|
||||||
|
|
||||||
def func(x):
|
def func(x):
|
||||||
@ -217,7 +221,7 @@ class TestJit(object):
|
|||||||
with pytest.raises(AssertionError):
|
with pytest.raises(AssertionError):
|
||||||
func = mmcv.jit(func, check_input=(a, ))
|
func = mmcv.jit(func, check_input=(a, ))
|
||||||
|
|
||||||
@mmcv.skip_no_parrots
|
@skip_no_parrots
|
||||||
def test_jit_partial_shape(self):
|
def test_jit_partial_shape(self):
|
||||||
|
|
||||||
@mmcv.jit(full_shape=False)
|
@mmcv.jit(full_shape=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user