Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pytest from the runtime dependencies #763

Merged
merged 4 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
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
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
run: python -c "import mmcv"
- name: Run unittests and generate coverage report
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

build_without_ops:
Expand All @@ -70,12 +71,14 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
- name: Install PyTorch
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
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
run: python -c "import mmcv"
- 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:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -107,12 +110,13 @@ jobs:
if: ${{matrix.torchvision == '0.4.2'}}
- name: Install PyTorch
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
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
run: python -c "import mmcv"
- name: Run unittests and generate coverage report
run: |
pip install -r requirements/test.txt
coverage run --branch --source=mmcv -m pytest tests/
coverage xml
coverage report -m
Expand Down Expand Up @@ -174,12 +178,13 @@ jobs:
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install system dependencies
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
run: rm -rf .eggs && pip install -e .
- name: Validate the installation
run: python -c "import mmcv"
- name: Run unittests and generate coverage report
run: |
pip install -r requirements/test.txt
coverage run --branch --source=mmcv -m pytest tests/ --ignore=tests/test_ops/test_onnx.py
coverage xml
coverage report -m
Expand Down Expand Up @@ -216,8 +221,6 @@ jobs:
python-version: 3.7
- name: Install system dependencies
run: brew install ffmpeg jpeg-turbo
- name: Install unittest dependencies
run: pip install -r requirements/test.txt
- name: Install Pillow
run: pip install Pillow==6.2.2
if: ${{matrix.torchvision == '0.4.2'}}
Expand All @@ -227,7 +230,10 @@ jobs:
run: |
rm -rf .eggs
CC=clang CXX=clang++ CFLAGS='-stdlib=libc++' pip install -e .
- name: Validate the installation
run: python -c "import mmcv"
- name: Run unittests
run: |
pip install -r requirements/test.txt
# 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
5 changes: 2 additions & 3 deletions mmcv/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
DataLoader, PoolDataLoader, SyncBatchNorm, _AdaptiveAvgPoolNd,
_AdaptiveMaxPoolNd, _AvgPoolNd, _BatchNorm, _ConvNd,
_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
__all__ = [
'Config', 'ConfigDict', 'DictAction', 'collect_env', 'get_logger',
Expand All @@ -49,6 +49,5 @@
'_InstanceNorm', '_MaxPoolNd', 'get_build_config', 'BuildExtension',
'CppExtension', 'CUDAExtension', 'DataLoader', 'PoolDataLoader',
'TORCH_VERSION', 'deprecated_api_warning', 'digit_version',
'get_git_hash', 'import_modules_from_strings', 'jit', 'skip_no_elena',
'skip_no_parrots'
'get_git_hash', 'import_modules_from_strings', 'jit', 'skip_no_elena'
]
13 changes: 1 addition & 12 deletions mmcv/utils/parrots_jit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import pytest
import torch

TORCH_VERSION = torch.__version__
from .parrots_wrapper import TORCH_VERSION

if TORCH_VERSION == 'parrots':
from parrots.jit import pat as jit
Expand Down Expand Up @@ -37,11 +34,3 @@ def wrapper(*args, **kargs):
return func(*args, **kargs)

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')
14 changes: 9 additions & 5 deletions tests/test_utils/test_parrots_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import torch

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):
Expand Down Expand Up @@ -55,7 +59,7 @@ def add_list_pyfunc(oper, x, y):
assert f'k{idx}' in rets_t
assert (rets[f'k{idx}'] == rets_t[f'k{idx}']).all()

@mmcv.skip_no_parrots
@skip_no_parrots
def test_jit_cache(self):

@mmcv.jit
Expand Down Expand Up @@ -88,7 +92,7 @@ def pyfunc(oper):
rets_a = (rets_minus_t + rets_plus_t) / 4
assert torch.allclose(oper['x'], rets_a)

@mmcv.skip_no_parrots
@skip_no_parrots
def test_jit_shape(self):

@mmcv.jit
Expand All @@ -109,7 +113,7 @@ def func(a):
assert (r == 2).all()
assert len(func._cache._cache) == 2

@mmcv.skip_no_parrots
@skip_no_parrots
def test_jit_kwargs(self):

@mmcv.jit
Expand Down Expand Up @@ -206,7 +210,7 @@ def pyfunc(a, b):
d = pyfunc(a, b)
assert torch.allclose(c, d)

@mmcv.skip_no_parrots
@skip_no_parrots
def test_jit_check_input(self):

def func(x):
Expand All @@ -217,7 +221,7 @@ def func(x):
with pytest.raises(AssertionError):
func = mmcv.jit(func, check_input=(a, ))

@mmcv.skip_no_parrots
@skip_no_parrots
def test_jit_partial_shape(self):

@mmcv.jit(full_shape=False)
Expand Down