Skip to content
Open
47 changes: 15 additions & 32 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ concurrency:
jobs:
cpu-tests:
runs-on: ${{ matrix.os }}
env:
UV_SYSTEM_PIP: 1
CLEARML_OFFLINE_MODE: 1
CLEARML_API_HOST: http://localhost
CLEARML_WEB_HOST: http://localhost
CLEARML_FILES_HOST: http://localhost
timeout-minutes: 85
defaults:
run:
Expand All @@ -57,57 +63,34 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Install uv and Python
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}

- name: Get year & week number
id: get-date
run: |
echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT

- name: Get pip cache dir
id: pip-cache
run: |
pip install -U pip || python -m pip install -U pip
echo "pip_cache=$(pip cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: |
${{ steps.pip-cache.outputs.pip_cache }}
key: ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}-${{ hashFiles('requirements-dev.txt') }}
restore-keys: |
${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}-

- run: pip install pip wheel setuptools -Uqq
cache: true

- name: Install PyTorch
if: ${{ matrix.pytorch-channel == 'pytorch' }}
run: pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
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: pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre

- name: Install dependencies
run: |
pip install -r requirements-dev.txt
pip install .
pip list
uv pip install -r requirements-dev.txt
uv pip install -e .
uv pip list

- name: Check code formatting
run: |
bash ./tests/run_code_style.sh install
uv pip install --upgrade flake8 "black==24.10.0" "usort==1.0.8.post1" "ufmt==2.7.3" "mypy"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad, once we need to upgrade the version of one of these tools we need to do that in +1 place now.
In future I wanted to remove ./tests/run_code_style.sh and use pre-commit such that we can have only one file showing the used tools and the versions. But this is for another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is not ideal. If you have ideas for an alternative solution, I would gladly explore it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vfdev-5 redone with pre-commit. seems to be working fine

bash ./tests/run_code_style.sh lint

- name: Run Mypy
# https://github.com/pytorch/ignite/pull/2780
#
if: ${{ matrix.os == 'ubuntu-latest' && matrix.pytorch-channel == 'pytorch-nightly'}}
run: |
bash ./tests/run_code_style.sh mypy

# Download MNIST: https://github.com/pytorch/ignite/issues/1737
# to "/tmp" for unit tests
- name: Download MNIST
Expand Down
Loading