Skip to content

Commit e96ab04

Browse files
Merge branch 'master' into 1090-efficientnet-support
2 parents d83a053 + d6ed956 commit e96ab04

25 files changed

+388
-192
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/docker.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
80+
docker_test_latest:
81+
if: github.repository == 'Project-MONAI/MONAI'
82+
needs: local_docker
83+
container:
84+
image: localhost:5000/local_monai:latest
85+
runs-on: [self-hosted, linux, x64, common]
86+
steps:
87+
- name: Import
88+
run: |
89+
python -c 'import monai; monai.config.print_config()'
90+
cd /opt/monai
91+
ls -al
92+
ngc --version
93+
python -m tests.min_tests
94+
env:
95+
QUICKTEST: True
96+
97+
docker_test_dockerhub:
98+
if: github.repository == 'Project-MONAI/MONAI'
99+
needs: local_docker
100+
container:
101+
image: localhost:5000/local_monai:dockerhub
102+
runs-on: [self-hosted, linux, x64, common]
103+
steps:
104+
- name: Import
105+
run: |
106+
python -c 'import monai; monai.config.print_config()'
107+
cd /opt/monai
108+
ls -al
109+
ngc --version
110+
python -m tests.min_tests
111+
env:
112+
QUICKTEST: True

.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: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -148,44 +148,3 @@ jobs:
148148
python -m tests.min_tests
149149
env:
150150
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

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ RUN cp /tmp/requirements.txt /tmp/req.bak \
3030
# please specify exact files and folders to be copied -- else, basically always, the Docker build process cannot cache
3131
# this or anything below it and always will build from at most here; one file change leads to no caching from here on...
3232

33-
COPY LICENSE setup.py setup.cfg versioneer.py runtests.sh .gitignore .gitattributes README.md MANIFEST.in ./
33+
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py setup.cfg runtests.sh MANIFEST.in ./
3434
COPY tests ./tests
3535
COPY monai ./monai
36-
COPY .git ./.git
3736
RUN BUILD_MONAI=1 FORCE_CUDA=1 python setup.py develop \
3837
&& rm -rf build __pycache__
3938

docs/requirements.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ pytorch-ignite==0.4.4
44
numpy>=1.17
55
itk>=5.0, <=5.1.2
66
nibabel
7-
cucim==0.18.2
8-
openslide-python==1.1.2
97
parameterized
108
scikit-image>=0.14.2
119
tensorboard
1210
commonmark==0.9.1
1311
recommonmark==0.6.0
14-
Sphinx==3.3.0
15-
sphinx-rtd-theme==0.5.0
12+
Sphinx==3.5.3
13+
sphinx-rtd-theme==0.5.2
1614
sphinxcontrib-applehelp
1715
sphinxcontrib-devhelp
1816
sphinxcontrib-htmlhelp

monai/_version.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
12
# This file helps to compute a version number in source trees obtained from
23
# git-archive tarball (such as those provided by githubs download-from-tag
34
# feature). Distribution tarballs (built by setup.py sdist) and build
45
# directories (produced by setup.py build) will contain a much shorter file
56
# that just contains the computed version number.
67

78
# This file is released into the public domain. Generated by
8-
# versioneer-0.18 (https://github.com/warner/python-versioneer)
9+
# versioneer-0.19 (https://github.com/python-versioneer/python-versioneer)
910

1011
"""Git implementation of _version.py."""
1112

@@ -56,7 +57,7 @@ class NotThisMethod(Exception):
5657

5758

