Skip to content

Commit 3797e0b

Browse files
committed
Merge branch 'dev' into fix-compose
2 parents 2c28c37 + 996e876 commit 3797e0b

Some content is hidden

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

66 files changed

+2924
-302
lines changed

.github/workflows/cron.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616
- "PT110+CUDA113"
1717
- "PT113+CUDA118"
1818
- "PT210+CUDA121"
19-
- "PTLATEST+CUDA124"
19+
- "PT240+CUDA126"
20+
- "PTLATEST+CUDA126"
2021
include:
2122
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes
2223
- environment: PT110+CUDA113
@@ -28,9 +29,12 @@ jobs:
2829
- environment: PT210+CUDA121
2930
pytorch: "pytorch==2.1.0 torchvision==0.16.0 --extra-index-url https://download.pytorch.org/whl/cu121"
3031
base: "nvcr.io/nvidia/pytorch:23.08-py3" # CUDA 12.1
31-
- environment: PTLATEST+CUDA124
32+
- environment: PT240+CUDA126
33+
pytorch: "pytorch==2.4.0 torchvision==0.19.0 --extra-index-url https://download.pytorch.org/whl/cu121"
34+
base: "nvcr.io/nvidia/pytorch:24.08-py3" # CUDA 12.6
35+
- environment: PTLATEST+CUDA126
3236
pytorch: "-U torch torchvision --extra-index-url https://download.pytorch.org/whl/cu121"
33-
base: "nvcr.io/nvidia/pytorch:24.08-py3" # CUDA 12.4
37+
base: "nvcr.io/nvidia/pytorch:24.10-py3" # CUDA 12.6
3438
container:
3539
image: ${{ matrix.base }}
3640
options: "--gpus all"
@@ -71,7 +75,7 @@ jobs:
7175
if pgrep python; then pkill python; fi
7276
shell: bash
7377
- name: Upload coverage
74-
uses: codecov/codecov-action@v4
78+
uses: codecov/codecov-action@v5
7579
with:
7680
fail_ci_if_error: false
7781
files: ./coverage.xml
@@ -80,7 +84,7 @@ jobs:
8084
if: github.repository == 'Project-MONAI/MONAI'
8185
strategy:
8286
matrix:
83-
container: ["pytorch:23.08", "pytorch:24.08"]
87+
container: ["pytorch:23.08", "pytorch:24.08", "pytorch:24.10"]
8488
container:
8589
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
8690
options: "--gpus all"
@@ -119,7 +123,7 @@ jobs:
119123
if pgrep python; then pkill python; fi
120124
shell: bash
121125
- name: Upload coverage
122-
uses: codecov/codecov-action@v4
126+
uses: codecov/codecov-action@v5
123127
with:
124128
fail_ci_if_error: false
125129
files: ./coverage.xml
@@ -129,7 +133,7 @@ jobs:
129133
if: github.repository == 'Project-MONAI/MONAI'
130134
strategy:
131135
matrix:
132-
container: ["pytorch:24.08"]
136+
container: ["pytorch:24.10"]
133137
container:
134138
image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image
135139
options: "--gpus all"
@@ -224,7 +228,7 @@ jobs:
224228
if pgrep python; then pkill python; fi
225229
shell: bash
226230
- name: Upload coverage
227-
uses: codecov/codecov-action@v4
231+
uses: codecov/codecov-action@v5
228232
with:
229233
fail_ci_if_error: false
230234
files: ./coverage.xml
@@ -233,7 +237,7 @@ jobs:
233237
if: github.repository == 'Project-MONAI/MONAI'
234238
needs: cron-gpu # so that monai itself is verified first
235239
container:
236-
image: nvcr.io/nvidia/pytorch:24.08-py3 # testing with the latest pytorch base image
240+
image: nvcr.io/nvidia/pytorch:24.10-py3 # testing with the latest pytorch base image
237241
options: "--gpus all --ipc=host"
238242
runs-on: [self-hosted, linux, x64, integration]
239243
steps:

.github/workflows/pythonapp-gpu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,6 @@ jobs:
137137
shell: bash
138138
- name: Upload coverage
139139
if: ${{ github.head_ref != 'dev' && github.event.pull_request.merged != true }}
140-
uses: codecov/codecov-action@v4
140+
uses: codecov/codecov-action@v5
141141
with:
142142
files: ./coverage.xml

.github/workflows/setupapp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
if pgrep python; then pkill python; fi
7373
shell: bash
7474
- name: Upload coverage
75-
uses: codecov/codecov-action@v4
75+
uses: codecov/codecov-action@v5
7676
with:
7777
fail_ci_if_error: false
7878
files: ./coverage.xml
@@ -119,7 +119,7 @@ jobs:
119119
BUILD_MONAI=1 ./runtests.sh --build --quick --min
120120
coverage xml --ignore-errors
121121
- name: Upload coverage
122-
uses: codecov/codecov-action@v4
122+
uses: codecov/codecov-action@v5
123123
with:
124124
fail_ci_if_error: false
125125
files: ./coverage.xml

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ tests/testing_data/nrrd_example.nrrd
149149
# clang format tool
150150
.clang-format-bin/
151151

152+
# ctags
153+
tags
154+
152155
# VSCode
153156
.vscode/
154157
*.zip

Dockerfile

Lines changed: 7 additions & 1 deletion
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.08-py3
14+
ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:24.10-py3
1515
FROM ${PYTORCH_IMAGE}
1616

1717
LABEL maintainer="[email protected]"
@@ -41,6 +41,10 @@ RUN cp /tmp/requirements.txt /tmp/req.bak \
4141
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py setup.cfg runtests.sh MANIFEST.in ./
4242
COPY tests ./tests
4343
COPY monai ./monai
44+
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+
4448
RUN BUILD_MONAI=1 FORCE_CUDA=1 python setup.py develop \
4549
&& rm -rf build __pycache__
4650

