Skip to content

Commit

Permalink
Merge pull request #141 from Project-MONAI/master
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
Nic-Ma authored Sep 16, 2020
2 parents 468a6bf + 12b3fbf commit 9e476ca
Show file tree
Hide file tree
Showing 27 changed files with 810 additions and 235 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
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 --coverage
BUILD_MONAI=1 ./runtests.sh --coverage
coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v1
Expand All @@ -58,7 +58,7 @@ jobs:
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")))'
ngc --version
./runtests.sh --coverage --pytype
BUILD_MONAI=1 ./runtests.sh --coverage --pytype
coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v1
Expand Down
65 changes: 59 additions & 6 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ jobs:
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()"
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:13]); 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
SKIP_MONAI_BUILD=1 python setup.py develop
python setup.py develop
python setup.py develop --uninstall
python setup.py develop # compile the cpp extensions
BUILD_MONAI=1 python setup.py develop # compile the cpp extensions
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
run: |
Expand All @@ -95,6 +95,56 @@ jobs:
env:
QUICKTEST: True

min-dep-py3: # min dependencies installed
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
- name: Install the dependencies
run: |
# min. requirements for windows instances
python -m pip install torch==1.4
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:6]); f.close()"
cat "requirements-dev.txt"
python -m pip install -r requirements-dev.txt
python -m pip list
BUILD_MONAI=0 python setup.py develop # no compile of extensions
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -m tests.min_tests
env:
QUICKTEST: True

GPU-quick-py3: # GPU with full dependencies
strategy:
matrix:
Expand Down Expand Up @@ -170,11 +220,11 @@ jobs:
run: |
python -m pip list
nvidia-smi
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
export CUDA_VISIBLE_DEVICES=$(coverage run -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
BUILD_MONAI=1 ./runtests.sh --quick
if [ ${{ matrix.environment }} == "PT16+CUDA110" ]; then
# test the clang-format tool downloading once
coverage run -m tests.clang_format_utils
Expand Down Expand Up @@ -274,4 +324,7 @@ jobs:
- name: Make html
run: |
cd docs/
make html
make clean
make html 2>&1 | tee tmp_log
if [[ $(grep -c "^WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; exit 1; fi
shell: bash
71 changes: 13 additions & 58 deletions .github/workflows/setupapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
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 --coverage
BUILD_MONAI=1 ./runtests.sh --coverage
coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v1
Expand Down Expand Up @@ -83,65 +83,15 @@ jobs:
run: |
python -m pip list
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
./runtests.sh --quick
BUILD_MONAI=1 ./runtests.sh --quick
coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
file: ./coverage.xml

min-dep-py3: # min dependencies installed
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
- name: Install the dependencies
run: |
# min. requirements for windows instances
python -m pip install torch==1.4
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:5]); f.close()"
cat "requirements-dev.txt"
python -m pip install -r requirements-dev.txt
python -m pip list
SKIP_MONAI_BUILD=1 python setup.py develop # no compile of extensions
shell: bash
- name: Run quick tests (CPU ${{ runner.os }})
run: |
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
python -m tests.min_tests
env:
QUICKTEST: True

install:
install: # pip install from github url
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.7
Expand All @@ -158,14 +108,19 @@ jobs:
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install the default branch
run: |
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
- name: Import
- name: Install the default branch no build
run: |
BUILD_MONAI=0 pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
python -c 'import monai; monai.config.print_config()'
- name: Uninstall
cd $(python -c 'import monai; import os; print(os.path.dirname(monai.__file__))')
ls .
pip uninstall -y monai
- name: Install the default branch with build
run: |
BUILD_MONAI=1 pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
python -c 'import monai; monai.config.print_config()'
cd $(python -c 'import monai; import os; print(os.path.dirname(monai.__file__))')
ls .
pip uninstall -y monai
docker:
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ include monai/_version.py

include README.md
include LICENSE

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"visualize",
"utils",
"inferers",
"optimizers",
]


Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Technical documentation is available at `docs.monai.io <https://docs.monai.io>`_
losses
networks
metrics
optimizers
data
engines
inferers
Expand Down
28 changes: 20 additions & 8 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ for the latest features:
```bash
pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
```
or, to build with MONAI Cpp/CUDA extensions:
```bash
BUILD_MONAI=1 pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI
```
this command will download and install the current master branch of [MONAI from
GitHub](https://github.com/Project-MONAI/MONAI).

Expand All @@ -55,17 +59,25 @@ You can install it by running:
```bash
cd MONAI/
python setup.py develop
```
or, to build with MONAI Cpp/CUDA extensions and install:
```bash
cd MONAI/
BUILD_MONAI=1 python setup.py develop
# for MacOS
BUILD_MONAI=1 CC=clang CXX=clang++ python setup.py develop
```

# For MacOS:
# CC=clang CXX=clang++ python setup.py develop

# To install without build
# SKIP_MONAI_BUILD=1 python setup.py develop

# To uninstall the package please run:
To uninstall the package please run:
```bash
cd MONAI/
python setup.py develop --uninstall

# to further clean up the MONAI/ folder (Bash script)
./runtests.sh --clean
```
or simply adding the root directory of the cloned source code (e.g., ``/workspace/Documents/MONAI``) to your ``$PYTHONPATH``

Alternatively, simply adding the root directory of the cloned source code (e.g., ``/workspace/Documents/MONAI``) to your ``$PYTHONPATH``
and the codebase is ready to use (without the additional features of MONAI C++/CUDA extensions).


Expand Down
12 changes: 12 additions & 0 deletions docs/source/optimizers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:github_url: https://github.com/Project-MONAI/MONAI

.. _optimizers:

Optimizers
==========
.. currentmodule:: monai.optimizers

`Novograd`
----------
.. autoclass:: Novograd
:members:
2 changes: 2 additions & 0 deletions monai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

* **networks**: contains network definitions, component definitions, and Pytorch specific utilities.

* **optimizers**: classes defining optimizers.

* **transforms**: defines data transforms for preprocessing and postprocessing.

* **utils**: generic utilities intended to be implemented in pure Python or using Numpy,
Expand Down
13 changes: 12 additions & 1 deletion monai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import sys

from ._version import get_versions
from .utils.module import load_submodules

PY_REQUIRED_MAJOR = 3
PY_REQUIRED_MINOR = 6

__version__ = get_versions()["version"]
del get_versions
Expand All @@ -22,6 +24,15 @@

__basedir__ = os.path.dirname(__file__)

if not (sys.version_info.major == PY_REQUIRED_MAJOR and sys.version_info.minor >= PY_REQUIRED_MINOR):
raise RuntimeError(
"MONAI requires Python {}.{} or higher. But the current Python is: {}".format(
PY_REQUIRED_MAJOR, PY_REQUIRED_MINOR, sys.version
),
)

from .utils.module import load_submodules # noqa: E402

# handlers_* have some external decorators the users may not have installed
# *.so files and folder "_C" may not exist when the cpp extensions are not compiled
excludes = "(^(monai.handlers))|((\\.so)$)|(^(monai._C))"
Expand Down
Loading

0 comments on commit 9e476ca

Please sign in to comment.