5859
def register_vcs_handler(vcs, method): # decorator
59-
"""Decorator to mark a method as the handler for a particular VCS."""
60+
"""Create decorator to mark a method as the handler of a VCS."""
6061
def decorate(f):
6162
"""Store f in HANDLERS[vcs][method]."""
6263
if vcs not in HANDLERS:
@@ -92,9 +93,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
9293
if verbose:
9394
print("unable to find command, tried %s" % (commands,))
9495
return None, None
95-
stdout = p.communicate()[0].strip()
96-
if sys.version_info[0] >= 3:
97-
stdout = stdout.decode()
96+
stdout = p.communicate()[0].strip().decode()
9897
if p.returncode != 0:
9998
if verbose:
10099
print("unable to run %s (error)" % dispcmd)
@@ -164,6 +163,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
164163
raise NotThisMethod("no keywords at all, weird")
165164
date = keywords.get("date")
166165
if date is not None:
166+
# Use only the last line. Previous lines may contain GPG signature
167+
# information.
168+
date = date.splitlines()[-1]
169+
167170
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
168171
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
169172
# -like" string, which we must then edit to make compliant), because
@@ -299,6 +302,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
299302
# commit date: see ISO-8601 comment in git_versions_from_keywords()
300303
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
301304
cwd=root)[0].strip()
305+
# Use only the last line. Previous lines may contain GPG signature
306+
# information.
307+
date = date.splitlines()[-1]
302308
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
303309

304310
return pieces
@@ -337,18 +343,18 @@ def render_pep440(pieces):
337343

338344

339345
def render_pep440_pre(pieces):
340-
"""TAG[.post.devDISTANCE] -- No -dirty.
346+
"""TAG[.post0.devDISTANCE] -- No -dirty.
341347
342348
Exceptions:
343-
1: no tags. 0.post.devDISTANCE
349+
1: no tags. 0.post0.devDISTANCE
344350
"""
345351
if pieces["closest-tag"]:
346352
rendered = pieces["closest-tag"]
347353
if pieces["distance"]:
348-
rendered += ".post.dev%d" % pieces["distance"]
354+
rendered += ".post0.dev%d" % pieces["distance"]
349355
else:
350356
# exception #1
351-
rendered = "0.post.dev%d" % pieces["distance"]
357+
rendered = "0.post0.dev%d" % pieces["distance"]
352358
return rendered
353359

354360

@@ -494,7 +500,7 @@ def get_versions():
494500
# versionfile_source is the relative path from the top of the source
495501
# tree (where the .git directory might live) to this file. Invert
496502
# this to find the root from __file__.
497-
for i in cfg.versionfile_source.split('/'): # lgtm[py/unused-loop-variable]
503+
for i in cfg.versionfile_source.split('/'):
498504
root = os.path.dirname(root)
499505
except NameError:
500506
return {"version": "0+unknown", "full-revisionid": None,

monai/apps/deepgrow/transforms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from monai.config import IndexSelection, KeysCollection
1717
from monai.networks.layers import GaussianFilter
1818
from monai.transforms import Resize, SpatialCrop
19-
from monai.transforms.transform import MapTransform, RandomizableTransform, Transform
19+
from monai.transforms.transform import MapTransform, Randomizable, Transform
2020
from monai.transforms.utils import generate_spatial_bounding_box
2121
from monai.utils import InterpolateMode, ensure_tuple_rep, min_version, optional_import
2222

@@ -61,7 +61,7 @@ def __call__(self, data):
6161
return d
6262

6363

64-
class AddInitialSeedPointd(RandomizableTransform):
64+
class AddInitialSeedPointd(Randomizable):
6565
"""
6666
Add random guidance as initial seed point for a given label.
6767
@@ -86,7 +86,6 @@ def __init__(
8686
sid: str = "sid",
8787
connected_regions: int = 5,
8888
):
89-
super().__init__(prob=1.0, do_transform=True)
9089
self.label = label
9190
self.sids_key = sids
9291
self.sid_key = sid
@@ -284,7 +283,7 @@ def __call__(self, data):
284283
return d
285284

286285

287-
class AddRandomGuidanced(RandomizableTransform):
286+
class AddRandomGuidanced(Randomizable):
288287
"""
289288
Add random guidance based on discrepancies that were found between label and prediction.
290289
@@ -320,7 +319,6 @@ def __init__(
320319
probability: str = "probability",
321320
batched: bool = True,
322321
):
323-
super().__init__(prob=1.0, do_transform=True)
324322
self.guidance = guidance
325323
self.discrepancy = discrepancy
326324
self.probability = probability

0 commit comments

Comments
 (0)