@@ -57,4 +61,6 @@ RUN apt-get update \
5761
# append /opt/tools to runtime path for NGC CLI to be accessible from all file system locations
5862
ENV PATH=${PATH}:/opt/tools
5963
ENV POLYGRAPHY_AUTOINSTALL_DEPS=1
64+
65+
6066
WORKDIR /opt/monai

docs/source/networks.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ Nets
630630
.. autoclass:: ViTAutoEnc
631631
:members:
632632

633+
`MaskedAutoEncoderViT`
634+
~~~~~~~~~~~~~~~~~~~~~~
635+
.. autoclass:: MaskedAutoEncoderViT
636+
:members:
637+
633638
`FullyConnectedNet`
634639
~~~~~~~~~~~~~~~~~~~
635640
.. autoclass:: FullyConnectedNet

docs/source/transforms.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,18 @@ Utility
11801180
:members:
11811181
:special-members: __call__
11821182

1183+
`TorchIO`
1184+
"""""""""
1185+
.. autoclass:: TorchIO
1186+
:members:
1187+
:special-members: __call__
1188+
1189+
`RandTorchIO`
1190+
"""""""""""""
1191+
.. autoclass:: RandTorchIO
1192+
:members:
1193+
:special-members: __call__
1194+
11831195
`MapLabelValue`
11841196
"""""""""""""""
11851197
.. autoclass:: MapLabelValue
@@ -2253,6 +2265,18 @@ Utility (Dict)
22532265
:members:
22542266
:special-members: __call__
22552267

2268+
`TorchIOd`
2269+
""""""""""
2270+
.. autoclass:: TorchIOd
2271+
:members:
2272+
:special-members: __call__
2273+
2274+
`RandTorchIOd`
2275+
""""""""""""""
2276+
.. autoclass:: RandTorchIOd
2277+
:members:
2278+
:special-members: __call__
2279+
22562280
`MapLabelValued`
22572281
""""""""""""""""
22582282
.. autoclass:: MapLabelValued

environment-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ channels:
77
dependencies:
88
- numpy>=1.24,<2.0
99
- pytorch>=1.9
10+
- torchio
1011
- torchvision
1112
- pytorch-cuda>=11.6
1213
- pip

monai/apps/utils.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616
import logging
1717
import os
18+
import re
1819
import shutil
1920
import sys
2021
import tarfile
@@ -30,7 +31,9 @@
3031
from monai.config.type_definitions import PathLike
3132
from monai.utils import look_up_option, min_version, optional_import
3233

34+
requests, has_requests = optional_import("requests")
3335
gdown, has_gdown = optional_import("gdown", "4.7.3")
36+
BeautifulSoup, has_bs4 = optional_import("bs4", name="BeautifulSoup")
3437

3538
if TYPE_CHECKING:
3639
from tqdm import tqdm
@@ -298,6 +301,29 @@ def extractall(
298301
)
299302

300303

304+
def get_filename_from_url(data_url: str) -> str:
305+
"""
306+
Get the filename from the URL link.
307+
"""
308+
try:
309+
response = requests.head(data_url, allow_redirects=True)
310+
content_disposition = response.headers.get("Content-Disposition")
311+
if content_disposition:
312+
filename = re.findall('filename="?([^";]+)"?', content_disposition)
313+
if filename:
314+
return str(filename[0])
315+
if "drive.google.com" in data_url:
316+
response = requests.get(data_url)
317+
if "text/html" in response.headers.get("Content-Type", ""):
318+
soup = BeautifulSoup(response.text, "html.parser")
319+
filename_div = soup.find("span", {"class": "uc-name-size"})
320+
if filename_div:
321+
return str(filename_div.find("a").text)
322+
return _basename(data_url)
323+
except Exception as e:
324+
raise Exception(f"Error processing URL: {e}") from e
325+
326+
301327
def download_and_extract(
302328
url: str,
303329
filepath: PathLike = "",
@@ -327,7 +353,18 @@ def download_and_extract(
327353
be False.
328354
progress: whether to display progress bar.
329355
"""
356+
url_filename_ext = "".join(Path(get_filename_from_url(url)).suffixes)
357+
filepath_ext = "".join(Path(_basename(filepath)).suffixes)
358+
if filepath not in ["", "."]:
359+
if filepath_ext == "":
360+
new_filepath = Path(filepath).with_suffix(url_filename_ext)
361+
logger.warning(
362+
f"filepath={filepath}, which missing file extension. Auto-appending extension to: {new_filepath}"
363+
)
364+
filepath = new_filepath
365+
if filepath_ext and filepath_ext != url_filename_ext:
366+
raise ValueError(f"File extension mismatch: expected extension {url_filename_ext}, but get {filepath_ext}")
330367
with tempfile.TemporaryDirectory() as tmp_dir:
331-
filename = filepath or Path(tmp_dir, _basename(url)).resolve()
368+
filename = filepath or Path(tmp_dir, get_filename_from_url(url)).resolve()
332369
download_url(url=url, filepath=filename, hash_val=hash_val, hash_type=hash_type, progress=progress)
333370
extractall(filepath=filename, output_dir=output_dir, file_type=file_type, has_base=has_base)

monai/bundle/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
MACRO_KEY,
4444
load_bundle_config,
4545
)
46-
from .workflows import BundleWorkflow, ConfigWorkflow
46+
from .workflows import BundleWorkflow, ConfigWorkflow, PythonicWorkflow

0 commit comments

Comments
 (0)