Skip to content

Commit 2964048

Browse files
authored
Merge branch 'master' into neha/stain-norm
2 parents db131d3 + d1f4e6f commit 2964048

File tree

87 files changed

+2876
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2876
-391
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ docs/
88
.coverage/
99
coverage.xml
1010
.readthedocs.yml
11-
*.md
1211
*.toml
1312

1413
!README.md

.github/workflows/cron.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: crons
33
on:
44
schedule:
55
- cron: "0 2 * * *" # at 02:00 UTC
6+
# Allows you to run this workflow manually from the Actions tab
7+
workflow_dispatch:
68

79
jobs:
810
cron-gpu:
@@ -40,17 +42,14 @@ jobs:
4042
nvidia-smi
4143
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
4244
echo $CUDA_VISIBLE_DEVICES
43-
stop_time=$((LAUNCH_DELAY + $(date +%s)))
44-
while [ $(date +%s) -lt $stop_time ]; do
45-
python -c 'import torch; torch.rand(5, 3, device=torch.device("cuda:0"))';
46-
done
45+
trap 'if pgrep python; then pkill python; fi;' ERR
46+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
4747
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
4848
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
4949
BUILD_MONAI=1 ./runtests.sh --coverage --unittests # unit tests with coverage report
50-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
51-
echo $CUDA_VISIBLE_DEVICES
5250
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
5351
coverage xml
52+
if pgrep python; then pkill python; fi
5453
- name: Upload coverage
5554
uses: codecov/codecov-action@v1
5655
with:
@@ -83,17 +82,14 @@ jobs:
8382
nvidia-smi
8483
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
8584
echo $CUDA_VISIBLE_DEVICES
86-
stop_time=$((LAUNCH_DELAY + $(date +%s)))
87-
while [ $(date +%s) -lt $stop_time ]; do
88-
python -c 'import torch; torch.rand(5, 3, device=torch.device("cuda:0"))';
89-
done
85+
trap 'if pgrep python; then pkill python; fi;' ERR
86+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
9087
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
9188
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
9289
BUILD_MONAI=1 ./runtests.sh --coverage --unittests # unit tests with coverage report
93-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
94-
echo $CUDA_VISIBLE_DEVICES
9590
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
9691
coverage xml
92+
if pgrep python; then pkill python; fi
9793
- name: Upload coverage
9894
uses: codecov/codecov-action@v1
9995
with:
@@ -115,14 +111,15 @@ jobs:
115111
nvidia-smi
116112
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
117113
echo $CUDA_VISIBLE_DEVICES
114+
trap 'if pgrep python; then pkill python; fi;' ERR
115+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
118116
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
119117
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
120118
ngc --version
121119
BUILD_MONAI=1 ./runtests.sh --coverage --pytype --unittests # unit tests with pytype checks, coverage report
122-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
123-
echo $CUDA_VISIBLE_DEVICES
124120
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
125121
coverage xml
122+
if pgrep python; then pkill python; fi
126123
- name: Upload coverage
127124
uses: codecov/codecov-action@v1
128125
with:
@@ -156,8 +153,12 @@ jobs:
156153
cd tutorials
157154
python -m pip install -r requirements.txt
158155
- name: Run tutorial notebooks
156+
timeout-minutes: 150
159157
run: |
160158
export CUDA_VISIBLE_DEVICES=${{ steps.monai-install.outputs.devices }}
161159
echo $CUDA_VISIBLE_DEVICES
160+
trap 'if pgrep python; then pkill python; fi;' ERR
161+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
162162
cd /opt/tutorials
163163
$(pwd)/runner.sh
164+
if pgrep python; then pkill python; fi

