| name: build |
|
|
| on: |
| |
| push: |
| branches: |
| - master |
| pull_request: |
|
|
| jobs: |
| |
| |
| |
| |
| flake8-py3: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v2 |
| - name: Set up Python 3.7 |
| uses: actions/setup-python@v1 |
| with: |
| python-version: 3.7 |
| - name: cache weekly timestamp |
| id: pip-cache |
| run: | |
| echo "::set-output name=datew::$(date '+%Y-%V')" |
| - name: cache for pip |
| uses: actions/cache@v2 |
| id: cache |
| with: |
| path: ~/.cache/pip |
| key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip wheel |
| python -m pip install -r requirements-dev.txt |
| - name: Lint and type check |
| run: | |
| # clean up temporary files |
| $(pwd)/runtests.sh --clean |
| # Git hub actions have 2 cores, so parallize pytype |
| $(pwd)/runtests.sh --nounittests --codeformat -j 2 |
| |
| quick-py3: |
| runs-on: ${{ matrix.os }} |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [windows-latest, macOS-latest, ubuntu-latest] |
| timeout-minutes: 20 |
| steps: |
| - uses: actions/checkout@v2 |
| - name: Set up Python 3.x |
| uses: actions/setup-python@v1 |
| with: |
| python-version: '3.x' |
| - name: Prepare pip wheel |
| run: | |
| which python |
| python -m pip install --upgrade pip wheel |
| - name: cache weekly timestamp |
| id: pip-cache |
| run: | |
| echo "::set-output name=datew::$(date '+%Y-%V')" |
| echo "::set-output name=dir::$(pip cache dir)" |
| shell: bash |
| - name: cache for pip |
| uses: actions/cache@v2 |
| id: cache |
| with: |
| path: ${{ steps.pip-cache.outputs.dir }} |
| key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} |
| - if: runner.os == 'windows' |
| name: Install torch cpu from pytorch.org (Windows only) |
| run: | |
| python -m pip install torch==1.4 -f https://download.pytorch.org/whl/cpu/torch_stable.html |
| python -m pip install torchvision==0.5.0 |
| # min. requirements for windows instances |
| python -c "f=open('requirements-dev.txt', 'r'); txt=f.readlines(); f.close(); print(txt); f=open('requirements-dev.txt', 'w'); f.writelines(txt[1:12]); f.close()" |
| - name: Install the dependencies |
| run: | |
| python -m pip install torch==1.4 |
| python -m pip install torchvision==0.5.0 |
| cat "requirements-dev.txt" |
| python -m pip install -r requirements-dev.txt |
| python -m pip list |
| python setup.py develop # compile the cpp extensions |
| - name: Run quick tests (CPU ${{ runner.os }}) |
| run: | |
| python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' |
| python -m unittest -v |
| env: |
| QUICKTEST: True |
|
|
| GPU-quick-py3: |
| strategy: |
| matrix: |
| environment: |
| - "PT15+CUDA101" |
| - "PT16+CUDA101" |
| - "PT15+CUDA102" |
| - "PT16+CUDA102" |
| - "PT16+CUDA110" |
| include: |
| - environment: PT15+CUDA101 |
| pytorch: "torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html" |
| base: "nvcr.io/nvidia/cuda:10.1-devel-ubuntu18.04" |
| - environment: PT16+CUDA101 |
| pytorch: "torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html" |
| base: "nvcr.io/nvidia/cuda:10.1-devel-ubuntu18.04" |
| - environment: PT15+CUDA102 |
| pytorch: "torch==1.5.0 torchvision==0.6.0" |
| base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" |
| - environment: PT16+CUDA102 |
| pytorch: "torch torchvision" |
| base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" |
| - environment: PT16+CUDA110 |
| |
| pytorch: "-h" |
| base: "nvcr.io/nvidia/pytorch:20.07-py3" |
| container: |
| image: ${{ matrix.base }} |
| options: --gpus all |
| runs-on: [self-hosted, linux, x64] |
| steps: |
| - uses: actions/checkout@v2 |
| - name: apt install |
| run: | |
| if [ ${{ matrix.environment }} != "PT16+CUDA110" ]; then \ |
| PYVER=3.6 PYSFX=3 DISTUTILS=python3-distutils && \ |
| apt-get update && apt-get install -y --no-install-recommends \ |
| curl \ |
| pkg-config \ |
| python$PYVER \ |
| python$PYVER-dev \ |
| python$PYSFX-pip \ |
| $DISTUTILS \ |
| rsync \ |
| swig \ |
| unzip \ |
| zip \ |
| zlib1g-dev \ |
| libboost-locale-dev \ |
| libboost-program-options-dev \ |
| libboost-system-dev \ |
| libboost-thread-dev \ |
| libboost-test-dev \ |
| libgoogle-glog-dev \ |
| libjsoncpp-dev \ |
| cmake && \ |
| rm -rf /var/lib/apt/lists/* && \ |
| export PYTHONIOENCODING=utf-8 LC_ALL=C.UTF-8 && \ |
| rm -f /usr/bin/python && \ |
| rm -f /usr/bin/python`echo $PYVER | cut -c1-1` && \ |
| ln -s /usr/bin/python$PYVER /usr/bin/python && \ |
| ln -s /usr/bin/python$PYVER /usr/bin/python`echo $PYVER | cut -c1-1` && |
| curl -O https://bootstrap.pypa.io/get-pip.py && \ |
| python get-pip.py && \ |
| rm get-pip.py ; fi |
| - name: Install dependencies |
| run: | |
| which python |
| python -m pip install --upgrade pip wheel |
| python -m pip install ${{ matrix.pytorch }} |
| python -m pip install -r requirements-dev.txt |
| - name: Run quick tests (GPU) |
| run: | |
| python -m pip list |
| nvidia-smi |
| export CUDA_VISIBLE_DEVICES=$(python -m tests.utils) |
| echo $CUDA_VISIBLE_DEVICES |
| python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))" |
| python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))' |
| ./runtests.sh --quick |
| coverage xml |
| - name: Upload coverage |
| uses: codecov/codecov-action@v1 |
| with: |
| file: ./coverage.xml |
|
|
| packaging: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v2 |
| with: |
| fetch-depth: 0 |
| - name: Set up Python 3.x |
| uses: actions/setup-python@v1 |
| with: |
| python-version: '3.x' |
| - name: cache weekly timestamp |
| id: pip-cache |
| run: | |
| echo "::set-output name=datew::$(date '+%Y-%V')" |
| - name: cache for pip |
| uses: actions/cache@v2 |
| id: cache |
| with: |
| path: ~/.cache/pip |
| key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} |
| - name: Install dependencies |
| run: | |
| python -m pip install --user --upgrade pip setuptools wheel twine |
| # install the latest pytorch for testing |
| # however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated |
| # fresh torch installation according to pyproject.toml |
| python -m pip install torch>=1.4 torchvision |
| - name: Test source archive and wheel file |
| run: | |
| git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| root_dir=$PWD |
| echo "$root_dir" |
| set -e |
| |
| |
| python setup.py check -m -s |
| python setup.py sdist bdist_wheel |
| python -m twine check dist/* |
|
|
| |
| tmp_dir=$(mktemp -d) |
| cp dist/monai* "$tmp_dir" |
| rm -r build dist monai.egg-info |
| cd "$tmp_dir" |
| ls -al |
|
|
| |
| python -m pip install monai*.whl |
| python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown" |
| python -c 'import monai; print(monai.__file__)' |
| python -m pip uninstall -y monai |
| rm monai*.whl |
|
|
| |
| python -m pip install monai*.tar.gz |
| python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown" |
| python -c 'import monai; print(monai.__file__)' |
| python -m pip uninstall -y monai |
| rm monai*.tar.gz |
|
|
| |
| cd "$root_dir" |
| rm -r "$tmp_dir" |
|
|
| build-docs: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@v2 |
| - name: Set up Python 3.7 |
| uses: actions/setup-python@v1 |
| with: |
| python-version: 3.7 |
| - name: cache weekly timestamp |
| id: pip-cache |
| run: | |
| echo "::set-output name=datew::$(date '+%Y-%V')" |
| - name: cache for pip |
| uses: actions/cache@v2 |
| id: cache |
| with: |
| path: ~/.cache/pip |
| key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} |
| - name: Install dependencies |
| run: | |
| python -m pip install --upgrade pip wheel |
| python -m pip install -r docs/requirements.txt |
| - name: Make html |
| run: | |
| cd docs/ |
| make html |
| |