Skip to content

Commit 867287e

Browse files
authored
Merge branch 'dev' into dev
2 parents d02da49 + 1dc47a5 commit 867287e

154 files changed

Lines changed: 4458 additions & 628 deletions

File tree

Some content is hidden

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

.dockerignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
__pycache__/
44
docs/
55

6+
.vscode
7+
.git
8+
.mypy_cache
9+
.ruff_cache
10+
.pytype
611
.coverage
712
.coverage.*
813
.coverage/
914
coverage.xml
1015
.readthedocs.yml
11-
*.toml
1216

1317
!README.md

.github/workflows/pythonapp.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: |
3939
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
4040
python -m pip install --upgrade pip wheel
41-
python -m pip install -r requirements-dev.txt
41+
python -m pip install --no-build-isolation -r requirements-dev.txt
4242
- name: Lint and type check
4343
run: |
4444
# clean up temporary files
@@ -82,17 +82,17 @@ jobs:
8282
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
8383
- name: Install the dependencies
8484
run: |
85-
python -m pip install --user --upgrade pip wheel
85+
python -m pip install --user --upgrade pip wheel pybind11
8686
python -m pip install torch==2.5.1 torchvision==0.20.1
8787
cat "requirements-dev.txt"
88-
python -m pip install -r requirements-dev.txt
88+
python -m pip install --no-build-isolation -r requirements-dev.txt
8989
python -m pip list
90-
python setup.py develop # test no compile installation
90+
python -m pip install -e . # test no compile installation
9191
shell: bash
9292
- name: Run compiled (${{ runner.os }})
9393
run: |
94-
python setup.py develop --uninstall
95-
BUILD_MONAI=1 python setup.py develop # compile the cpp extensions
94+
python -m pip uninstall -y monai
95+
BUILD_MONAI=1 python -m pip install -e . # compile the cpp extensions
9696
shell: bash
9797
- name: Run quick tests (CPU ${{ runner.os }})
9898
run: |
@@ -174,7 +174,7 @@ jobs:
174174
cp ${{ steps.root.outputs.pwd }}/requirements*.txt .
175175
cp -r ${{ steps.root.outputs.pwd }}/tests .
176176
ls -al
177-
python -m pip install -r requirements-dev.txt --extra-index-url https://download.pytorch.org/whl/cpu
177+
python -m pip install --no-build-isolation -r requirements-dev.txt --extra-index-url https://download.pytorch.org/whl/cpu
178178
python -m unittest -v
179179
env:
180180
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354

.github/workflows/setupapp.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
runs-on: ubuntu-latest
8282
strategy:
8383
matrix:
84-
python-version: ['3.9', '3.10', '3.11']
84+
python-version: ['3.10', '3.11', '3.12']
8585
steps:
8686
- uses: actions/checkout@v6
8787
with:
@@ -90,23 +90,12 @@ jobs:
9090
uses: actions/setup-python@v6
9191
with:
9292
python-version: ${{ matrix.python-version }}
93-
- name: cache weekly timestamp
94-
id: pip-cache
95-
run: |
96-
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
97-
- name: cache for pip
98-
uses: actions/cache@v5
99-
id: cache
100-
with:
101-
path: |
102-
~/.cache/pip
103-
~/.cache/torch
104-
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ steps.pip-cache.outputs.datew }}
93+
cache: pip
10594
- name: Install the dependencies
10695
run: |
10796
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
10897
python -m pip install --upgrade pip wheel
109-
python -m pip install -r requirements-dev.txt
98+
python -m pip install --no-build-isolation -r requirements-dev.txt
11099
- name: Run quick tests CPU ubuntu
111100
env:
112101
NGC_API_KEY: ${{ secrets.NGC_API_KEY }}
@@ -115,8 +104,8 @@ jobs:
115104
run: |
116105
python -m pip list
117106
python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))'
118-
BUILD_MONAI=0 ./runtests.sh --build --quick --unittests
119-
BUILD_MONAI=1 ./runtests.sh --build --quick --min
107+
BUILD_MONAI=0 ./runtests.sh --build --coverage --quick --unittests
108+
BUILD_MONAI=1 ./runtests.sh --build --coverage --quick --min
120109
coverage xml --ignore-errors
121110
- name: Upload coverage
122111
uses: codecov/codecov-action@v5

.pre-commit-config.yaml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ci:
99

1010
repos:
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v5.0.0
12+
rev: v6.0.0
1313
hooks:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
@@ -27,35 +27,18 @@ repos:
2727
- id: end-of-file-fixer
2828
- id: mixed-line-ending
2929
- repo: https://github.com/astral-sh/ruff-pre-commit
30-
rev: v0.7.0
30+
rev: v0.14.11
3131
hooks:
32-
- id: ruff
32+
- id: ruff-check
3333
args: ["--fix"]
3434
exclude: |
3535
(?x)(
3636
^versioneer.py|
3737
^monai/_version.py
3838
)
3939
40-
- repo: https://github.com/asottile/yesqa
41-
rev: v1.5.0
42-
hooks:
43-
- id: yesqa
44-
name: Unused noqa
45-
additional_dependencies:
46-
- flake8>=3.8.1
47-
- flake8-bugbear<=24.2.6
48-
- flake8-comprehensions
49-
- pep8-naming
50-
exclude: |
51-
(?x)^(
52-
monai/__init__.py|
53-
docs/source/conf.py|
54-
tests/utils.py
55-
)$
56-
5740
- repo: https://github.com/hadialqattan/pycln
58-
rev: v2.5.0
41+
rev: v2.6.0
5942
hooks:
6043
- id: pycln
6144
args: [--config=pyproject.toml]

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
77