.github/workflows/docker.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: docker
2+
# versioning: compute a static version file
3+
# local_docker: use the version file to build docker images
4+
# docker_test_latest: test the latest internal docker image (has flake)
5+
# docker_test_dockerhub: test the latest dockerhub release (no flake)
6+
on:
7+
# master only docker deployment and quick tests
8+
push:
9+
branches:
10+
- master
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
jobs:
15+
versioning:
16+
# compute versioning file from python setup.py
17+
# upload as artifact
18+
# (also used in release.yml)
19+
if: github.repository == 'Project-MONAI/MONAI'
20+
container:
21+
image: localhost:5000/local_monai:latest
22+
runs-on: [self-hosted, linux, x64, build_only]
23+
steps:
24+
- uses: actions/checkout@v2
25+
# full history so that we can git describe
26+
with:
27+
ref: master
28+
fetch-depth: 0
29+
- shell: bash
30+
run: |
31+
git describe
32+
python setup.py build
33+
cat build/lib/monai/_version.py
34+
- name: Upload version
35+
uses: actions/upload-artifact@v2
36+
with:
37+
name: _version.py
38+
path: build/lib/monai/_version.py
39+
- name: Clean up directory
40+
shell: bash
41+
run: |
42+
ls -al
43+
rm -rf {*,.[^.]*}
44+
45+
local_docker:
46+
# builds two versions: local_monai:latest and local_monai:dockerhub
47+
# latest: used for local tests
48+
# dockerhub: release, no flake package
49+
if: github.repository == 'Project-MONAI/MONAI'
50+
needs: versioning
51+
runs-on: [self-hosted, linux, x64, build_only]
52+
steps:
53+
- uses: actions/checkout@v2
54+
with:
55+
ref: master
56+
- name: Download version
57+
uses: actions/download-artifact@v2
58+
with:
59+
name: _version.py
60+
- name: docker_build
61+
shell: bash
62+
run: |
63+
# get tag info for versioning
64+
cat _version.py
65+
mv _version.py monai/
66+
# build and run original docker image for local registry
67+
docker build -t localhost:5000/local_monai:latest -f Dockerfile .
68+
docker push localhost:5000/local_monai:latest
69+
# build once more w/ tag "latest": remove flake package as it is not needed on hub.docker.com
70+
sed -i '/flake/d' requirements-dev.txt
71+
docker build -t projectmonai/monai:latest -f Dockerfile .
72+
# also push as tag "dockerhub" to local registry
73+
docker image tag projectmonai/monai:latest localhost:5000/local_monai:dockerhub
74+
docker push localhost:5000/local_monai:dockerhub
75+
# distribute as always w/ tag "latest" to hub.docker.com
76+
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
77+
docker push projectmonai/monai:latest
78+
docker logout
79+
docker image prune -f
80+
81+
docker_test_latest:
82+
if: github.repository == 'Project-MONAI/MONAI'
83+
needs: local_docker
84+
container:
85+
image: localhost:5000/local_monai:latest
86+
runs-on: [self-hosted, linux, x64, common]
87+
steps:
88+
- name: Import
89+
run: |
90+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
91+
echo $CUDA_VISIBLE_DEVICES
92+
trap 'if pgrep python; then pkill python; fi;' ERR
93+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
94+
python -c 'import monai; monai.config.print_config()'
95+
cd /opt/monai
96+
ls -al
97+
ngc --version
98+
python -m tests.min_tests
99+
if pgrep python; then pkill python; fi
100+
env:
101+
QUICKTEST: True
102+
103+
docker_test_dockerhub:
104+
if: github.repository == 'Project-MONAI/MONAI'
105+
needs: local_docker
106+
container:
107+
image: localhost:5000/local_monai:dockerhub
108+
runs-on: [self-hosted, linux, x64, common]
109+
steps:
110+
- name: Import
111+
run: |
112+
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
113+
echo $CUDA_VISIBLE_DEVICES
114+
trap 'if pgrep python; then pkill python; fi;' ERR
115+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
116+
python -c 'import monai; monai.config.print_config()'
117+
cd /opt/monai
118+
ls -al
119+
ngc --version
120+
python -m tests.min_tests
121+
if pgrep python; then pkill python; fi
122+
env:
123+
QUICKTEST: True

.github/workflows/integration.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ jobs:
4242
nvidia-smi
4343
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
4444
echo $CUDA_VISIBLE_DEVICES
45+
trap 'if pgrep python; then pkill python; fi;' ERR
46+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
4547
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
4648
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
47-
BUILD_MONAI=1 ./runtests.sh --unittests --net
49+
BUILD_MONAI=1 ./runtests.sh --net
50+
BUILD_MONAI=1 ./runtests.sh --unittests
51+
if pgrep python; then pkill python; fi
52+
shell: bash
4853
- name: Add reaction
4954
uses: peter-evans/create-or-update-comment@v1
5055
with:

.github/workflows/pythonapp.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,8 @@ jobs:
290290
sleep $LAUNCH_DELAY
291291
export CUDA_VISIBLE_DEVICES=$(coverage run -m tests.utils)
292292
echo $CUDA_VISIBLE_DEVICES
293-
stop_time=$((LAUNCH_DELAY + $(date +%s)))
294-
while [ $(date +%s) -lt $stop_time ]; do
295-
python -c 'import torch; torch.rand(5, 3, device=torch.device("cuda:0"))';
296-
done
293+
trap 'if pgrep python; then pkill python; fi;' ERR
294+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
297295
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
298296
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
299297
python -c "import monai; monai.config.print_config()"
@@ -303,6 +301,8 @@ jobs:
303301
coverage run -m tests.clang_format_utils
304302
fi
305303
coverage xml
304+
if pgrep python; then pkill python; fi
305+
shell: bash
306306
- name: Upload coverage
307307
uses: codecov/codecov-action@v1
308308
with:

.github/workflows/release.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,70 @@ jobs:
8383
password: ${{ secrets.TEST_PYPI }}
8484
repository_url: https://test.pypi.org/legacy/
8585

