Skip to content

Commit 54f8246

Browse files
authored
Merge branch 'dev' into fix/non_tuple_indexing
2 parents 939a5bb + 894068a commit 54f8246

File tree

89 files changed

+2103
-344
lines changed

Some content is hidden

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

89 files changed

+2103
-344
lines changed

.github/workflows/pythonapp.yml

Lines changed: 6 additions & 6 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
@@ -85,14 +85,14 @@ jobs:
8585
python -m pip install --user --upgrade pip wheel
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

.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]

CONTRIBUTING.md

Lines changed: 2 additions & 2 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

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

docs/source/handlers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ Panoptic Quality metrics handler
8383
:members:
8484

8585

86+
Calibration Error metrics handler
87+
---------------------------------
88+
.. autoclass:: CalibrationError
89+
:members:
90+
91+
8692
Mean squared error metrics handler
8793
----------------------------------
8894
.. autoclass:: MeanSquaredError

docs/source/installation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,23 @@ You can install it by running:
135135

136136
```bash
137137
cd MONAI/
138-
python setup.py develop
138+
pip install -e .
139139
```
140140

141141
or, to build with MONAI C++/CUDA extensions and install:
142142

143143
```bash
144144
cd MONAI/
145-
BUILD_MONAI=1 python setup.py develop
145+
BUILD_MONAI=1 pip install -e .
146146
# for MacOS
147-
BUILD_MONAI=1 CC=clang CXX=clang++ python setup.py develop
147+
BUILD_MONAI=1 CC=clang CXX=clang++ pip install -e .
148148
```
149149

150150
To uninstall the package please run:
151151

152152
```bash
153153
cd MONAI/
154-
python setup.py develop --uninstall
154+
pip uninstall -y monai
155155

156156
# to further clean up the MONAI/ folder (Bash script)
157157
./runtests.sh --clean

docs/source/metrics.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ Metrics
143143
.. autoclass:: PSNRMetric
144144
:members:
145145

146+
`Mean absolute percentage error`
147+
---------------------------------
148+
.. autoclass:: MAPEMetric
149+
:members:
150+
146151
`Structural similarity index measure`
147152
-------------------------------------
148153
.. autoclass:: monai.metrics.regression.SSIMMetric
@@ -180,6 +185,15 @@ Metrics
180185
.. autoclass:: MetricsReloadedCategorical
181186
:members:
182187

188+
`Calibration Error`
189+
-------------------
190+
.. autofunction:: calibration_binning
191+
192+
.. autoclass:: CalibrationReduction
193+
:members:
194+
195+
.. autoclass:: CalibrationErrorMetric
196+
:members:
183197

184198

185199
Utilities

monai/apps/auto3dseg/bundle_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def _create_cmd(self, train_params: None | dict = None) -> tuple[str, str]:
208208
config_files = []
209209
if os.path.isdir(config_dir):
210210
for file in sorted(os.listdir(config_dir)):
211-
if file.endswith("yaml") or file.endswith("json"):
211+
if file.endswith(("yaml", "json")):
212212
# Python Fire may be confused by single-quoted WindowsPath
213213
config_files.append(Path(os.path.join(config_dir, file)).as_posix())
214214

monai/apps/deepedit/transforms.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ class NormalizeLabelsInDatasetd(RemapLabelsToSequentiald):
164164
which better describes the transform's functionality.
165165
"""
166166

167-
pass
168-
169167

170168
class SingleLabelSelectiond(MapTransform):
171169

monai/apps/detection/networks/retinanet_network.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ def forward(self, x: list[Tensor]) -> list[Tensor]:
125125

126126
cls_logits_maps.append(cls_logits)
127127

128-
if torch.isnan(cls_logits).any() or torch.isinf(cls_logits).any():
129-
if torch.is_grad_enabled():
130-
raise ValueError("cls_logits is NaN or Inf.")
131-
else:
132-
warnings.warn("cls_logits is NaN or Inf.")
128+
if not torch.compiler.is_compiling():
129+
if torch.isnan(cls_logits).any() or torch.isinf(cls_logits).any():
130+
if torch.is_grad_enabled():
131+
raise ValueError("cls_logits is NaN or Inf.")
132+
else:
133+
warnings.warn("cls_logits is NaN or Inf.")
133134

134135
return cls_logits_maps
135136

@@ -197,11 +198,12 @@ def forward(self, x: list[Tensor]) -> list[Tensor]:
197198

198199
box_regression_maps.append(box_regression)
199200

200-
if torch.isnan(box_regression).any() or torch.isinf(box_regression).any():
201-
if torch.is_grad_enabled():
202-
raise ValueError("box_regression is NaN or Inf.")
203-
else:
204-
warnings.warn("box_regression is NaN or Inf.")
201+
if not torch.compiler.is_compiling():
202+
if torch.isnan(box_regression).any() or torch.isinf(box_regression).any():
203+
if torch.is_grad_enabled():
204+
raise ValueError("box_regression is NaN or Inf.")
205+
else:
206+
warnings.warn("box_regression is NaN or Inf.")
205207

206208
return box_regression_maps
207209

0 commit comments

Comments
 (0)