8+
## [1.5.2] - 2026-01-28
9+
10+
## What's Changed
11+
### Fixed
12+
* Fix Zip Slip vulnerability in NGC private bundle download (#8682)
13+
814
## [1.5.1] - 2025-09-22
915

1016
## What's Changed
@@ -1261,7 +1267,8 @@ the postprocessing steps should be used before calling the metrics methods
12611267

12621268
[highlights]: https://github.com/Project-MONAI/MONAI/blob/master/docs/source/highlights.md
12631269

1264-
[Unreleased]: https://github.com/Project-MONAI/MONAI/compare/1.5.1...HEAD
1270+
[Unreleased]: https://github.com/Project-MONAI/MONAI/compare/1.5.2...HEAD
1271+
[1.5.2]: https://github.com/Project-MONAI/MONAI/compare/1.5.1...1.5.2
12651272
[1.5.1]: https://github.com/Project-MONAI/MONAI/compare/1.5.0...1.5.1
12661273
[1.5.0]: https://github.com/Project-MONAI/MONAI/compare/1.4.0...1.5.0
12671274
[1.4.0]: https://github.com/Project-MONAI/MONAI/compare/1.3.2...1.4.0

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ title: "MONAI: Medical Open Network for AI"
66
abstract: "AI Toolkit for Healthcare Imaging"
77
authors:
88
- name: "MONAI Consortium"
9-
date-released: 2025-09-22
10-
version: "1.5.1"
9+
date-released: 2026-01-29
10+
version: "1.5.2"
1111
identifiers:
1212
- description: "This DOI represents all versions of MONAI, and will always resolve to the latest one."
1313
type: doi

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Please note that, as per PyTorch, MONAI uses American English spelling. This mea
3737

3838
### Preparing pull requests
3939

40-
To ensure the code quality, MONAI relies on several linting tools ([flake8 and its plugins](https://gitlab.com/pycqa/flake8), [black](https://github.com/psf/black), [isort](https://github.com/timothycrosley/isort), [ruff](https://github.com/astral-sh/ruff)),
40+
To ensure the code quality, MONAI relies on several linting tools ([black](https://github.com/psf/black), [isort](https://github.com/timothycrosley/isort), [ruff](https://github.com/astral-sh/ruff)),
4141
static type analysis tools ([mypy](https://github.com/python/mypy), [pytype](https://github.com/google/pytype)), as well as a set of unit/integration tests.
4242

4343
This section highlights all the necessary preparation steps required before sending a pull request.
@@ -51,7 +51,7 @@ To collaborate efficiently, please read through this section and follow them.
5151

5252
#### Checking the coding style
5353

54-
Coding style is checked and enforced by flake8, black, isort, and ruff, using [a flake8 configuration](./setup.cfg) similar to [PyTorch's](https://github.com/pytorch/pytorch/blob/master/.flake8).
54+
Coding style is checked and enforced by black, isort, and ruff.
5555
Before submitting a pull request, we recommend that all linting should pass, by running the following command locally:
5656

5757
```bash
@@ -380,7 +380,8 @@ All code review comments should be specific, constructive, and actionable.
380380

381381
### Release a new version
382382

383-
The `dev` branch's `HEAD` always corresponds to MONAI docker image's latest tag: `projectmonai/monai:latest`.
383+
The `dev` branch's `HEAD` always corresponds to MONAI Docker image's latest tag: `projectmonai/monai:latest`. (No
384+
release is currently done for the slim MONAI image, this is built locally by users.)
384385
The `main` branch's `HEAD` always corresponds to the latest MONAI milestone release.
385386

386387
When major features are ready for a milestone, to prepare for a new release:

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# To build with a different base image
1313
# please run `docker build` using the `--build-arg PYTORCH_IMAGE=...` flag.
14-
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:24.10-py3
14+
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:25.12-py3
1515
FROM ${PYTORCH_IMAGE}
1616

1717
LABEL maintainer="monai.contact@gmail.com"
@@ -42,9 +42,6 @@ COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versionee
4242
COPY tests ./tests
4343
COPY monai ./monai
4444

45-
# TODO: remove this line and torch.patch for 24.11
46-
RUN patch -R -d /usr/local/lib/python3.10/dist-packages/torch/onnx/ < ./monai/torch.patch
47-
4845
RUN BUILD_MONAI=1 FORCE_CUDA=1 python setup.py develop \
4946
&& rm -rf build __pycache__
5047

Dockerfile.slim

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright (c) MONAI Consortium
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS,
8+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
# See the License for the specific language governing permissions and
10+
# limitations under the License.
11+
12+
# This is a slimmed down version of the MONAI Docker image using a smaller base image and multi-stage building. Not all
13+
# NVIDIA tools will be present but all libraries and compiled code are included. This image isn't provided through
14+
# Dockerhub so users must build locally: `docker build -t monai_slim -f Dockerfile.slim .`
15+
# Containers may require more shared memory, eg.: `docker run -ti --rm --gpus all --shm-size=10gb monai_slim /bin/bash`
16+
17+
ARG IMAGE=debian:12-slim
18+
19+
FROM ${IMAGE} AS build
20+
21+
ARG TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6 8.9 9.0+PTX"
22+
23+
ENV DEBIAN_FRONTEND=noninteractive
24+
ENV APT_INSTALL="apt install -y --no-install-recommends"
25+
26+
RUN apt update && apt upgrade -y && \
27+
${APT_INSTALL} ca-certificates python3-pip python-is-python3 git wget libopenslide0 unzip python3-dev && \
28+
wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb && \
29+
dpkg -i cuda-keyring_1.1-1_all.deb && \
30+
apt update && \
31+
${APT_INSTALL} cuda-toolkit-12 && \
32+
rm -rf /usr/lib/python*/EXTERNALLY-MANAGED /var/lib/apt/lists/* && \
33+
python -m pip install --upgrade --no-cache-dir --no-build-isolation pip
34+
35+
# TODO: remark for issue [revise the dockerfile](https://github.com/zarr-developers/numcodecs/issues/431)
36+
RUN if [[ $(uname -m) =~ "aarch64" ]]; then \
37+
CFLAGS="-O3" DISABLE_NUMCODECS_SSE2=true DISABLE_NUMCODECS_AVX2=true python -m pip install numcodecs; \
38+
fi
39+
40+
# NGC Client
41+
WORKDIR /opt/tools
42+
ARG NGC_CLI_URI="https://ngc.nvidia.com/downloads/ngccli_linux.zip"
43+
RUN wget -q ${NGC_CLI_URI} && unzip ngccli_linux.zip && chmod u+x ngc-cli/ngc && \
44+
find ngc-cli/ -type f -exec md5sum {} + | LC_ALL=C sort | md5sum -c ngc-cli.md5 && \
45+
rm -rf ngccli_linux.zip ngc-cli.md5
46+
47+
WORKDIR /opt/monai
48+
49+
# copy relevant parts of repo
50+
COPY requirements.txt requirements-min.txt requirements-dev.txt versioneer.py setup.py setup.cfg pyproject.toml ./
51+
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md MANIFEST.in runtests.sh ./
52+
COPY tests ./tests
53+
COPY monai ./monai
54+
55+
# install full deps
56+
RUN python -m pip install --no-cache-dir --no-build-isolation -r requirements-dev.txt
57+
58+
# compile ext
59+
RUN CUDA_HOME=/usr/local/cuda FORCE_CUDA=1 USE_COMPILED=1 BUILD_MONAI=1 python setup.py develop
60+
61+
# recreate the image without the installed CUDA packages then copy the installed MONAI and Python directories
62+
FROM ${IMAGE} AS build2
63+
64+
ENV DEBIAN_FRONTEND=noninteractive
65+
ENV APT_INSTALL="apt install -y --no-install-recommends"
66+
67+
RUN apt update && apt upgrade -y && \
68+
${APT_INSTALL} ca-certificates python3-pip python-is-python3 git libopenslide0 && \
69+
apt clean && \
70+
rm -rf /usr/lib/python*/EXTERNALLY-MANAGED /var/lib/apt/lists/* && \
71+
python -m pip install --upgrade --no-cache-dir --no-build-isolation pip
72+
73+
COPY --from=build /opt/monai /opt/monai
74+
COPY --from=build /opt/tools /opt/tools
75+
ARG PYTHON_VERSION=3.11
76+
COPY --from=build /usr/local/lib/python${PYTHON_VERSION}/dist-packages /usr/local/lib/python${PYTHON_VERSION}/dist-packages
77+
COPY --from=build /usr/local/bin /usr/local/bin
78+
79+
RUN rm -rf /opt/monai/build /opt/monai/monai.egg-info && \
80+
find /opt /usr/local/lib -type d -name __pycache__ -exec rm -rf {} +
81+
82+
# flatten all layers down to one
83+
FROM ${IMAGE}
84+
LABEL maintainer="monai.contact@gmail.com"
85+
86+
COPY --from=build2 / /
87+
88+
WORKDIR /opt/monai
89+
90+
ENV PATH=${PATH}:/opt/tools:/opt/tools/ngc-cli
91+
ENV POLYGRAPHY_AUTOINSTALL_DEPS=1
92+
ENV CUDA_HOME=/usr/local/cuda
93+
ENV BUILD_MONAI=1

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ include monai/_version.py
33

44
include README.md
55
include LICENSE
6+
7+
prune tests

0 commit comments

Comments
 (0)