From bc3dcee1979e322035b3e0ee0c556a644fff5400 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:34:52 +0100 Subject: [PATCH 01/18] Refactoring min-dep tests Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/pythonapp-min.yml | 283 ++++++++++++++++++---------- 1 file changed, 179 insertions(+), 104 deletions(-) diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index 0d147ca264..87b991c532 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -18,23 +18,45 @@ concurrency: cancel-in-progress: true jobs: - # caching of these jobs: - # - docker-py3-pip- (shared) - # - ubuntu py37 pip- - # - os-latest-pip- (shared) - min-dep-os: # min dependencies installed tests for different OS + min-dep: # min dependencies installed tests for different OS runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [windows-latest, macOS-latest, ubuntu-latest] + python-version: ['3.9'] + pytorch-version: ['2.5.1'] + include: + # Test Python versions under Ubuntu with lowest PyTorch version supported + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.10' + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.11' + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.12' + + # test PyTorch versions under Ubuntu and lowest Python version supported + - os: ubuntu-latest + python-version: '3.9' + pytorch-version: '2.6.0' + - os: ubuntu-latest + python-version: '3.9' + pytorch-version: '2.7.1' + - os: ubuntu-latest + python-version: '3.9' + pytorch-version: '2.8.0' + + timeout-minutes: 40 steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: ${{ matrix.python-version }} - name: Prepare pip wheel run: | which python @@ -51,10 +73,10 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies + - name: Install the dependencies with PyTorch ${{ matrix.pytorch-version }} run: | # min. requirements - python -m pip install torch --index-url https://download.pytorch.org/whl/cpu + python -m pip install torch==${{ matrix.pytorch-version }} python -m pip install -r requirements-min.txt python -m pip list BUILD_MONAI=0 python setup.py develop # no compile of extensions @@ -63,7 +85,7 @@ jobs: run: | python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' python -c "import monai; monai.config.print_config()" - ./runtests.sh --min + # ./runtests.sh --min shell: bash env: QUICKTEST: True @@ -71,98 +93,151 @@ jobs: NGC_ORG: ${{ secrets.NGC_ORG }} NGC_TEAM: ${{ secrets.NGC_TEAM }} - min-dep-py3: # min dependencies installed tests for different python - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] - timeout-minutes: 40 - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Prepare pip wheel - run: | - which python - python -m pip install --user --upgrade pip setuptools wheel - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies - run: | - # min. requirements - python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu - python -m pip install -r requirements-min.txt - python -m pip list - BUILD_MONAI=0 python setup.py develop # no compile of extensions - shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) - run: | - python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - python -c "import monai; monai.config.print_config()" - ./runtests.sh --min - env: - QUICKTEST: True - NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - NGC_ORG: ${{ secrets.NGC_ORG }} - NGC_TEAM: ${{ secrets.NGC_TEAM }} + # # caching of these jobs: + # # - docker-py3-pip- (shared) + # # - ubuntu py37 pip- + # # - os-latest-pip- (shared) + # min-dep-os: # min dependencies installed tests for different OS + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [windows-latest, macOS-latest, ubuntu-latest] + # timeout-minutes: 40 + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Python 3.9 + # uses: actions/setup-python@v5 + # with: + # python-version: '3.9' + # - name: Prepare pip wheel + # run: | + # which python + # python -m pip install --upgrade pip wheel + # - name: cache weekly timestamp + # id: pip-cache + # run: | + # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + # shell: bash + # - name: cache for pip + # uses: actions/cache@v4 + # id: cache + # with: + # path: ${{ steps.pip-cache.outputs.dir }} + # key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} + # - name: Install the dependencies + # run: | + # # min. requirements + # python -m pip install torch --index-url https://download.pytorch.org/whl/cpu + # python -m pip install -r requirements-min.txt + # python -m pip list + # BUILD_MONAI=0 python setup.py develop # no compile of extensions + # shell: bash + # - name: Run quick tests (CPU ${{ runner.os }}) + # run: | + # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' + # python -c "import monai; monai.config.print_config()" + # ./runtests.sh --min + # shell: bash + # env: + # QUICKTEST: True + # NGC_API_KEY: ${{ secrets.NGC_API_KEY }} + # NGC_ORG: ${{ secrets.NGC_ORG }} + # NGC_TEAM: ${{ secrets.NGC_TEAM }} - min-dep-pytorch: # min dependencies installed tests for different pytorch - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - pytorch-version: ['2.5.1', '2.6.0', '2.7.1', '2.8.0'] - timeout-minutes: 40 - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Prepare pip wheel - run: | - which python - python -m pip install --user --upgrade pip setuptools wheel - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies - run: | - # min. requirements - python -m pip install torch==${{ matrix.pytorch-version }} - python -m pip install -r requirements-min.txt - python -m pip list - BUILD_MONAI=0 python setup.py develop # no compile of extensions - shell: bash - - name: Run quick tests (pytorch ${{ matrix.pytorch-version }}) - run: | - python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - python -c "import monai; monai.config.print_config()" - ./runtests.sh --min - env: - QUICKTEST: True - NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - NGC_ORG: ${{ secrets.NGC_ORG }} - NGC_TEAM: ${{ secrets.NGC_TEAM }} + # min-dep-py3: # min dependencies installed tests for different python + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # matrix: + # python-version: ['3.9', '3.10', '3.11', '3.12'] + # timeout-minutes: 40 + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v5 + # with: + # python-version: ${{ matrix.python-version }} + # - name: Prepare pip wheel + # run: | + # which python + # python -m pip install --user --upgrade pip setuptools wheel + # - name: cache weekly timestamp + # id: pip-cache + # run: | + # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + # shell: bash + # - name: cache for pip + # uses: actions/cache@v4 + # id: cache + # with: + # path: ${{ steps.pip-cache.outputs.dir }} + # key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} + # - name: Install the dependencies + # run: | + # # min. requirements + # python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu + # python -m pip install -r requirements-min.txt + # python -m pip list + # BUILD_MONAI=0 python setup.py develop # no compile of extensions + # shell: bash + # - name: Run quick tests (CPU ${{ runner.os }}) + # run: | + # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' + # python -c "import monai; monai.config.print_config()" + # ./runtests.sh --min + # env: + # QUICKTEST: True + # NGC_API_KEY: ${{ secrets.NGC_API_KEY }} + # NGC_ORG: ${{ secrets.NGC_ORG }} + # NGC_TEAM: ${{ secrets.NGC_TEAM }} + + # min-dep-pytorch: # min dependencies installed tests for different pytorch + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # matrix: + # pytorch-version: ['2.5.1', '2.6.0', '2.7.1', '2.8.0'] + # timeout-minutes: 40 + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Python 3.9 + # uses: actions/setup-python@v5 + # with: + # python-version: '3.9' + # - name: Prepare pip wheel + # run: | + # which python + # python -m pip install --user --upgrade pip setuptools wheel + # - name: cache weekly timestamp + # id: pip-cache + # run: | + # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + # shell: bash + # - name: cache for pip + # uses: actions/cache@v4 + # id: cache + # with: + # path: ${{ steps.pip-cache.outputs.dir }} + # key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} + # - name: Install the dependencies + # run: | + # # min. requirements + # python -m pip install torch==${{ matrix.pytorch-version }} + # python -m pip install -r requirements-min.txt + # python -m pip list + # BUILD_MONAI=0 python setup.py develop # no compile of extensions + # shell: bash + # - name: Run quick tests (pytorch ${{ matrix.pytorch-version }}) + # run: | + # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' + # python -c "import monai; monai.config.print_config()" + # ./runtests.sh --min + # env: + # QUICKTEST: True + # NGC_API_KEY: ${{ secrets.NGC_API_KEY }} + # NGC_ORG: ${{ secrets.NGC_ORG }} + # NGC_TEAM: ${{ secrets.NGC_TEAM }} From 2b9a9924d0ea66f272158cd451e477f58edbbb14 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:39:52 +0100 Subject: [PATCH 02/18] Update test Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/pythonapp-min.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index 87b991c532..3b70fb100b 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -1,4 +1,3 @@ -# Jenkinsfile.monai-premerge name: premerge-min on: @@ -29,27 +28,20 @@ jobs: include: # Test Python versions under Ubuntu with lowest PyTorch version supported - os: ubuntu-latest - pytorch-version: '2.5.1' python-version: '3.10' - os: ubuntu-latest - pytorch-version: '2.5.1' python-version: '3.11' - os: ubuntu-latest - pytorch-version: '2.5.1' python-version: '3.12' - # test PyTorch versions under Ubuntu and lowest Python version supported + # Test PyTorch versions under Ubuntu with lowest Python version supported - os: ubuntu-latest - python-version: '3.9' pytorch-version: '2.6.0' - os: ubuntu-latest - python-version: '3.9' pytorch-version: '2.7.1' - os: ubuntu-latest - python-version: '3.9' pytorch-version: '2.8.0' - timeout-minutes: 40 steps: - uses: actions/checkout@v4 From 44bc1aedc282140cdc09abe32a1f2879ff7c7814 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:43:34 +0100 Subject: [PATCH 03/18] Update test Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/pythonapp-min.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index 3b70fb100b..8f019e1f54 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -23,8 +23,8 @@ jobs: fail-fast: false matrix: os: [windows-latest, macOS-latest, ubuntu-latest] - python-version: ['3.9'] - pytorch-version: ['2.5.1'] + python-version: '3.9' + pytorch-version: '2.5.1' include: # Test Python versions under Ubuntu with lowest PyTorch version supported - os: ubuntu-latest From 0c8c868577549356c8298d5fcc91223142c620e9 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:45:13 +0100 Subject: [PATCH 04/18] Restoring include that worked Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/pythonapp-min.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index 8f019e1f54..48f422af26 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -23,23 +23,29 @@ jobs: fail-fast: false matrix: os: [windows-latest, macOS-latest, ubuntu-latest] - python-version: '3.9' - pytorch-version: '2.5.1' + python-version: ['3.9'] + pytorch-version: ['2.5.1'] include: # Test Python versions under Ubuntu with lowest PyTorch version supported - os: ubuntu-latest + pytorch-version: '2.5.1' python-version: '3.10' - os: ubuntu-latest + pytorch-version: '2.5.1' python-version: '3.11' - os: ubuntu-latest + pytorch-version: '2.5.1' python-version: '3.12' # Test PyTorch versions under Ubuntu with lowest Python version supported - os: ubuntu-latest + python-version: '3.9' pytorch-version: '2.6.0' - os: ubuntu-latest + python-version: '3.9' pytorch-version: '2.7.1' - os: ubuntu-latest + python-version: '3.9' pytorch-version: '2.8.0' timeout-minutes: 40 From e3616e4e262437f24ddfd260f89c0309b228c8d0 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 12:57:07 +0100 Subject: [PATCH 05/18] Renaming file Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/{pythonapp-min.yml => cicd_tests.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{pythonapp-min.yml => cicd_tests.yml} (100%) diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/cicd_tests.yml similarity index 100% rename from .github/workflows/pythonapp-min.yml rename to .github/workflows/cicd_tests.yml From 53cb0a4f31ec054c57b0a0d59cb1f0dce5ac8a56 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 13:05:26 +0100 Subject: [PATCH 06/18] Combining tests Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 367 ++++++++++++++++++------------- 1 file changed, 220 insertions(+), 147 deletions(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 48f422af26..a8ccc110ec 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -1,4 +1,4 @@ -name: premerge-min +name: tests on: # quick tests for pull requests and the releasing branches @@ -17,6 +17,39 @@ concurrency: cancel-in-progress: true jobs: + static-checks: + runs-on: ubuntu-latest + strategy: + matrix: + opt: ["codeformat", "pytype", "mypy"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: '3.9' + - name: cache weekly timestamp + id: pip-cache + run: | + echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + - name: cache for pip + uses: actions/cache@v4 + id: cache + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} + - name: Install dependencies + run: | + find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; + python -m pip install --upgrade pip wheel + python -m pip install -r requirements-dev.txt + - name: Lint and type check + run: | + # clean up temporary files + $(pwd)/runtests.sh --build --clean + # Github actions have 2 cores, so parallelize pytype + $(pwd)/runtests.sh --build --${{ matrix.opt }} -j 2 + min-dep: # min dependencies installed tests for different OS runs-on: ${{ matrix.os }} strategy: @@ -91,151 +124,191 @@ jobs: NGC_ORG: ${{ secrets.NGC_ORG }} NGC_TEAM: ${{ secrets.NGC_TEAM }} - # # caching of these jobs: - # # - docker-py3-pip- (shared) - # # - ubuntu py37 pip- - # # - os-latest-pip- (shared) - # min-dep-os: # min dependencies installed tests for different OS - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, macOS-latest, ubuntu-latest] - # timeout-minutes: 40 - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Python 3.9 - # uses: actions/setup-python@v5 - # with: - # python-version: '3.9' - # - name: Prepare pip wheel - # run: | - # which python - # python -m pip install --upgrade pip wheel - # - name: cache weekly timestamp - # id: pip-cache - # run: | - # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - # shell: bash - # - name: cache for pip - # uses: actions/cache@v4 - # id: cache - # with: - # path: ${{ steps.pip-cache.outputs.dir }} - # key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - # - name: Install the dependencies - # run: | - # # min. requirements - # python -m pip install torch --index-url https://download.pytorch.org/whl/cpu - # python -m pip install -r requirements-min.txt - # python -m pip list - # BUILD_MONAI=0 python setup.py develop # no compile of extensions - # shell: bash - # - name: Run quick tests (CPU ${{ runner.os }}) - # run: | - # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - # python -c "import monai; monai.config.print_config()" - # ./runtests.sh --min - # shell: bash - # env: - # QUICKTEST: True - # NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - # NGC_ORG: ${{ secrets.NGC_ORG }} - # NGC_TEAM: ${{ secrets.NGC_TEAM }} + full-dep: # full dependencies installed tests for different OS + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, macOS-latest, ubuntu-latest] + timeout-minutes: 120 + steps: + - if: runner.os == 'windows' + name: Config pagefile (Windows only) + uses: al-cheb/configure-pagefile-action@v1.4 + with: + minimum-size: 8GB + maximum-size: 16GB + disk-root: "D:" + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: '3.9' + - name: Prepare pip wheel + run: | + which python + python -m pip install --upgrade pip wheel + - name: cache weekly timestamp + id: pip-cache + run: | + echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + shell: bash + - name: cache for pip + uses: actions/cache@v4 + id: cache + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} + - if: runner.os == 'windows' + name: Install torch cpu from pytorch.org (Windows only) + run: | + python -m pip install torch==2.5.1 torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu + - if: runner.os == 'Linux' + name: Install itk pre-release (Linux only) + run: | + python -m pip install --pre -U itk + find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; + - name: Install the dependencies + run: | + python -m pip install --user --upgrade pip wheel + python -m pip install torch==2.5.1 torchvision==0.20.1 + cat "requirements-dev.txt" + python -m pip install -r requirements-dev.txt + python -m pip list + python setup.py develop # test no compile installation + shell: bash + - name: Run compiled (${{ runner.os }}) + run: | + python setup.py develop --uninstall + BUILD_MONAI=1 python setup.py develop # compile the cpp extensions + shell: bash + - name: Run quick tests (CPU ${{ runner.os }}) + run: | + python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' + python -c "import monai; monai.config.print_config()" + # python -m unittest -v + env: + QUICKTEST: True + PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 + + packaging: + runs-on: ubuntu-latest + env: + QUICKTEST: True + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: '3.9' + - name: cache weekly timestamp + id: pip-cache + run: | + echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + - name: cache for pip + uses: actions/cache@v4 + id: cache + with: + path: | + ~/.cache/pip + ~/.cache/torch + key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} + - name: Install dependencies + run: | + find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; + python -m pip install --user --upgrade pip setuptools wheel twine packaging + # install the latest pytorch for testing + # however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated + # fresh torch installation according to pyproject.toml + python -m pip install torch>=2.5.1 torchvision + - name: Check packages + run: | + pip uninstall monai + pip list | grep -iv monai + git fetch --depth=1 origin +refs/tags/*:refs/tags/* + set -e - # min-dep-py3: # min dependencies installed tests for different python - # runs-on: ubuntu-latest - # strategy: - # fail-fast: false - # matrix: - # python-version: ['3.9', '3.10', '3.11', '3.12'] - # timeout-minutes: 40 - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v5 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Prepare pip wheel - # run: | - # which python - # python -m pip install --user --upgrade pip setuptools wheel - # - name: cache weekly timestamp - # id: pip-cache - # run: | - # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - # shell: bash - # - name: cache for pip - # uses: actions/cache@v4 - # id: cache - # with: - # path: ${{ steps.pip-cache.outputs.dir }} - # key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} - # - name: Install the dependencies - # run: | - # # min. requirements - # python -m pip install torch --extra-index-url https://download.pytorch.org/whl/cpu - # python -m pip install -r requirements-min.txt - # python -m pip list - # BUILD_MONAI=0 python setup.py develop # no compile of extensions - # shell: bash - # - name: Run quick tests (CPU ${{ runner.os }}) - # run: | - # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - # python -c "import monai; monai.config.print_config()" - # ./runtests.sh --min - # env: - # QUICKTEST: True - # NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - # NGC_ORG: ${{ secrets.NGC_ORG }} - # NGC_TEAM: ${{ secrets.NGC_TEAM }} + # build tar.gz and wheel + python setup.py check -m -s + python setup.py sdist bdist_wheel + python -m twine check dist/* + - run: echo "pwd=$PWD" >> $GITHUB_OUTPUT + id: root + - run: echo "tmp_dir=$(mktemp -d)" >> $GITHUB_OUTPUT + id: mktemp + - name: Move packages + run: | + printf ${{ steps.root.outputs.pwd }} + printf ${{ steps.mktemp.outputs.tmp_dir }} + # move packages to a temp dir + cp dist/monai* "${{ steps.mktemp.outputs.tmp_dir }}" + rm -r build dist monai.egg-info + cd "${{ steps.mktemp.outputs.tmp_dir }}" + ls -al + - name: Install wheel file + working-directory: ${{ steps.mktemp.outputs.tmp_dir }} + run: | + # install from wheel + python -m pip install monai*.whl + python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown" + python -c 'import monai; print(monai.__file__)' + python -m pip uninstall -y monai + rm monai*.whl + - name: Install source archive + working-directory: ${{ steps.mktemp.outputs.tmp_dir }} + run: | + # install from tar.gz + name=$(ls *.tar.gz | head -n1) + echo $name + python -m pip install $name[all] + python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown" + python -c 'import monai; print(monai.__file__)' + - name: Quick test + working-directory: ${{ steps.mktemp.outputs.tmp_dir }} + run: | + # run min tests + cp ${{ steps.root.outputs.pwd }}/requirements*.txt . + cp -r ${{ steps.root.outputs.pwd }}/tests . + ls -al + python -m pip install -r requirements-dev.txt + python -m unittest -v + env: + PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - # min-dep-pytorch: # min dependencies installed tests for different pytorch - # runs-on: ubuntu-latest - # strategy: - # fail-fast: false - # matrix: - # pytorch-version: ['2.5.1', '2.6.0', '2.7.1', '2.8.0'] - # timeout-minutes: 40 - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Python 3.9 - # uses: actions/setup-python@v5 - # with: - # python-version: '3.9' - # - name: Prepare pip wheel - # run: | - # which python - # python -m pip install --user --upgrade pip setuptools wheel - # - name: cache weekly timestamp - # id: pip-cache - # run: | - # echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - # echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - # shell: bash - # - name: cache for pip - # uses: actions/cache@v4 - # id: cache - # with: - # path: ${{ steps.pip-cache.outputs.dir }} - # key: ubuntu-latest-latest-pip-${{ steps.pip-cache.outputs.datew }} - # - name: Install the dependencies - # run: | - # # min. requirements - # python -m pip install torch==${{ matrix.pytorch-version }} - # python -m pip install -r requirements-min.txt - # python -m pip list - # BUILD_MONAI=0 python setup.py develop # no compile of extensions - # shell: bash - # - name: Run quick tests (pytorch ${{ matrix.pytorch-version }}) - # run: | - # python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - # python -c "import monai; monai.config.print_config()" - # ./runtests.sh --min - # env: - # QUICKTEST: True - # NGC_API_KEY: ${{ secrets.NGC_API_KEY }} - # NGC_ORG: ${{ secrets.NGC_ORG }} - # NGC_TEAM: ${{ secrets.NGC_TEAM }} + build-docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.9 + uses: actions/setup-python@v5 + with: + python-version: '3.9' + - name: cache weekly timestamp + id: pip-cache + run: | + echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT + - name: cache for pip + uses: actions/cache@v4 + id: cache + with: + path: | + ~/.cache/pip + ~/.cache/torch + key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + python -m pip install -r docs/requirements.txt + - name: Make html + run: | + cd docs/ + make clean + make html 2>&1 | tee tmp_log + if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "found errors"; grep "ERROR:" tmp_log; exit 1; fi + sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133 + if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi + shell: bash From 28f06ff8e75b4c617ccd163f183c78f8cff5e618 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 13:06:16 +0100 Subject: [PATCH 07/18] Removing combined file Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 245 -------------------------------- 1 file changed, 245 deletions(-) delete mode 100644 .github/workflows/pythonapp.yml diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml deleted file mode 100644 index c68c879231..0000000000 --- a/.github/workflows/pythonapp.yml +++ /dev/null @@ -1,245 +0,0 @@ -# Jenkinsfile.monai-premerge -name: premerge - -on: - # quick tests for pull requests and the releasing branches - push: - branches: - - dev - - main - - releasing/* - pull_request: - head_ref-ignore: - - dev - -concurrency: - # automatically cancel the previously triggered workflows when there's a newer version - group: build-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - # caching of these jobs: - # - docker-py3-pip- (shared) - # - ubuntu py37 pip- - # - os-latest-pip- (shared) - flake8-py3: - runs-on: ubuntu-latest - strategy: - matrix: - opt: ["codeformat", "pytype", "mypy"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install dependencies - run: | - find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; - python -m pip install --upgrade pip wheel - python -m pip install -r requirements-dev.txt - - name: Lint and type check - run: | - # clean up temporary files - $(pwd)/runtests.sh --build --clean - # Github actions have 2 cores, so parallelize pytype - $(pwd)/runtests.sh --build --${{ matrix.opt }} -j 2 - - quick-py3: # full dependencies installed tests for different OS - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest, macOS-latest, ubuntu-latest] - timeout-minutes: 120 - steps: - - if: runner.os == 'windows' - name: Config pagefile (Windows only) - uses: al-cheb/configure-pagefile-action@v1.4 - with: - minimum-size: 8GB - maximum-size: 16GB - disk-root: "D:" - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: Prepare pip wheel - run: | - which python - python -m pip install --upgrade pip wheel - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT - shell: bash - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - - if: runner.os == 'windows' - name: Install torch cpu from pytorch.org (Windows only) - run: | - python -m pip install torch==2.5.1 torchvision==0.20.1+cpu --index-url https://download.pytorch.org/whl/cpu - - if: runner.os == 'Linux' - name: Install itk pre-release (Linux only) - run: | - python -m pip install --pre -U itk - find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; - - name: Install the dependencies - run: | - python -m pip install --user --upgrade pip wheel - python -m pip install torch==2.5.1 torchvision==0.20.1 - cat "requirements-dev.txt" - python -m pip install -r requirements-dev.txt - python -m pip list - python setup.py develop # test no compile installation - shell: bash - - name: Run compiled (${{ runner.os }}) - run: | - python setup.py develop --uninstall - BUILD_MONAI=1 python setup.py develop # compile the cpp extensions - shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) - run: | - python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' - python -c "import monai; monai.config.print_config()" - python -m unittest -v - env: - QUICKTEST: True - PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - - packaging: - runs-on: ubuntu-latest - env: - QUICKTEST: True - shell: bash - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: | - ~/.cache/pip - ~/.cache/torch - key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install dependencies - run: | - find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; - python -m pip install --user --upgrade pip setuptools wheel twine packaging - # install the latest pytorch for testing - # however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated - # fresh torch installation according to pyproject.toml - python -m pip install torch>=2.5.1 torchvision - - name: Check packages - run: | - pip uninstall monai - pip list | grep -iv monai - git fetch --depth=1 origin +refs/tags/*:refs/tags/* - set -e - - # build tar.gz and wheel - python setup.py check -m -s - python setup.py sdist bdist_wheel - python -m twine check dist/* - - run: echo "pwd=$PWD" >> $GITHUB_OUTPUT - id: root - - run: echo "tmp_dir=$(mktemp -d)" >> $GITHUB_OUTPUT - id: mktemp - - name: Move packages - run: | - printf ${{ steps.root.outputs.pwd }} - printf ${{ steps.mktemp.outputs.tmp_dir }} - # move packages to a temp dir - cp dist/monai* "${{ steps.mktemp.outputs.tmp_dir }}" - rm -r build dist monai.egg-info - cd "${{ steps.mktemp.outputs.tmp_dir }}" - ls -al - - name: Install wheel file - working-directory: ${{ steps.mktemp.outputs.tmp_dir }} - run: | - # install from wheel - python -m pip install monai*.whl - python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown" - python -c 'import monai; print(monai.__file__)' - python -m pip uninstall -y monai - rm monai*.whl - - name: Install source archive - working-directory: ${{ steps.mktemp.outputs.tmp_dir }} - run: | - # install from tar.gz - name=$(ls *.tar.gz | head -n1) - echo $name - python -m pip install $name[all] - python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown" - python -c 'import monai; print(monai.__file__)' - - name: Quick test - working-directory: ${{ steps.mktemp.outputs.tmp_dir }} - run: | - # run min tests - cp ${{ steps.root.outputs.pwd }}/requirements*.txt . - cp -r ${{ steps.root.outputs.pwd }}/tests . - ls -al - python -m pip install -r requirements-dev.txt - python -m unittest -v - env: - PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - - build-docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.9 - uses: actions/setup-python@v5 - with: - python-version: '3.9' - - name: cache weekly timestamp - id: pip-cache - run: | - echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - - name: cache for pip - uses: actions/cache@v4 - id: cache - with: - path: | - ~/.cache/pip - ~/.cache/torch - key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip wheel - python -m pip install -r docs/requirements.txt - - name: Make html - run: | - cd docs/ - make clean - make html 2>&1 | tee tmp_log - if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "found errors"; grep "ERROR:" tmp_log; exit 1; fi - sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133 - if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi - shell: bash From 4d8807555e420f0aa4f1adfa52c599fb2913fb0f Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 13:38:11 +0100 Subject: [PATCH 08/18] Script update Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index a8ccc110ec..25870c4e9a 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -13,11 +13,15 @@ on: concurrency: # automatically cancel the previously triggered workflows when there's a newer version - group: build-min-${{ github.event.pull_request.number || github.ref }} + group: cicd-tests-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +# These jobs run the CICD tests, type checking, and testing packaging and documentation generation. These use the +# minimum supported versions of Python and PyTorch in many places hard-coded as literals, so when support is dropped +# for a version it is important to go through all jobs and check the versions they use are correct. + jobs: - static-checks: + static-checks: # Perform static type and other checks using runtests.sh runs-on: ubuntu-latest strategy: matrix: @@ -43,14 +47,14 @@ jobs: find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; python -m pip install --upgrade pip wheel python -m pip install -r requirements-dev.txt - - name: Lint and type check + - name: Lint and type check with "./runtests.sh --build --${{ matrix.opt }}" run: | # clean up temporary files $(pwd)/runtests.sh --build --clean - # Github actions have 2 cores, so parallelize pytype - $(pwd)/runtests.sh --build --${{ matrix.opt }} -j 2 + # Github actions have multiple cores, so parallelize pytype + $(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all) - min-dep: # min dependencies installed tests for different OS + min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -124,7 +128,7 @@ jobs: NGC_ORG: ${{ secrets.NGC_ORG }} NGC_TEAM: ${{ secrets.NGC_TEAM }} - full-dep: # full dependencies installed tests for different OS + full-dep: # Test with full dependencies installed for different OS runners runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -192,7 +196,7 @@ jobs: QUICKTEST: True PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - packaging: + packaging: # Test package generation runs-on: ubuntu-latest env: QUICKTEST: True @@ -279,7 +283,7 @@ jobs: env: PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 - build-docs: + build-docs: # Test building documentation runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -308,7 +312,7 @@ jobs: cd docs/ make clean make html 2>&1 | tee tmp_log - if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "found errors"; grep "ERROR:" tmp_log; exit 1; fi + if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "Found errors:"; grep "ERROR:" tmp_log; exit 1; fi sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133 - if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "found warnings"; grep "WARNING:" tmp_log; exit 1; fi - shell: bash + if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "Found warnings:"; grep "WARNING:" tmp_log; exit 1; fi + shell: bash \ No newline at end of file From d7e1451086822cf4f39a0d6357621451d4926ca4 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Mon, 8 Sep 2025 13:55:12 +0100 Subject: [PATCH 09/18] Fix Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 25870c4e9a..2c47923beb 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -16,7 +16,7 @@ concurrency: group: cicd-tests-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true -# These jobs run the CICD tests, type checking, and testing packaging and documentation generation. These use the +# These jobs run the CICD tests, type checking, and testing packaging and documentation generation. These use the # minimum supported versions of Python and PyTorch in many places hard-coded as literals, so when support is dropped # for a version it is important to go through all jobs and check the versions they use are correct. @@ -53,7 +53,7 @@ jobs: $(pwd)/runtests.sh --build --clean # Github actions have multiple cores, so parallelize pytype $(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all) - + min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations runs-on: ${{ matrix.os }} strategy: @@ -315,4 +315,4 @@ jobs: if [[ $(grep -c "ERROR:" tmp_log) != 0 ]]; then echo "Found errors:"; grep "ERROR:" tmp_log; exit 1; fi sed '/WARNING.*pip/d' tmp_log > tmp_log1; mv tmp_log1 tmp_log # monai#7133 if [[ $(grep -c "WARNING:" tmp_log) != 0 ]]; then echo "Found warnings:"; grep "WARNING:" tmp_log; exit 1; fi - shell: bash \ No newline at end of file + shell: bash From 7fc61070bef6540afbd8de7a3034b87de3a1057d Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 9 Sep 2025 00:21:57 +0100 Subject: [PATCH 10/18] Update with GPU runner Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 2c47923beb..1af6a783bd 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macOS-latest, ubuntu-latest] + os: [windows-latest, macOS-latest, ubuntu-latest, linux-gpu-runner] python-version: ['3.9'] pytorch-version: ['2.5.1'] include: @@ -110,6 +110,7 @@ jobs: key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - name: Install the dependencies with PyTorch ${{ matrix.pytorch-version }} run: | + /usr/bin/env nvidia-smi &> /dev/null || echo "No nvidia-smi found" # min. requirements python -m pip install torch==${{ matrix.pytorch-version }} python -m pip install -r requirements-min.txt From 3a2381c646bc526cddab79c52219fb69d525dc1a Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 9 Sep 2025 00:32:46 +0100 Subject: [PATCH 11/18] Whoops Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 1af6a783bd..1fbc2e6376 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -110,7 +110,7 @@ jobs: key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - name: Install the dependencies with PyTorch ${{ matrix.pytorch-version }} run: | - /usr/bin/env nvidia-smi &> /dev/null || echo "No nvidia-smi found" + /usr/bin/env nvidia-smi 2> /dev/null || echo "No nvidia-smi found" # min. requirements python -m pip install torch==${{ matrix.pytorch-version }} python -m pip install -r requirements-min.txt From 95b731071258c9e57d99fa3aaa279eb8dbcc6dbd Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 9 Sep 2025 00:42:02 +0100 Subject: [PATCH 12/18] Adding GPU check Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 1fbc2e6376..139a755261 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -66,13 +66,7 @@ jobs: # Test Python versions under Ubuntu with lowest PyTorch version supported - os: ubuntu-latest pytorch-version: '2.5.1' - python-version: '3.10' - - os: ubuntu-latest - pytorch-version: '2.5.1' - python-version: '3.11' - - os: ubuntu-latest - pytorch-version: '2.5.1' - python-version: '3.12' + python-version: ['3.10', '3.11', '3.12'] # Test PyTorch versions under Ubuntu with lowest Python version supported - os: ubuntu-latest @@ -108,16 +102,21 @@ jobs: with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }} - - name: Install the dependencies with PyTorch ${{ matrix.pytorch-version }} + - name: Install the minimum dependencies run: | - /usr/bin/env nvidia-smi 2> /dev/null || echo "No nvidia-smi found" # min. requirements python -m pip install torch==${{ matrix.pytorch-version }} python -m pip install -r requirements-min.txt python -m pip list BUILD_MONAI=0 python setup.py develop # no compile of extensions shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) + - if: matrix.os == 'linux-gpu-runner' + name: Print GPU Info + run: | + nvidia-smi + python -c 'import torch; print(torch.rand(2,2).to("cuda:0"))' + shell: bash + - name: Run quick tests run: | python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' python -c "import monai; monai.config.print_config()" @@ -174,7 +173,7 @@ jobs: run: | python -m pip install --pre -U itk find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; - - name: Install the dependencies + - name: Install the complete dependencies run: | python -m pip install --user --upgrade pip wheel python -m pip install torch==2.5.1 torchvision==0.20.1 @@ -188,7 +187,7 @@ jobs: python setup.py develop --uninstall BUILD_MONAI=1 python setup.py develop # compile the cpp extensions shell: bash - - name: Run quick tests (CPU ${{ runner.os }}) + - name: Run quick tests run: | python -c 'import torch; print(torch.__version__); print(torch.rand(5,3))' python -c "import monai; monai.config.print_config()" From d8128f4b4208615bd981441acf8a06bfde8a8f58 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Tue, 9 Sep 2025 00:43:20 +0100 Subject: [PATCH 13/18] Fix Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 139a755261..b48b8468f4 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -66,7 +66,13 @@ jobs: # Test Python versions under Ubuntu with lowest PyTorch version supported - os: ubuntu-latest pytorch-version: '2.5.1' - python-version: ['3.10', '3.11', '3.12'] + python-version: '3.10' + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.11' + - os: ubuntu-latest + pytorch-version: '2.5.1' + python-version: '3.12' # Test PyTorch versions under Ubuntu with lowest Python version supported - os: ubuntu-latest From 55c351cc5021d131b43b022fdd7c6bc65692c95b Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:35:27 +0000 Subject: [PATCH 14/18] Update with merge Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index a8e1829520..3de13a2da2 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -87,15 +87,16 @@ jobs: timeout-minutes: 40 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Prepare pip wheel run: | which python python -m pip install --upgrade pip wheel + python -m pip install --user more-itertools>=8.0 - name: cache weekly timestamp id: pip-cache run: | @@ -158,6 +159,7 @@ jobs: run: | which python python -m pip install --upgrade pip wheel + python -m pip install --user more-itertools>=8.0 - name: cache weekly timestamp id: pip-cache run: | From 4d58d5b759e993f4b67d71555e06197556dba931 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:45:35 +0000 Subject: [PATCH 15/18] Removing Python 3.9 tests, adding Python 3.13 and Pytorch 2.9 tests Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/cicd_tests.yml | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/cicd_tests.yml b/.github/workflows/cicd_tests.yml index 3de13a2da2..8eb70e2533 100644 --- a/.github/workflows/cicd_tests.yml +++ b/.github/workflows/cicd_tests.yml @@ -28,10 +28,10 @@ jobs: opt: ["codeformat", "pytype", "mypy"] steps: - uses: actions/checkout@v5 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: cache weekly timestamp id: pip-cache run: | @@ -59,31 +59,31 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macOS-latest, ubuntu-latest, linux-gpu-runner] - python-version: ['3.9'] - pytorch-version: ['2.5.1'] + os: [windows-latest, macOS-latest, ubuntu-latest] + python-version: ['3.10'] + pytorch-version: ['2.6.0'] include: # Test Python versions under Ubuntu with lowest PyTorch version supported - os: ubuntu-latest - pytorch-version: '2.5.1' - python-version: '3.10' - - os: ubuntu-latest - pytorch-version: '2.5.1' + pytorch-version: '2.6.0' python-version: '3.11' - os: ubuntu-latest - pytorch-version: '2.5.1' + pytorch-version: '2.6.0' python-version: '3.12' - - # Test PyTorch versions under Ubuntu with lowest Python version supported - os: ubuntu-latest - python-version: '3.9' pytorch-version: '2.6.0' + python-version: '3.13' + + # Test PyTorch versions under Ubuntu with lowest Python version supported - os: ubuntu-latest - python-version: '3.9' + python-version: '3.10' pytorch-version: '2.7.1' - os: ubuntu-latest - python-version: '3.9' + python-version: '3.10' pytorch-version: '2.8.0' + - os: ubuntu-latest + python-version: '3.10' + pytorch-version: '2.9.0' timeout-minutes: 40 steps: @@ -151,10 +151,10 @@ jobs: maximum-size: 16GB disk-root: "D:" - uses: actions/checkout@v5 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: Prepare pip wheel run: | which python @@ -213,10 +213,10 @@ jobs: - uses: actions/checkout@v5 with: fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: cache weekly timestamp id: pip-cache run: | @@ -295,10 +295,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: cache weekly timestamp id: pip-cache run: | From 29a2ff67010b0108b8386320a7928b77a757a0e2 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:03:31 +0000 Subject: [PATCH 16/18] Further changes for 3.9 to 3.10 Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- .github/workflows/conda.yml | 2 +- .github/workflows/cron-ngc-bundle.yml | 4 +- .github/workflows/docker.yml | 4 +- .github/workflows/pythonapp-gpu.yml | 2 +- .github/workflows/release.yml | 12 +++--- .github/workflows/setupapp.yml | 6 +-- .github/workflows/weekly-preview.yml | 8 ++-- docs/.readthedocs.yaml | 2 +- docs/requirements.txt | 2 +- docs/source/installation.md | 4 +- json_test.py | 55 +++++++++++++++++++++++++++ monai/apps/auto3dseg/auto_runner.py | 2 +- monai/auto3dseg/utils.py | 3 +- requirements-dev.txt | 4 +- setup.cfg | 15 ++++---- 15 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 json_test.py diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index fd680e14c8..bedbcec548 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.9", "3.10"] + python-version: ["3.10", "3.11"] runs-on: ${{ matrix.os }} timeout-minutes: 46 # equal to max + 3*std over the last 600 successful runs env: diff --git a/.github/workflows/cron-ngc-bundle.yml b/.github/workflows/cron-ngc-bundle.yml index c9bebc7bff..141a0b9acc 100644 --- a/.github/workflows/cron-ngc-bundle.yml +++ b/.github/workflows/cron-ngc-bundle.yml @@ -18,10 +18,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: cache weekly timestamp id: pip-cache run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4741dca858..5dd6fbe9f6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -26,10 +26,10 @@ jobs: with: ref: dev fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - shell: bash run: | git describe diff --git a/.github/workflows/pythonapp-gpu.yml b/.github/workflows/pythonapp-gpu.yml index 347b49bba3..8639127b4d 100644 --- a/.github/workflows/pythonapp-gpu.yml +++ b/.github/workflows/pythonapp-gpu.yml @@ -53,7 +53,7 @@ jobs: if [ ${{ matrix.environment }} = "PT230+CUDA124" ] then - PYVER=3.9 PYSFX=3 DISTUTILS=python3-distutils && \ + PYVER=3.10 PYSFX=3 DISTUTILS=python3-distutils && \ apt-get update && apt-get install -y --no-install-recommends \ curl \ pkg-config \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a8e8ffdf6..cfc2d4b7a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v5 with: @@ -64,14 +64,14 @@ jobs: env: QUICKTEST: True - - if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/') + - if: matrix.python-version == '3.10' && startsWith(github.ref, 'refs/tags/') name: Upload artifacts uses: actions/upload-artifact@v5 with: name: dist path: dist/ - - if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/') + - if: matrix.python-version == '3.10' && startsWith(github.ref, 'refs/tags/') name: Check artifacts run: | ls -al dist/ @@ -79,7 +79,7 @@ jobs: ls -al dist/ # remove publishing to Test PyPI as it is moved to blossom - # - if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/') + # - if: matrix.python-version == '3.10' && startsWith(github.ref, 'refs/tags/') # name: Publish to Test PyPI # uses: pypa/gh-action-pypi-publish@release/v1 # with: @@ -97,10 +97,10 @@ jobs: # full history so that we can git describe with: fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - shell: bash run: | find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; diff --git a/.github/workflows/setupapp.yml b/.github/workflows/setupapp.yml index acd72eaf6f..912d254334 100644 --- a/.github/workflows/setupapp.yml +++ b/.github/workflows/setupapp.yml @@ -81,7 +81,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9', '3.10', '3.11'] + python-version: ['3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v5 with: @@ -127,10 +127,10 @@ jobs: install: # pip install from github url, the default branch is dev runs-on: ubuntu-latest steps: - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: cache weekly timestamp id: pip-cache run: | diff --git a/.github/workflows/weekly-preview.yml b/.github/workflows/weekly-preview.yml index 93d6f67f09..67a712fe2d 100644 --- a/.github/workflows/weekly-preview.yml +++ b/.github/workflows/weekly-preview.yml @@ -12,10 +12,10 @@ jobs: opt: ["codeformat", "pytype", "mypy"] steps: - uses: actions/checkout@v5 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: cache weekly timestamp id: pip-cache run: | @@ -46,10 +46,10 @@ jobs: with: ref: dev fetch-depth: 0 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v6 with: - python-version: '3.9' + python-version: '3.10' - name: Install setuptools run: | python -m pip install --user --upgrade setuptools wheel packaging diff --git a/docs/.readthedocs.yaml b/docs/.readthedocs.yaml index d2e2ee74a5..0212e806e8 100644 --- a/docs/.readthedocs.yaml +++ b/docs/.readthedocs.yaml @@ -6,7 +6,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.9" + python: "3.10" sphinx: configuration: docs/source/conf.py python: diff --git a/docs/requirements.txt b/docs/requirements.txt index f44f41a6b2..7f4db0f704 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,7 +6,7 @@ itk>=5.2 nibabel parameterized scikit-image>=0.19.0 -scipy>=1.12.0; python_version >= '3.9' +scipy>=1.12.0 tensorboard commonmark==0.9.1 recommonmark==0.6.0 diff --git a/docs/source/installation.md b/docs/source/installation.md index b8befc10b4..bf7fa56138 100644 --- a/docs/source/installation.md +++ b/docs/source/installation.md @@ -19,7 +19,7 @@ --- -MONAI's core functionality is written in Python 3 (>= 3.9) and only requires [Numpy](https://numpy.org/) and [Pytorch](https://pytorch.org/). +MONAI's core functionality is written in Python 3 (>= 3.10) and only requires [Numpy](https://numpy.org/) and [Pytorch](https://pytorch.org/). The package is currently distributed via Github as the primary source code repository, and the Python package index (PyPI). The pre-built Docker images are made available on DockerHub. @@ -245,7 +245,7 @@ this will install PyTorch as well as `pytorch-cuda`, please follow https://pytor ```bash git clone https://github.com/Project-MONAI/MONAI.git cd MONAI/ -conda create -n python= # eg 3.9 +conda create -n python= # eg 3.10 conda env update -n -f environment-dev.yml ``` diff --git a/json_test.py b/json_test.py new file mode 100644 index 0000000000..7111a67223 --- /dev/null +++ b/json_test.py @@ -0,0 +1,55 @@ +from functools import partial +import numpy as np +import torch +import json + + +JSON_NUMPY_TYPE = "numpy" +JSON_TORCH_TYPE = "torch" + + +class SafeEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, np.ndarray): + return {"__type__": JSON_NUMPY_TYPE, "dtype": str(obj.dtype), "data": obj.tolist()} + + if isinstance(obj, torch.Tensor): + return { + "__type__": JSON_TORCH_TYPE, + "dtype": str(obj.dtype).replace("torch.", ""), + "data": obj.detach().cpu().numpy().tolist(), + } + + return super().default(obj) + + +def json_decode_hook(item): + datatype = item.get("__type__", "") + if datatype == JSON_NUMPY_TYPE: + return np.array(item["data"], dtype=np.dtype(item["dtype"])) + elif datatype == JSON_TORCH_TYPE: + return torch.tensor(item["data"], dtype=getattr(torch, item["dtype"])) + else: + return item + + +json_dumps = partial(json.dumps, cls=SafeEncoder) +json_loads = partial(json.loads, object_hook=json_decode_hook) + +item = { + "np": np.random.rand(5, 5), + "pt": torch.rand(4, 4), + "int": 123, + "list": [1, 2, 3], + "tuple": (1, 2, 3), + "dict": {"one": 1, "two": 2}, +} + +print(item) +print() + +dump_item = json_dumps(item) + +loaded_item = json_loads(dump_item) + +print(loaded_item) diff --git a/monai/apps/auto3dseg/auto_runner.py b/monai/apps/auto3dseg/auto_runner.py index 28ba2a88f9..9acab5d441 100644 --- a/monai/apps/auto3dseg/auto_runner.py +++ b/monai/apps/auto3dseg/auto_runner.py @@ -560,7 +560,7 @@ def set_device_info( cmd_prefix: command line prefix for subprocess running in BundleAlgo and EnsembleRunner. Default using env "CMD_PREFIX" or None, examples are: - - single GPU/CPU or multinode bcprun: "python " or "/opt/conda/bin/python3.9 ", + - single GPU/CPU or multinode bcprun: "python " or "/opt/conda/bin/python3.10", - single node multi-GPU running "torchrun --nnodes=1 --nproc_per_node=2 " If user define this prefix, please make sure --nproc_per_node matches cuda_visible_device or diff --git a/monai/auto3dseg/utils.py b/monai/auto3dseg/utils.py index 211f23c415..8b5dab75b5 100644 --- a/monai/auto3dseg/utils.py +++ b/monai/auto3dseg/utils.py @@ -407,7 +407,8 @@ def _prepare_cmd_default(cmd: str, cmd_prefix: str | None = None, **kwargs: Any) Args: cmd: the command or script to run in the distributed job. - cmd_prefix: the command prefix to run the script, e.g., "python", "python -m", "python3", "/opt/conda/bin/python3.9 ". + cmd_prefix: the command prefix to run the script, + e.g., "python", "python -m", "python3", "/opt/conda/bin/python3.10". kwargs: the keyword arguments to be passed to the script. Returns: diff --git a/requirements-dev.txt b/requirements-dev.txt index ff234c856e..e1422ea8ce 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ -r requirements-min.txt pytorch-ignite==0.4.11 gdown>=4.7.3 -scipy>=1.12.0; python_version >= '3.9' +scipy>=1.12.0 itk>=5.2 nibabel pillow!=8.3.0 # https://github.com/python-pillow/Pillow/issues/5571 @@ -27,7 +27,7 @@ ninja torchio torchvision psutil -cucim-cu12; platform_system == "Linux" and python_version >= "3.9" and python_version <= "3.10" +cucim-cu12; platform_system == "Linux" and python_version <= "3.10" openslide-python openslide-bin imagecodecs; platform_system == "Linux" or platform_system == "Darwin" diff --git a/setup.cfg b/setup.cfg index b3949213c2..5011b6382e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,9 +21,10 @@ classifiers = Intended Audience :: Healthcare Industry Programming Language :: C++ Programming Language :: Python :: 3 - Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 Topic :: Scientific/Engineering Topic :: Scientific/Engineering :: Artificial Intelligence Topic :: Scientific/Engineering :: Medical Science Apps. @@ -33,7 +34,7 @@ classifiers = Typing :: Typed [options] -python_requires = >= 3.9 +python_requires = >= 3.10 # for compiling and develop setup only # no need to specify the versions so that we could # compile for multiple targeted versions. @@ -42,7 +43,7 @@ setup_requires = ninja packaging install_requires = - torch>=2.4.1 + torch>=2.6.0 numpy>=1.24,<3.0 [options.extras_require] @@ -50,7 +51,7 @@ all = nibabel ninja scikit-image>=0.14.2 - scipy>=1.12.0; python_version >= '3.9' + scipy>=1.12.0 pillow tensorboard gdown>=4.7.3 @@ -61,7 +62,7 @@ all = tqdm>=4.47.0 lmdb psutil - cucim-cu12; platform_system == "Linux" and python_version >= '3.9' and python_version <= '3.10' + cucim-cu12; platform_system == "Linux" and python_version <= '3.10' openslide-python openslide-bin tifffile; platform_system == "Linux" or platform_system == "Darwin" @@ -95,7 +96,7 @@ ninja = skimage = scikit-image>=0.14.2 scipy = - scipy>=1.12.0; python_version >= '3.9' + scipy>=1.12.0 pillow = pillow!=8.3.0 tensorboard = @@ -117,7 +118,7 @@ lmdb = psutil = psutil cucim = - cucim-cu12; platform_system == "Linux" and python_version >= '3.9' and python_version <= '3.10' + cucim-cu12; platform_system == "Linux" and python_version <= '3.10' openslide = openslide-python openslide-bin From d309fe9ce2ddbb58e8c04975632cffb4980049ac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:04:23 +0000 Subject: [PATCH 17/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- monai/auto3dseg/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/auto3dseg/utils.py b/monai/auto3dseg/utils.py index 8b5dab75b5..ff1be57629 100644 --- a/monai/auto3dseg/utils.py +++ b/monai/auto3dseg/utils.py @@ -407,7 +407,7 @@ def _prepare_cmd_default(cmd: str, cmd_prefix: str | None = None, **kwargs: Any) Args: cmd: the command or script to run in the distributed job. - cmd_prefix: the command prefix to run the script, + cmd_prefix: the command prefix to run the script, e.g., "python", "python -m", "python3", "/opt/conda/bin/python3.10". kwargs: the keyword arguments to be passed to the script. From aa3080be6df90ba2dd9972d997999702fd5f7063 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:18:35 +0000 Subject: [PATCH 18/18] Whoops Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> --- json_test.py | 55 ---------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 json_test.py diff --git a/json_test.py b/json_test.py deleted file mode 100644 index 7111a67223..0000000000 --- a/json_test.py +++ /dev/null @@ -1,55 +0,0 @@ -from functools import partial -import numpy as np -import torch -import json - - -JSON_NUMPY_TYPE = "numpy" -JSON_TORCH_TYPE = "torch" - - -class SafeEncoder(json.JSONEncoder): - def default(self, obj): - if isinstance(obj, np.ndarray): - return {"__type__": JSON_NUMPY_TYPE, "dtype": str(obj.dtype), "data": obj.tolist()} - - if isinstance(obj, torch.Tensor): - return { - "__type__": JSON_TORCH_TYPE, - "dtype": str(obj.dtype).replace("torch.", ""), - "data": obj.detach().cpu().numpy().tolist(), - } - - return super().default(obj) - - -def json_decode_hook(item): - datatype = item.get("__type__", "") - if datatype == JSON_NUMPY_TYPE: - return np.array(item["data"], dtype=np.dtype(item["dtype"])) - elif datatype == JSON_TORCH_TYPE: - return torch.tensor(item["data"], dtype=getattr(torch, item["dtype"])) - else: - return item - - -json_dumps = partial(json.dumps, cls=SafeEncoder) -json_loads = partial(json.loads, object_hook=json_decode_hook) - -item = { - "np": np.random.rand(5, 5), - "pt": torch.rand(4, 4), - "int": 123, - "list": [1, 2, 3], - "tuple": (1, 2, 3), - "dict": {"one": 1, "two": 2}, -} - -print(item) -print() - -dump_item = json_dumps(item) - -loaded_item = json_loads(dump_item) - -print(loaded_item)