Skip to content

Commit

Permalink
Merge pull request open-mmlab#109 from hellock/fix-version
Browse files Browse the repository at this point in the history
Fix setup and CI
  • Loading branch information
hellock authored Jul 19, 2020
2 parents e1877e3 + 78fd637 commit d3a5227
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 61 deletions.
65 changes: 40 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,50 @@ 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 linting dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 isort==4.3.21 yapf interrogate
- name: Lint with flake8
run: flake8 .
- name: Lint with isort
run: isort --recursive --check-only --diff mmedit/ tools/ tests/ demo/
- name: Format python codes with yapf
run: yapf -r -d mmedit/ tools/ configs/ tests/ demo/
- name: Check docstring
run: interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmedit

build:
env:
CUDA: 10.1.105-1
CUDA_SHORT: 10.1
UBUNTU_VERSION: ubuntu1804
FORCE_CUDA: 1
MMCV_CUDA_ARGS: -gencode=arch=compute_61,code=sm_61
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7]
torch: [1.3.0, 1.5.0]
torch: [1.3.0+cpu, 1.5.0+cpu]
include:
- torch: 1.3.0
torchvision: 0.4.2
cuda_arch: "6.0"
- torch: 1.5.0
torchvision: 0.6.0
cuda_arch: "7.0"
- torch: 1.3.0+cpu
torchvision: 0.4.2+cpu
- torch: 1.5.0+cpu
torchvision: 0.6.0+cpu
- torch: 1.5.0+cpu
torchvision: 0.6.0+cpu
python-version: 3.8
- torch: 1.5.0+cu101
torchvision: 0.6.0+cu101
python-version: 3.7

steps:
- uses: actions/checkout@v2
Expand All @@ -30,6 +55,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install CUDA
if: ${{matrix.torch == '1.5.0+cu101'}}
run: |
export INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb
wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER}
Expand All @@ -44,35 +70,24 @@ jobs:
export PATH=${CUDA_HOME}/bin:${PATH}
sudo apt-get install -y ninja-build
- name: Install Pillow
if: ${{matrix.torchvision == '0.4.2+cpu'}}
run: pip install Pillow==6.2.2
if: ${{matrix.torchvision < 0.5}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}}
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install mmedit 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==latest+torch${{matrix.torch}} -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 mmedit/ tools/ tests/
- name: Format with yapf
run: yapf -r -d mmedit/ tools/ configs/ tests/
- name: Check docstring
run: interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmedit
- 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
run: rm -rf .eggs && pip install -e .
- name: Run unittests and generate coverage report
run: |
coverage run --branch --source mmedit -m pytest tests/
coverage xml
coverage report -m
# Only upload coverage report for python3.7 && pytorch1.5
- name: Upload coverage to Codecov
if: ${{matrix.torch == '1.5.0+cu101' && matrix.python-version == '3.7'}}
uses: codecov/[email protected]
with:
file: ./coverage.xml
Expand Down
1 change: 1 addition & 0 deletions mmedit/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
2 changes: 0 additions & 2 deletions requirements/runtime.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
future>=0.18.2
lmdb
mmcv-full>=1.0.0
scikit-image
tensorboard>=2.2.2
yapf
2 changes: 0 additions & 2 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ flake8
interrogate
isort==4.3.21
pytest
pytest-cov
pytest-runner
ubelt
51 changes: 19 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,15 @@
import os
import subprocess
import time
from functools import partial
from setuptools import find_packages, setup

import torch


def _get_extension():
if torch.__version__ == 'parrots':
from parrots.utils.build_extension import BuildExtension, Extension
CppExtension = partial(Extension, cuda=False)
CUDAExtension = partial(Extension, cuda=True)
else:
from torch.utils.cpp_extension import (BuildExtension, CppExtension,
CUDAExtension)
return BuildExtension, CppExtension, CUDAExtension


BuildExtension, CppExtension, CUDAExtension = _get_extension()


def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content


MAJOR = 0
MINOR = 1
PATCH = 0
SUFFIX = ''
if PATCH:
SHORT_VERSION = f'{MAJOR}.{MINOR}.{PATCH}{SUFFIX}'
else:
SHORT_VERSION = f'{MAJOR}.{MINOR}{SUFFIX}'

version_file = 'mmedit/version.py'


Expand Down Expand Up @@ -68,6 +42,12 @@ def _minimal_ext_cmd(cmd):
def get_hash():
if os.path.exists('.git'):
sha = get_git_hash()[:7]
elif os.path.exists(version_file):
try:
from mmdet.version import __version__
sha = __version__.split('+')[-1]
except ImportError:
raise ImportError('Unable to get git version')
else:
sha = 'unknown'

Expand All @@ -77,15 +57,21 @@ def get_hash():
def write_version_py():
content = """# GENERATED VERSION FILE
# TIME: {}
__version__ = '{}'
short_version = '{}'
version_info = ({})
"""
sha = get_hash()
with open('mmedit/VERSION', 'r') as f:
SHORT_VERSION = f.read().strip()
VERSION_INFO = ', '.join(
[x if x.isdigit() else f'"{x}"' for x in SHORT_VERSION.split('.')])
VERSION = SHORT_VERSION + '+' + sha

version_file_str = content.format(time.asctime(), VERSION, SHORT_VERSION,
VERSION_INFO)
with open(version_file, 'w') as f:
f.write(content.format(time.asctime(), VERSION, SHORT_VERSION))
f.write(version_file_str)


def get_version():
Expand Down Expand Up @@ -124,6 +110,8 @@ def parse_line(line):
info = {'line': line}
if line.startswith('-e '):
info['package'] = line.split('#egg=')[1]
elif '@git+' in line:
info['package'] = line
else:
# Remove versioning from the package
pat = '(' + '|'.join(['>=', '==', '>']) + ')'
Expand Down Expand Up @@ -175,10 +163,10 @@ def gen_packages_items():
setup(
name='mmedit',
version=get_version(),
description='Open MMLab Image and Video Editing Toolbox and Benchmark',
description='OpenMMLab Image and Video Editing Toolbox and Benchmark',
long_description=readme(),
maintainer='OpenMMLab',
maintainer_email='wxt1994@126.com',
maintainer='MMEditing Authors',
maintainer_email='openmmlab@gmail.com',
keywords='computer vision, inpainting, matting, '
'super-resolution, generation',
url='https://github.com/open-mmlab/mmediting',
Expand All @@ -199,5 +187,4 @@ def gen_packages_items():
'all': parse_requirements('requirements.txt'),
'tests': parse_requirements('requirements/tests.txt'),
},
cmdclass={'build_ext': BuildExtension},
zip_safe=False)

0 comments on commit d3a5227

Please sign in to comment.