Skip to content

Commit

Permalink
Add pypi deployment (#11)
Browse files Browse the repository at this point in the history
* add pypi deployment

* remove useless jobs

* fixed typo and cleanup

* delete build.tx

* add change log

Co-authored-by: Jiarui XU <[email protected]>
  • Loading branch information
hellock and xvjiarui authored Jul 13, 2020
1 parent 2fc821e commit bc285be
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ We use the following tools for linting and formatting:
- [yapf](https://github.com/google/yapf): formatter
- [isort](https://github.com/timothycrosley/isort): sort imports

Style configurations of yapf and isort can be found in [.style.yapf](../.style.yapf) and [.isort.cfg](../.isort.cfg).
Style configurations of yapf and isort can be found in [setup.cfg](../setup.cfg) and [.isort.cfg](../.isort.cfg).

We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`,
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
Expand Down
96 changes: 46 additions & 50 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: build

on: [push, pull_request]

jobs:

lint:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -53,49 +49,49 @@ jobs:
python-version: 3.7

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
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 https://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
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
if: ${{matrix.torchvision == '0.4.2+cpu'}}
run: pip install Pillow==6.2.2
- name: Install PyTorch
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install mmseg dependencies
run: |
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: Build and install
run: rm -rf .eggs && pip install -e .
- name: Run unittests and generate coverage report
run: |
coverage run --branch --source mmseg -m pytest tests/
coverage xml
coverage report -m --omit="mmseg/utils/*","mmseg/apis/*"
# 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
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
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 https://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
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
if: ${{matrix.torchvision == '0.4.2+cpu'}}
run: pip install Pillow==6.2.2
- name: Install PyTorch
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install mmseg dependencies
run: |
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: Build and install
run: rm -rf .eggs && pip install -e .
- name: Run unittests and generate coverage report
run: |
coverage run --branch --source mmseg -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
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: deploy

on: push

jobs:
build-n-publish:
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Build MMSegmentation
run: python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
run: |
pip install twine
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
4 changes: 0 additions & 4 deletions .style.yapf

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ The master branch works with **PyTorch 1.3 to 1.5**.

This project is released under the [Apache 2.0 license](LICENSE).

## Changelog

v0.5.0 was released in 10/7/2020.

## Benchmark and model zoo

Results and models are available in the [model zoo](docs/model_zoo.md).
Expand Down
38 changes: 12 additions & 26 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,31 @@ conda activate open-mmlab

b. Install PyTorch and torchvision following the [official instructions](https://pytorch.org/).
Here we use PyTorch 1.5.0 and CUDA 10.1.
You may also switch to other version by specifying version number.
You may also switch to other version by specifying the version number.

```shell
conda install pytorch=1.5.0 torchvision cudatoolkit=10.1 -c pytorch
```

c. Clone the mmsegmentation repository.
c. Install [MMCV](https://mmcv.readthedocs.io/en/latest/) following the [official instructions](https://mmcv.readthedocs.io/en/latest/#installation).
Either `mmcv` or `mmcv-full` is compatible with MMSegmentation, but for methods like CCNet and PSANet, CUDA ops in `mmcv-full` is required

```shell
git clone https://github.com/open-mmlab/mmsegmentation
cd mmsegmentation
```

d. Install [MMCV](https://mmcv.readthedocs.io/en/latest/).
Either *mmcv* or *mmcv-full* is compatible with MMSegmentation, but for methods like CCNet and PSANet, CUDA ops in *mmcv-full* is required
The pre-build mmcv-full (with PyTorch 1.5 and CUDA 10.1) can be installed by running: (other available versions could be found [here](https://mmcv.readthedocs.io/en/latest/#install-with-pip))

The pre-build *mmcv-full* could be installed by running: (available versions could be found [here](https://mmcv.readthedocs.io/en/latest/#install-with-pip))
```
```shell
pip install mmcv-full==latest+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
```

Optionally, you could also install lite version by running:
```
pip install mmcv
```
or build full version from source:
```
pip install mmcv-full
d. Install MMSegmentation.

```shell
pip install mmseg # install the latest release
```

e. Install build requirements and then install MMSegmentation.
or

```shell
pip install -r requirements/build.txt # or "pip install -r requirements.txt" for everything.
pip install -e . # or "python setup.py develop"
pip install git+https://github.com/open-mmlab/mmsegmentation.git # install the master branch
```

Note:
Expand All @@ -68,7 +58,6 @@ you can install it before installing MMCV.
4. Some dependencies are optional. Simply running `pip install -e .` will only install the minimum runtime requirements.
To use optional dependencies like `cityscapessripts` either install them manually with `pip install -r requirements/optional.txt` or specify desired extras when calling `pip` (e.g. `pip install -e .[optional]`). Valid keys for the extras field are: `all`, `tests`, `build`, and `optional`.


### A from-scratch setup script

Here is a full script for setting up mmsegmentation with conda and link the dataset path (supposing that your dataset path is $DATA_ROOT).
Expand All @@ -78,11 +67,8 @@ conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab

conda install pytorch=1.5.0 torchvision cudatoolkit=10.1 -c pytorch
git clone https://github.com/open-mmlab/mmsegmentation
cd mmsegmentation
pip install mmcv-full==latest+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
pip install -r requirements/build.txt
pip install -e .
pip install git+https://github.com/open-mmlab/mmsegmentation.git

mkdir data
ln -s $DATA_ROOT data
Expand Down
8 changes: 4 additions & 4 deletions docs/model_zoo.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ Please refer to [PSPNet](https://github.com/open-mmlab/mmsegmentation/blob/maste

### DeepLabV3

Please refer to [DeepLabV3](https://github.com/open-mmlab/mmsegmentatio/blob/master/configs/deeplabv3) for details.
Please refer to [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) for details.

### PSANet

Please refer to [PSANet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/psanet) for details.

### DeepLabV3+

Please refer to [DeepLabV3+](https://github.com/open-mmlab/mmsegmentatio/blob/master/configs/deeplabv3plus) for details.
Please refer to [DeepLabV3+](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3plus) for details.

### UPerNet

Please refer to [UPerNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/upernet) for details.

### NonLocal Net

Please refer to [NonLocal Net](https://github.com/open-mmlab/mmsegmentatio/blob/master/configs/nlnet) for details.
Please refer to [NonLocal Net](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/nlnet) for details.

### EncNet

Please refer to [NonLocal Net](https://github.com/open-mmlab/mmsegmentatio/blob/master/configs/encnet) for details.
Please refer to [NonLocal Net](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) for details.

### CCNet

Expand Down
4 changes: 2 additions & 2 deletions mmseg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .version import __version__, short_version
from .version import __version__, short_version, version_info

__all__ = ['__version__', 'short_version']
__all__ = ['__version__', 'short_version', 'version_info']
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
-r requirements/build.txt
-r requirements/optional.txt
-r requirements/runtime.txt
-r requirements/tests.txt
2 changes: 0 additions & 2 deletions requirements/build.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
asynctest
codecov
flake8
interrogate
Expand Down
33 changes: 0 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env python
import os
import subprocess
import time
from setuptools import find_packages, setup

import torch
from mmcv.utils.parrots_wrapper import (BuildExtension, CppExtension,
CUDAExtension)


def readme():
with open('README.md', encoding='utf-8') as f:
Expand Down Expand Up @@ -85,32 +80,6 @@ def get_version():
return locals()['__version__']


def make_cuda_ext(name, module, sources, sources_cuda=[]):

define_macros = []
extra_compile_args = {'cxx': []}

if torch.cuda.is_available() or os.getenv('FORCE_CUDA', '0') == '1':
define_macros += [('WITH_CUDA', None)]
extension = CUDAExtension
extra_compile_args['nvcc'] = [
'-D__CUDA_NO_HALF_OPERATORS__',
'-D__CUDA_NO_HALF_CONVERSIONS__',
'-D__CUDA_NO_HALF2_OPERATORS__',
]
sources += sources_cuda
else:
print('Compiling {} without CUDA'.format(name))
extension = CppExtension
# raise EnvironmentError('CUDA is required to compile MMSegmentation!')

return extension(
name='{}.{}'.format(module, name),
sources=[os.path.join(*module.split('.'), p) for p in sources],
define_macros=define_macros,
extra_compile_args=extra_compile_args)


def parse_requirements(fname='requirements.txt', with_version=True):
"""Parse the package dependencies listed in a requirements file but strips
specific versioning information.
Expand Down Expand Up @@ -199,7 +168,6 @@ def gen_packages_items():
keywords='computer vision, semantic segmentation',
url='https://github.com/open-mmlab/mmsegmentation',
packages=find_packages(exclude=('configs', 'tools', 'demo')),
package_data={'mmseg.ops': ['*/*.so']},
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: Apache Software License',
Expand All @@ -219,5 +187,4 @@ def gen_packages_items():
'optional': parse_requirements('requirements/optional.txt'),
},
ext_modules=[],
cmdclass={'build_ext': BuildExtension},
zip_safe=False)

0 comments on commit bc285be

Please sign in to comment.