From 02d42b0b89363f7ef30d4c0319f7fe9beae2be75 Mon Sep 17 00:00:00 2001 From: Demetrios Agourakis Date: Mon, 23 Nov 2026 15:59:08 -0300 Subject: [PATCH 1/2] CI: Run full dependency tests on Python 3.12 and PyTorch 2.15 Add one Ubuntu entry after the CI version update in #9266. Keep the three required full-dep check names and verify the resolved PyTorch and torchvision versions before running the full test suite. Assisted-by: OpenAI Codex Signed-off-by: Demetrios Agourakis --- .github/workflows/ci_tests.yml | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 35c15ac34d..e4b51f6543 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -209,11 +209,22 @@ jobs: NGC_TEAM: ${{ secrets.NGC_TEAM }} full-dep: # Test with full dependencies installed for different OS runners + # Keep the existing check names for branch protection. + name: >- + full-dep (${{ matrix.os }}${{ matrix.python-version && + format(', {0}, {1}', matrix.python-version, matrix.pytorch-version) || '' }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest, macOS-latest] # macOS-latest is very slow (#8864), testing install only + include: + - os: windows-latest + - os: ubuntu-latest + - os: macOS-latest # macOS-latest is very slow (#8864), testing install only + - os: ubuntu-latest + python-version: '3.12' + pytorch-version: '2.15.0' + torchvision-version: '0.29.2' timeout-minutes: 120 needs: test_skip env: @@ -236,11 +247,11 @@ jobs: disk-root: "D:" - uses: actions/checkout@v7 if: needs.test_skip.outputs.skip == 0 - - name: Set up Python ${{ env.PYTHON_VER1 }} + - name: Set up Python ${{ matrix.python-version || env.PYTHON_VER1 }} if: needs.test_skip.outputs.skip == 0 uses: actions/setup-python@v6 with: - python-version: ${{ env.PYTHON_VER1 }} + python-version: ${{ matrix.python-version || env.PYTHON_VER1 }} cache: 'pip' - name: Prepare pip wheel if: needs.test_skip.outputs.skip == 0 @@ -250,9 +261,11 @@ jobs: - if: needs.test_skip.outputs.skip == 0 name: Install PyTorch run: | - # install the lowest version of PyTorch supported - python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1} + python -m pip install "torch==${PYTORCH_VERSION}" "torchvision==${TORCHVISION_VERSION}" shell: bash + env: + PYTORCH_VERSION: ${{ matrix.pytorch-version || env.PYTORCH_VER1 }} + TORCHVISION_VERSION: ${{ matrix.torchvision-version || env.TORCHVISION_VER1 }} - if: runner.os == 'Linux' && needs.test_skip.outputs.skip == 0 name: Install itk pre-release (Linux only) run: | @@ -275,6 +288,25 @@ jobs: nvidia-smi || true python monai/config/check_env.py --env --monai shell: bash + - name: Verify resolved PyTorch versions + if: matrix.pytorch-version && needs.test_skip.outputs.skip == 0 + shell: bash + env: + PYTORCH_VERSION: ${{ matrix.pytorch-version }} + TORCHVISION_VERSION: ${{ matrix.torchvision-version }} + run: | + python - <<'PY' + import os + from importlib.metadata import version + + for package, expected in ( + ("torch", os.environ["PYTORCH_VERSION"]), + ("torchvision", os.environ["TORCHVISION_VERSION"]), + ): + installed = version(package) + if installed.split("+", 1)[0] != expected: + raise SystemExit(f"Expected {package}=={expected}, found {installed}.") + PY - if: runner.os != 'macOS' && needs.test_skip.outputs.skip == 0 name: Run full tests run: | From 486e75bdac20c5015f383393b65028297bb5b8e5 Mon Sep 17 00:00:00 2001 From: Demetrios Agourakis Date: Wed, 25 Nov 2026 10:50:55 -0300 Subject: [PATCH 2/2] CI: Simplify full-dependency version handling Expose matrix package versions at job scope, keep the existing default versions, and verify resolved versions with Bash after the complete dependency installation. Assisted-by: OpenAI Codex Signed-off-by: Demetrios Agourakis --- .github/workflows/ci_tests.yml | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index e4b51f6543..10e7183c70 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -229,6 +229,8 @@ jobs: needs: test_skip env: QUICKTEST: True + PYTORCH_VERSION: ${{ matrix.pytorch-version }} + TORCHVISION_VERSION: ${{ matrix.torchvision-version }} steps: - name: Clean unused tools if: runner.os == 'Linux' && needs.test_skip.outputs.skip == 0 @@ -261,11 +263,8 @@ jobs: - if: needs.test_skip.outputs.skip == 0 name: Install PyTorch run: | - python -m pip install "torch==${PYTORCH_VERSION}" "torchvision==${TORCHVISION_VERSION}" + python -m pip install "torch==${PYTORCH_VERSION:-$PYTORCH_VER1}" "torchvision==${TORCHVISION_VERSION:-$TORCHVISION_VER1}" shell: bash - env: - PYTORCH_VERSION: ${{ matrix.pytorch-version || env.PYTORCH_VER1 }} - TORCHVISION_VERSION: ${{ matrix.torchvision-version || env.TORCHVISION_VER1 }} - if: runner.os == 'Linux' && needs.test_skip.outputs.skip == 0 name: Install itk pre-release (Linux only) run: | @@ -291,22 +290,19 @@ jobs: - name: Verify resolved PyTorch versions if: matrix.pytorch-version && needs.test_skip.outputs.skip == 0 shell: bash - env: - PYTORCH_VERSION: ${{ matrix.pytorch-version }} - TORCHVISION_VERSION: ${{ matrix.torchvision-version }} run: | - python - <<'PY' - import os - from importlib.metadata import version + INSTALLED_PACKAGES=$(python -m pip list --format=columns) + ACTUAL_PYTORCH_VER=$(awk '$1 == "torch" {print $2}' <<< "$INSTALLED_PACKAGES") + ACTUAL_TORCHVISION_VER=$(awk '$1 == "torchvision" {print $2}' <<< "$INSTALLED_PACKAGES") - for package, expected in ( - ("torch", os.environ["PYTORCH_VERSION"]), - ("torchvision", os.environ["TORCHVISION_VERSION"]), - ): - installed = version(package) - if installed.split("+", 1)[0] != expected: - raise SystemExit(f"Expected {package}=={expected}, found {installed}.") - PY + # CPU wheels can include a local version suffix such as +cpu. + if [[ "${ACTUAL_PYTORCH_VER%%+*}" != "$PYTORCH_VERSION" || + "${ACTUAL_TORCHVISION_VER%%+*}" != "$TORCHVISION_VERSION" ]]; then + echo "Mismatched PyTorch/Torchvision versions:" + echo " PyTorch version actual=$ACTUAL_PYTORCH_VER, expected=$PYTORCH_VERSION" + echo " Torchvision version actual=$ACTUAL_TORCHVISION_VER, expected=$TORCHVISION_VERSION" + exit 1 + fi - if: runner.os != 'macOS' && needs.test_skip.outputs.skip == 0 name: Run full tests run: |