Bump astral-sh/setup-uv from 6 to 7 in the github-actions group #6156
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
| name: Run unit tests | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - "*.*.*" | |
| paths: | |
| - "examples/**.py" | |
| - "ignite/**" | |
| - "pyproject.toml" | |
| - "tests/ignite/**" | |
| - "tests/run_code_style.sh" | |
| - "tests/run_cpu_tests.sh" | |
| - "requirements-dev.txt" | |
| - ".github/workflows/unit-tests.yml" | |
| pull_request: | |
| paths: | |
| - "examples/**.py" | |
| - "ignite/**" | |
| - "pyproject.toml" | |
| - "tests/ignite/**" | |
| - "tests/run_code_style.sh" | |
| - "tests/run_cpu_tests.sh" | |
| - "requirements-dev.txt" | |
| - ".github/workflows/unit-tests.yml" | |
| workflow_dispatch: | |
| merge_group: | |
| concurrency: | |
| # <workflow_name>-<branch_name>-<true || commit_sha (if branch is protected)> | |
| group: unit-tests-${{ github.ref_name }}-${{ !(github.ref_protected) || github.sha }} | |
| cancel-in-progress: true | |
| jobs: | |
| cpu-tests: | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 85 | |
| defaults: | |
| run: | |
| shell: bash | |
| strategy: | |
| max-parallel: 10 | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| pytorch-channel: [pytorch, pytorch-nightly] | |
| include: | |
| # includes a single build on windows | |
| - os: windows-latest | |
| pytorch-channel: pytorch | |
| python-version: 3.11 | |
| skip-distrib-tests: 1 | |
| # includes a single build on macosx | |
| - os: macos-latest | |
| pytorch-channel: pytorch | |
| python-version: 3.11 | |
| skip-distrib-tests: 1 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Get year & week number | |
| id: get-date | |
| run: | | |
| echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "latest" | |
| python-version: ${{ matrix.python-version }} | |
| activate-environment: true | |
| enable-cache: true | |
| cache-suffix: "${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}" | |
| cache-dependency-glob: | | |
| **/requirements-dev.txt | |
| **/pyproject.toml | |
| - name: Install PyTorch | |
| if: ${{ matrix.pytorch-channel == 'pytorch' }} | |
| run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
| - name: Install PyTorch (nightly) | |
| if: ${{ matrix.pytorch-channel == 'pytorch-nightly' }} | |
| run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre | |
| - name: Install dependencies | |
| run: | | |
| uv pip install -r requirements-dev.txt | |
| uv pip install . | |
| uv pip list | |
| # Download MNIST: https://github.com/pytorch/ignite/issues/1737 | |
| # to "/tmp" for unit tests | |
| - name: Download MNIST | |
| uses: pytorch-ignite/download-mnist-github-action@master | |
| with: | |
| target_dir: /tmp | |
| # Copy MNIST to "." for the examples | |
| - name: Copy MNIST | |
| run: | | |
| cp -R /tmp/MNIST . | |
| - name: Run Tests | |
| uses: nick-fields/[email protected] | |
| with: | |
| max_attempts: 5 | |
| timeout_minutes: 15 | |
| shell: bash | |
| command: SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh | |
| new_command_on_retry: USE_LAST_FAILED=1 SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./coverage.xml | |
| flags: cpu | |
| fail_ci_if_error: false | |
| - name: Run MNIST Examples | |
| run: | | |
| # MNIST | |
| # 1) mnist.py | |
| python examples/mnist/mnist.py --epochs=1 | |
| - name: Run MNIST with loggers Examples | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| # 2) mnist_with_visdom.py | |
| python -c "from visdom.server.build import download_scripts; download_scripts()" # download scripts : https://github.com/facebookresearch/visdom/blob/master/py/server.py#L929 | |
| python -m visdom.server & | |
| sleep 10 | |
| python examples/mnist/mnist_with_visdom.py --epochs=1 | |
| kill %1 | |
| # 3.1) mnist_with_tensorboard.py with tbX | |
| python examples/mnist/mnist_with_tensorboard.py --epochs=1 | |
| # 3.2) mnist_with_tensorboard.py with native torch tb | |
| uv pip uninstall tensorboardX | |
| python examples/mnist/mnist_with_tensorboard.py --epochs=1 | |
| - name: Run MNIST Example With Crash | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| continue-on-error: true | |
| run: | | |
| # 4) mnist_save_resume_engine.py | |
| python examples/mnist/mnist_save_resume_engine.py --epochs=2 --crash_iteration 1100 | |
| - name: Resume MNIST from previous crash | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| python examples/mnist/mnist_save_resume_engine.py --epochs=2 --resume_from=/tmp/mnist_save_resume/checkpoint_1.pt | |
| - name: Run GAN example | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| # DCGAN | |
| python examples/gan/dcgan.py --dataset fake --dataroot /tmp/fakedata --output-dir /tmp/outputs-dcgan --batch-size 2 --epochs 2 --workers 0 | |
| - name: Run RL Examples | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| # RL | |
| # 1) Actor-Critic | |
| python examples/reinforcement_learning/actor_critic.py --max-episodes=2 | |
| # 2) Reinforce | |
| python examples/reinforcement_learning/reinforce.py --max-episodes=2 | |
| - name: Run Neural Style Example | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| #fast-neural-style | |
| #train | |
| mkdir -p ~/.cache/torch/checkpoints/ && wget "https://download.pytorch.org/models/vgg16-397923af.pth" -O ~/.cache/torch/checkpoints/vgg16-397923af.pth | |
| python examples/fast_neural_style/neural_style.py train --epochs 1 --cuda 0 --dataset test --dataroot . --image_size 32 --style_image examples/fast_neural_style/images/style_images/mosaic.jpg --style_size 32 | |
| - name: Run SR Example | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| set -e | |
| echo "Testing Caltech101 dataset availability..." | |
| if python -c "import torchvision; torchvision.datasets.Caltech101(root='./data', download=True)"; then | |
| python examples/super_resolution/main.py --upscale_factor 3 --crop_size 180 --batch_size 4 --test_batch_size 100 --n_epochs 1 --lr 0.001 --threads 2 --debug | |
| else | |
| echo "Caltech101 dataset failed to download. Skipping SR example test." | |
| fi |