From 78fda0aca02263e4c16bd19a38f1ef29acbba06a Mon Sep 17 00:00:00 2001
From: Kai Chen <chenkaidev@gmail.com>
Date: Mon, 27 Jul 2020 10:51:05 +0800
Subject: [PATCH] Update to pytorch 1.3.1 and 1.5.1 in CI (#3413)

* update to pytorch 1.3.1 and 1.5.1 in CI

* add build_cpu and lint jobs

* add missing dependencies

* fix mmcv version

* fix variable name

* add missing dependencies
---
 .github/workflows/build.yml | 70 ++++++++++++++++++++++++++-----------
 setup.py                    |  9 +++--
 2 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 24b7e53d..dedf9480 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -3,24 +3,66 @@ name: build
 on: [push, pull_request]
 
 jobs:
-  build:
+  lint:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python 3.7
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.7
+      - name: Install pre-commit hook
+        run: |
+          pip install pre-commit
+          pre-commit install
+      - name: Linting
+        run: pre-commit run --all-files
+      - name: Check docstring coverage
+        run: |
+          pip install interrogate
+          interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmdet
+
+  build_cpu:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: Set up Python 3.7
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.7
+      - name: Install PyTorch
+        run: pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
+      - name: Install MMCV
+        run: pip install mmcv-full==latest+torch1.5.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
+      - name: Install unittest dependencies
+        run: pip install -r requirements/tests.txt -r requirements/optional.txt
+      - name: Build and install
+        run: rm -rf .eggs && pip install -e .
+      - name: Run unittests and generate coverage report
+        run: |
+          coverage run --branch --source mmdet -m pytest tests/
+          coverage xml
+          coverage report -m
+
+  build_cuda:
     runs-on: ubuntu-latest
 
     env:
       CUDA: 10.1.105-1
       CUDA_SHORT: 10.1
       UBUNTU_VERSION: ubuntu1804
-      FORCE_CUDA: 1
     strategy:
       matrix:
         python-version: [3.6, 3.7]
-        torch: [1.3.0, 1.5.0]
+        torch: [1.3.1, 1.5.1]
         include:
-          - torch: 1.3.0
+          - torch: 1.3.1
             torchvision: 0.4.2
+            mmcv: "latest+torch1.3.0+cu101"
             cuda_arch: "6.0"
-          - torch: 1.5.0
-            torchvision: 0.6.0
+          - torch: 1.5.1
+            torchvision: 0.6.1
+            mmcv: "latest+torch1.5.0+cu101"
             cuda_arch: "7.0"
 
     steps:
@@ -42,7 +84,6 @@ jobs:
           export CUDA_HOME=/usr/local/cuda-${CUDA_SHORT}
           export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH}
           export PATH=${CUDA_HOME}/bin:${PATH}
-          sudo apt-get install -y ninja-build
       - name: Install Pillow
         run: pip install Pillow==6.2.2
         if: ${{matrix.torchvision < 0.5}}
@@ -50,24 +91,13 @@ jobs:
         run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}}
       - name: Install mmdet dependencies
         run: |
-          pip install mmcv-full==latest+torch${{matrix.torch}}+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
+          pip install mmcv-full==${{matrix.mmcv}} -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
           pip install -r requirements.txt
-      - name: Lint with flake8
-        run: flake8 .
-      - name: Lint with isort
-        run: isort --recursive --check-only --diff mmdet/ tools/ tests/
-      - name: Format with yapf
-        run: yapf -r -d mmdet/ tools/ configs/ tests/
-      - name: Check docstring
-        run: interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmdet
       - name: Build and install
-        env:
-          CUDA_ARCH: ${{matrix.cuda_arch}}
         run: |
           rm -rf .eggs
           python setup.py check -m -s
-          TORCH_CUDA_ARCH_LIST=${CUDA_ARCH} python setup.py build_ext --inplace
-
+          TORCH_CUDA_ARCH_LIST=${{matrix.cuda_arch}} pip install .
       - name: Run unittests and generate coverage report
         run: |
           coverage run --branch --source mmdet -m pytest tests/
diff --git a/setup.py b/setup.py
index f26ad3b3..3db76fa1 100755
--- a/setup.py
+++ b/setup.py
@@ -103,7 +103,6 @@ def make_cuda_ext(name, module, sources, sources_cuda=[]):
     else:
         print(f'Compiling {name} without CUDA')
         extension = CppExtension
-        # raise EnvironmentError('CUDA is required to compile MMDetection!')
 
     return extension(
         name=f'{module}.{name}',
@@ -195,21 +194,21 @@ if __name__ == '__main__':
     setup(
         name='mmdet',
         version=get_version(),
-        description='Open MMLab Detection Toolbox and Benchmark',
+        description='OpenMMLab Detection Toolbox and Benchmark',
         long_description=readme(),
         author='OpenMMLab',
-        author_email='chenkaidev@gmail.com',
+        author_email='openmmlab@gmail.com',
         keywords='computer vision, object detection',
         url='https://github.com/open-mmlab/mmdetection',
         packages=find_packages(exclude=('configs', 'tools', 'demo')),
         classifiers=[
-            'Development Status :: 4 - Beta',
+            'Development Status :: 5 - Production/Stable',
             'License :: OSI Approved :: Apache Software License',
             'Operating System :: OS Independent',
             'Programming Language :: Python :: 3',
-            'Programming Language :: Python :: 3.5',
             'Programming Language :: Python :: 3.6',
             'Programming Language :: Python :: 3.7',
+            'Programming Language :: Python :: 3.8',
         ],
         license='Apache License 2.0',
         setup_requires=parse_requirements('requirements/build.txt'),
-- 
GitLab