-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refactoring min-dep tests #8561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ericspod
wants to merge
61
commits into
Project-MONAI:dev
Choose a base branch
from
ericspod:cicd_test_update
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
bc3dcee
Refactoring min-dep tests
ericspod 2b9a992
Update test
ericspod 44bc1ae
Update test
ericspod 0c8c868
Restoring include that worked
ericspod e3616e4
Renaming file
ericspod 53cb0a4
Combining tests
ericspod 28f06ff
Removing combined file
ericspod 4d88075
Script update
ericspod d7e1451
Fix
ericspod 7fc6107
Update with GPU runner
ericspod 3a2381c
Whoops
ericspod 95b7310
Adding GPU check
ericspod d8128f4
Fix
ericspod f17ec42
Merge branch 'dev' into cicd_test_update
ericspod 55c351c
Update with merge
ericspod 4d58d5b
Removing Python 3.9 tests, adding Python 3.13 and Pytorch 2.9 tests
ericspod 29a2ff6
Further changes for 3.9 to 3.10
ericspod d309fe9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] aa3080b
Whoops
ericspod f990178
Merge branch 'cicd_test_update' of github.com:ericspod/MONAI into cic…
ericspod fabc538
Adding ignore paths to stop tests triggering when documentation changed
ericspod 309c312
Merge remote-tracking branch 'origin/dev' into cicd_test_update
ericspod 8908725
Experimental image cleaning
ericspod 18f640d
Fix
ericspod 4ec2800
Always import npt
ericspod 27cb347
Disk size optimisation
ericspod 3c5a3da
Fix
ericspod 5fbc0cb
Merge branch 'dev' into cicd_test_update
ericspod 99e6a62
Merge branch 'dev' into cicd_test_update
ericspod c4155a4
Merge branch 'dev' into cicd_test_update
ericspod f26ba2a
Merge branch 'cicd_test_update' of github.com:ericspod/MONAI into cic…
ericspod ea2816a
Updates with version bumps
ericspod 3841908
Merge branch 'dev' into cicd_test_update
ericspod 63a92bf
Syntax fix
ericspod b669526
Syntax fix
ericspod 22fe6ca
Pre-commit fix
ericspod edcbffe
Redundant file
ericspod 30616b1
Syntax fix
ericspod 0b6ec1c
Matrix restrictions
ericspod 6782838
Updates for new black formatting
ericspod 87c6fee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9b38586
Format fixes and script fixes
ericspod 6309f30
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8e54c64
Adding pybind11 to test MacOS failure
ericspod ee558b8
Merge branch 'cicd_test_update' of github.com:ericspod/MONAI into cic…
ericspod 20570f3
mypy fixes
ericspod 5f5482b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 707580f
Merge branch 'dev' into cicd_test_update
ericspod 8ffacc8
Enable tests
ericspod ed28475
Test fixes
ericspod 7e3b15c
Test fixes
ericspod 7e1d8c4
Windows fix
ericspod d3843c7
Windows fix
ericspod b0e1e7d
Windows fix attempt, need to use newest PyTorch?
ericspod 7b20c9f
Moving build docs
ericspod ee721da
Merge branch 'cicd_test_update' of github.com:ericspod/MONAI into cic…
ericspod d5a9182
Merge branch 'dev' into cicd_test_update
ericspod 50172b0
Merge branch 'dev' into cicd_test_update
ericspod af3f288
Coderabbit feedback
ericspod d243970
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5675306
Tweak
ericspod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - dev | ||
| - main | ||
| - releasing/* | ||
| pull_request: | ||
| branches: | ||
| - dev | ||
| - main | ||
| - releasing/* | ||
|
|
||
| concurrency: | ||
| # automatically cancel the previously triggered workflows when there's a newer version | ||
| group: build-docs-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-docs: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # minimum supported version of Python | ||
| PYTHON_VER1: '3.10' | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python ${{ env.PYTHON_VER1 }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VER1 }} | ||
| cache: 'pip' | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip wheel | ||
| python -m pip install -r docs/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
| - 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,318 @@ | ||
| name: tests | ||
|
|
||
| on: | ||
| # quick tests for pull requests and the releasing branches | ||
| push: | ||
| branches: | ||
| - dev | ||
| - main | ||
| - releasing/* | ||
| paths-ignore: # skip if only docs are modified | ||
| - '**.md' | ||
| - '**.rst' | ||
| - 'docs/**' | ||
| pull_request: | ||
| branches: | ||
| - dev | ||
| - main | ||
| - releasing/* | ||
| paths-ignore: # skip if only docs are modified | ||
| - '**.md' | ||
| - '**.rst' | ||
| - 'docs/**' | ||
|
|
||
| concurrency: | ||
| # automatically cancel the previously triggered workflows when there's a newer version | ||
| group: cicd-tests-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| # Supported versions of Python and PyTorch are listed here for use below and as documentation | ||
| env: | ||
| # supported versions of Python | ||
| PYTHON_VER1: '3.10' | ||
| PYTHON_VER2: '3.11' | ||
| PYTHON_VER3: '3.12' | ||
| PYTHON_VER4: '3.13' | ||
| # PYTHON_VER5: '3.14' # TODO: not compatible with Torchscript, re-enable once Torchscript removed from MONAI | ||
| # supported versions of PyTorch | ||
| PYTORCH_VER1: '2.8.0' | ||
| PYTORCH_VER2: '2.9.1' | ||
| PYTORCH_VER3: '2.10.0' | ||
| PYTORCH_VER4: '2.11.0' | ||
| TORCHVISION_VER1: '0.23.0' # used for testing with lowest PyTorch version (PYTORCH_VER1), update as needed | ||
|
|
||
| # versions of PyTorch/Torchvision to use for full-dep Windows tests, needed to get around a gloo bug | ||
| WIN_FULLDEP_VER: '2.11.0' | ||
| WIN_FULLDEP_VISION_VER: '0.26.0' | ||
|
|
||
| PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354 | ||
|
|
||
| # These jobs run the CICD tests, type checking, and testing packaging. These use the minimum supported versions of | ||
| # Python and PyTorch in many places using the above environment variables but also hard coded where necessary. | ||
| # When support is dropped for a version it is important to update these as appropriate. | ||
|
|
||
| jobs: | ||
| static-checks: # Perform static type and other checks using runtests.sh | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| opt: ["codeformat", "pytype", "mypy"] | ||
| steps: | ||
| - name: Clean unused tools | ||
| run: | | ||
| find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; | ||
| sudo rm -rf /usr/share/dotnet | ||
| sudo rm -rf /usr/local/lib/android | ||
| sudo rm -rf /opt/ghc /usr/local/.ghcup | ||
| sudo docker system prune -f | ||
|
|
||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python ${{ env.PYTHON_VER1 }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VER1 }} | ||
| cache: 'pip' | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip wheel | ||
| python -m pip install --no-build-isolation -r requirements-dev.txt | ||
| - name: Lint and type check | ||
| run: | | ||
| # clean up temporary files | ||
| $(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: | ||
| fail-fast: false | ||
| matrix: | ||
| # Base test cases are to test on all three OSes with the lowest versions of Python and PyTorch, other cases are | ||
| # added below as special cases to cover other Python and PyTorch versions under Ubuntu | ||
| os: [windows-latest, macOS-latest, ubuntu-latest] | ||
| python-version: ['3.10'] | ||
| pytorch-version: ['2.8.0'] | ||
| include: | ||
| # Test Python versions under Ubuntu with lowest PyTorch version supported | ||
| - os: ubuntu-latest | ||
| pytorch-version: '2.8.0' | ||
| python-version: '3.11' | ||
| - os: ubuntu-latest | ||
| pytorch-version: '2.8.0' | ||
| python-version: '3.12' | ||
| - os: ubuntu-latest | ||
| pytorch-version: '2.8.0' | ||
| python-version: '3.13' | ||
| # - os: ubuntu-latest | ||
| # pytorch-version: '2.9.1' | ||
| # python-version: '3.14' | ||
|
|
||
| # Test PyTorch versions under Ubuntu with lowest Python version supported | ||
| - os: ubuntu-latest | ||
| python-version: '3.10' | ||
| pytorch-version: '2.9.1' | ||
| - os: ubuntu-latest | ||
| python-version: '3.10' | ||
| pytorch-version: '2.10.0' | ||
| - os: ubuntu-latest | ||
| python-version: '3.10' | ||
| pytorch-version: '2.11.0' | ||
|
|
||
| timeout-minutes: 40 | ||
| steps: | ||
| - if: runner.os == 'Linux' | ||
| name: Clean unused tools | ||
| run: | | ||
| find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; | ||
| sudo rm -rf /usr/share/dotnet | ||
| sudo rm -rf /usr/local/lib/android | ||
| sudo rm -rf /opt/ghc /usr/local/.ghcup | ||
| sudo docker system prune -f | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
| - name: Prepare pip wheel | ||
| run: | | ||
| which python | ||
| python -m pip install --upgrade pip wheel | ||
| python -m pip install --user more-itertools>=8.0 | ||
| - name: Install the minimum 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 | ||
| - 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 | ||
ericspod marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - 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()" | ||
| ./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: # Test with full dependencies installed for different OS runners | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [windows-latest, macOS-latest, ubuntu-latest] | ||
| timeout-minutes: 120 | ||
| env: | ||
| QUICKTEST: True | ||
| steps: | ||
| - if: runner.os == 'Linux' | ||
| name: Clean unused tools | ||
| run: | | ||
| find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; | ||
| sudo rm -rf /usr/share/dotnet | ||
| sudo rm -rf /usr/local/lib/android | ||
| sudo rm -rf /opt/ghc /usr/local/.ghcup | ||
| sudo docker system prune -f | ||
| - if: runner.os == 'windows' | ||
| name: Config pagefile (Windows only) | ||
| uses: al-cheb/configure-pagefile-action@v1.5 | ||
| with: | ||
| minimum-size: 8GB | ||
| maximum-size: 16GB | ||
| disk-root: "D:" | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python ${{ env.PYTHON_VER1 }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VER1 }} | ||
| cache: 'pip' | ||
| - name: Prepare pip wheel | ||
| run: | | ||
| which python | ||
| python -m pip install --upgrade pip wheel | ||
| - if: runner.os == 'windows' | ||
| name: Install torch cpu from pytorch.org (Windows only) | ||
| run: | | ||
| # BUG: PyTorch 2.8.0 appears to have a gloo bug under Windows with failing distributed tests | ||
| python -m pip install torch==${WIN_FULLDEP_VER} torchvision==${WIN_FULLDEP_VISION_VER}+cpu --index-url https://download.pytorch.org/whl/cpu | ||
| shell: bash | ||
| - if: runner.os != 'windows' | ||
| name: Install torch gpu | ||
| run: | | ||
| # install the lowest version of PyTorch supported | ||
| python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1} | ||
| shell: bash | ||
| - if: runner.os == 'Linux' | ||
| name: Install itk pre-release (Linux only) | ||
| run: | | ||
| python -m pip install --pre -U itk | ||
| shell: bash | ||
| - name: Install the complete dependencies | ||
| run: | | ||
| python -m pip install --user --upgrade pip wheel pybind11 # TODO: pybind11 added for macOS, may not be needed | ||
| #python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1} | ||
| cat "requirements-dev.txt" | ||
| python -m pip install --no-build-isolation -r requirements-dev.txt | ||
| python -m pip list | ||
| python -m pip install -e . # test no compile installation | ||
| shell: bash | ||
| - name: Run compiled (${{ runner.os }}) | ||
| run: | | ||
| python -m pip uninstall -y monai | ||
| BUILD_MONAI=1 python -m pip install -e . # compile the cpp extensions | ||
| 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()" | ||
| python -m unittest -v | ||
| shell: bash | ||
|
|
||
| packaging: # Test package generation | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| QUICKTEST: True | ||
| steps: | ||
| - name: Clean unused tools | ||
| run: | | ||
| find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; | ||
| sudo rm -rf /usr/share/dotnet | ||
| sudo rm -rf /usr/local/lib/android | ||
| sudo rm -rf /opt/ghc /usr/local/.ghcup | ||
| sudo docker system prune -f | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up Python ${{ env.PYTHON_VER1 }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ env.PYTHON_VER1 }} | ||
| cache: 'pip' | ||
| - name: Install dependencies | ||
| run: | | ||
| 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==${PYTORCH_VER1} torchvision --extra-index-url https://download.pytorch.org/whl/cpu | ||
| - 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 --extra-index-url https://download.pytorch.org/whl/cpu | ||
| 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: | | ||
| for name in *.tar.gz; do break; done | ||
| echo $name | ||
| python -m pip install ${name}[all] --extra-index-url https://download.pytorch.org/whl/cpu | ||
| 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 --no-build-isolation -r requirements-dev.txt --extra-index-url https://download.pytorch.org/whl/cpu | ||
| python -m unittest -v | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.