From 7bb38af46396d3829482a94b4bc5b49a747150cc Mon Sep 17 00:00:00 2001 From: Jirka Borovec <Borda@users.noreply.github.com> Date: Thu, 22 Aug 2019 15:08:36 +0200 Subject: [PATCH] update CI - pkg build (#1235) * add testing in Travis * add proj. requirements * install CUDA * def tested packages * add missing meta in setup * add empty test * restructure travis tests * add sample doctest * switch to nose2 * add sample test * using pytest * minor fixes --- .travis.yml | 36 ++++++++++++++++++++++++++++++------ mmdet/utils/flops_counter.py | 12 ++++++++++++ requirements.txt | 9 +++++++++ setup.py | 2 ++ tests/requirements.txt | 5 +++++ tests/test_utils.py | 9 +++++++++ 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 requirements.txt create mode 100644 tests/requirements.txt create mode 100644 tests/test_utils.py diff --git a/.travis.yml b/.travis.yml index 35a68d79..30595047 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,39 @@ dist: xenial language: python -install: - - pip install isort flake8 yapf - python: - "3.5" - "3.6" - "3.7" +env: CUDA=9.2.148-1 CUDA_SHORT=9.2 UBUNTU_VERSION=ubuntu1604 + +# Ref to CUDA installation in Travis: https://github.com/jeremad/cuda-travis +before_install: + - INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb + - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER} + - sudo dpkg -i ${INSTALLER} + - wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub + - sudo apt-key add 7fa2af80.pub + - sudo apt update -qq + - sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-} + - sudo apt clean + - CUDA_HOME=/usr/local/cuda-${CUDA_SHORT} + - LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH} + - PATH=${CUDA_HOME}/bin:${PATH} + +install: + - pip install Cython + - pip install -r requirements.txt + - pip install -r tests/requirements.txt + script: - - flake8 - - isort -rc --check-only --diff mmdet/ tools/ - - yapf -r -d --style .style.yapf mmdet/ tools/ \ No newline at end of file + - flake8 . + - isort -rc --check-only --diff mmdet/ tools/ tests/ + - yapf -r -d --style .style.yapf mmdet/ tools/ tests/ + - python setup.py check -m -s + - python setup.py build_ext --inplace + - coverage run --source mmdet -m py.test tests -v --doctest-modules + +after_success: + - coverage report \ No newline at end of file diff --git a/mmdet/utils/flops_counter.py b/mmdet/utils/flops_counter.py index 3005a14f..5d9cdfce 100644 --- a/mmdet/utils/flops_counter.py +++ b/mmdet/utils/flops_counter.py @@ -101,6 +101,18 @@ def flops_to_string(flops, units='GMac', precision=2): def params_to_string(params_num): + """converting number to string + + :param float params_num: number + :returns str: number + + >>> params_to_string(1e9) + '1000.0 M' + >>> params_to_string(2e5) + '200.0 k' + >>> params_to_string(3e-9) + '3e-09' + """ if params_num // 10**6 > 0: return str(round(params_num / 10**6, 2)) + ' M' elif params_num // 10**3: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..f39f962d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +mmcv>=0.2.10 +numpy +matplotlib +six +terminaltables +pycocotools +torch>=1.1 +torchvision +imagecorruptions \ No newline at end of file diff --git a/setup.py b/setup.py index cf3a6e1d..976cc4bd 100644 --- a/setup.py +++ b/setup.py @@ -126,6 +126,8 @@ if __name__ == '__main__': version=get_version(), description='Open MMLab Detection Toolbox and Benchmark', long_description=readme(), + author='OpenMMLab', + author_email='chenkaidev@gmail.com', keywords='computer vision, object detection', url='https://github.com/open-mmlab/mmdetection', packages=find_packages(exclude=('configs', 'tools', 'demo')), diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 00000000..4eced799 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,5 @@ +isort +flake8 +yapf +pytest-cov +codecov \ No newline at end of file diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 00000000..cdefd2df --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,9 @@ +import numpy.testing as npt + +from mmdet.utils.flops_counter import params_to_string + + +def test_params_to_string(): + npt.assert_equal(params_to_string(1e9), '1000.0 M') + npt.assert_equal(params_to_string(2e5), '200.0 k') + npt.assert_equal(params_to_string(3e-9), '3e-09') -- GitLab