86+
versioning:
87+
# compute versioning file from python setup.py
88+
# upload as artifact
89+
# (also used in docker.yml)
90+
if: github.repository == 'Project-MONAI/MONAI'
91+
needs: packaging
92+
container:
93+
image: localhost:5000/local_monai:latest
94+
runs-on: [self-hosted, linux, x64, build_only]
95+
steps:
96+
- uses: actions/checkout@v2
97+
# full history so that we can git describe
98+
with:
99+
ref: master
100+
fetch-depth: 0
101+
- shell: bash
102+
run: |
103+
git describe
104+
python setup.py build
105+
cat build/lib/monai/_version.py
106+
- name: Upload version
107+
uses: actions/upload-artifact@v2
108+
with:
109+
name: _version.py
110+
path: build/lib/monai/_version.py
111+
- name: Clean up directory
112+
shell: bash
113+
run: |
114+
ls -al
115+
rm -rf {*,.[^.]*}
116+
117+
release_tag_docker:
118+
if: github.repository == 'Project-MONAI/MONAI'
119+
needs: versioning
120+
runs-on: [self-hosted, linux, x64, build_only]
121+
steps:
122+
- uses: actions/checkout@v2
123+
with:
124+
ref: master
125+
- name: Download version
126+
uses: actions/download-artifact@v2
127+
with:
128+
name: _version.py
129+
- name: Set tag
130+
id: versioning
131+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
132+
- name: Check tag
133+
env:
134+
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
135+
run: |
136+
echo "$RELEASE_VERSION"
137+
cat _version.py
138+
- if: startsWith(github.ref, 'refs/tags/')
139+
name: build with the tag
140+
env:
141+
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
142+
shell: bash
143+
run: |
144+
# get tag info for versioning
145+
mv _version.py monai/
146+
# remove flake package as it is not needed on hub.docker.com
147+
sed -i '/flake/d' requirements-dev.txt
148+
docker build -t projectmonai/monai:"$RELEASE_VERSION" -f Dockerfile .
149+
# distribute with a tag to hub.docker.com
150+
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
151+
docker push projectmonai/monai:"$RELEASE_VERSION"
152+
docker logout

.github/workflows/setupapp.yml

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,15 @@ jobs:
4747
nvidia-smi
4848
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
4949
echo $CUDA_VISIBLE_DEVICES
50-
stop_time=$((LAUNCH_DELAY + $(date +%s)))
51-
while [ $(date +%s) -lt $stop_time ]; do
52-
python -c 'import torch; torch.rand(5, 3, device=torch.device("cuda:0"))';
53-
done
50+
trap 'if pgrep python; then pkill python; fi;' ERR
51+
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
5452
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
5553
python -c 'import torch; print(torch.rand(5, 3, device=torch.device("cuda:0")))'
5654
BUILD_MONAI=1 ./runtests.sh --coverage --unittests # unit tests with coverage report
57-
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils)
58-
echo $CUDA_VISIBLE_DEVICES
5955
BUILD_MONAI=1 ./runtests.sh --coverage --net # integration tests with coverage report
6056
coverage xml
57+
if pgrep python; then pkill python; fi
58+
shell: bash
6159
- name: Upload coverage
6260
uses: codecov/codecov-action@v1
6361
with:
@@ -148,44 +146,3 @@ jobs:
148146
python -m tests.min_tests
149147
env:
150148
QUICKTEST: True
151-
152-
local_docker:
153-
if: github.repository == 'Project-MONAI/MONAI'
154-
runs-on: [self-hosted, linux, x64, build_only]
155-
# we only push built container if it is built from master branch
156-
steps:
157-
- uses: actions/checkout@v2
158-
with:
159-
ref: master
160-
- name: docker_build
161-
run: |
162-
# build and run original docker image for local registry
163-
docker build -t localhost:5000/local_monai:latest -f Dockerfile .
164-
docker push localhost:5000/local_monai:latest
165-
# build once more w/ tag "latest": remove flake package as it is not needed on hub.docker.com
166-
sed -i '/flake/d' requirements-dev.txt
167-
docker build -t projectmonai/monai:latest -f Dockerfile .
168-
# also push as tag "dockerhub" to local registry
169-
docker image tag projectmonai/monai:latest localhost:5000/local_monai:dockerhub
170-
docker push localhost:5000/local_monai:dockerhub
171-
# distribute as always w/ tag "latest" to hub.docker.com
172-
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
173-
docker push projectmonai/monai:latest
174-
docker logout
175-
176-
docker:
177-
if: github.repository == 'Project-MONAI/MONAI'
178-
needs: local_docker
179-
container:
180-
image: localhost:5000/local_monai:latest
181-
runs-on: [self-hosted, linux, x64, common]
182-
steps:
183-
- name: Import
184-
run: |
185-
python -c 'import monai; monai.config.print_config()'
186-
cd /opt/monai
187-
ls -al
188-
ngc --version
189-
python -m tests.min_tests
190-
env:
191-
QUICKTEST: True

.github/workflows/weekly-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
export YEAR_WEEK=$(date +'%y%U')
3333
echo "Year week for tag is ${YEAR_WEEK}"
3434
if ! [[ $YEAR_WEEK =~ ^[0-9]{4}$ ]] ; then echo "Wrong 'year week' format. Should be 4 digits."; exit 1 ; fi
35-
git tag "0.5.dev${YEAR_WEEK}"
35+
git tag "0.6.dev${YEAR_WEEK}"
3636
git log -1
3737
git tag --list
3838
python setup.py sdist bdist_wheel

0 commit comments

Comments
 (0)