Skip to content

Commit 62ee6f3

Browse files
committed
Use astral uv on CI testing. Add uv lock and lock check
1 parent d78eb34 commit 62ee6f3

File tree

10 files changed

+176
-90
lines changed

10 files changed

+176
-90
lines changed

.github/workflows/code-style.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ jobs:
1919
steps:
2020
- if: github.event_name == 'push'
2121
uses: actions/checkout@v4
22-
- uses: actions/setup-python@v5
22+
- uses: astral-sh/setup-uv@v6
2323
with:
24+
version: "latest"
2425
python-version: "3.11"
26+
activate-environment: true
27+
enable-cache: true
28+
cache-dependency-glob: |
29+
**/requirements-dev.txt
30+
**/pyproject.toml
2531
- run: |
2632
pip install -r requirements-dev.txt
2733
pre-commit run -a

.github/workflows/docs.yml

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,28 @@ jobs:
1717
permissions:
1818
contents: write
1919
if: (github.ref == 'refs/heads/master' && github.event_name == 'push') || github.event_name == 'release'
20-
runs-on: ubuntu-latest
20+
runs-on: ${{ matrix.os }}
21+
strategy:
22+
max-parallel: 10
23+
fail-fast: false
24+
matrix:
25+
os: ["ubuntu-latest"]
26+
python-version: ["3.10"]
2127
steps:
2228
- uses: actions/checkout@v4
23-
- uses: actions/setup-python@v5
29+
- uses: astral-sh/setup-uv@v6
2430
with:
25-
python-version: "3.10"
31+
version: "latest"
32+
python-version: "${{ matrix.python-version }}"
33+
activate-environment: true
34+
enable-cache: true
35+
cache-suffix: "${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}"
36+
cache-dependency-glob: |
37+
**/docs/requirements.txt
38+
**/requirements-dev.txt
39+
**/pyproject.toml
2640
2741
- run: sudo npm install katex -g
28-
- uses: actions/cache@v4
29-
with:
30-
path: ~/.cache/pip
31-
key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
3242

3343
- name: Install docs deps
3444
run: bash .github/workflows/install_docs_deps.sh
@@ -47,18 +57,27 @@ jobs:
4757

4858
linkcheck:
4959
if: github.event_name == 'pull_request' || github.event_name == 'push'
50-
runs-on: ubuntu-latest
60+
runs-on: ${{ matrix.os }}
5161
timeout-minutes: 10
62+
strategy:
63+
max-parallel: 10
64+
fail-fast: false
65+
matrix:
66+
os: ["ubuntu-latest"]
67+
python-version: ["3.10"]
5268
steps:
5369
- uses: actions/checkout@v4
54-
- uses: actions/setup-python@v5
55-
with:
56-
python-version: "3.10"
57-
58-
- uses: actions/cache@v4
70+
- uses: astral-sh/setup-uv@v6
5971
with:
60-
path: ~/.cache/pip
61-
key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
72+
version: "latest"
73+
python-version: ${{ matrix.python-version }}
74+
activate-environment: true
75+
enable-cache: true
76+
cache-suffix: "${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}"
77+
cache-dependency-glob: |
78+
**/docs/requirements.txt
79+
**/requirements-dev.txt
80+
**/pyproject.toml
6281
6382
- name: Install docs deps
6483
run: bash .github/workflows/install_docs_deps.sh
@@ -69,18 +88,28 @@ jobs:
6988

7089
doctest:
7190
if: github.event_name == 'pull_request' || github.event_name == 'push'
72-
runs-on: ubuntu-latest
91+
runs-on: ${{ matrix.os }}
92+
strategy:
93+
max-parallel: 10
94+
fail-fast: false
95+
matrix:
96+
os: ["ubuntu-latest"]
97+
python-version: ["3.10"]
7398
steps:
7499
- uses: actions/checkout@v4
75-
- uses: actions/setup-python@v5
100+
- uses: astral-sh/setup-uv@v6
76101
with:
77-
python-version: "3.10"
102+
version: "latest"
103+
python-version: "${{ matrix.python-version }}"
104+
activate-environment: true
105+
enable-cache: true
106+
cache-suffix: "${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}"
107+
cache-dependency-glob: |
108+
**/docs/requirements.txt
109+
**/requirements-dev.txt
110+
**/pyproject.toml
78111
79112
- run: sudo npm install katex -g
80-
- uses: actions/cache@v4
81-
with:
82-
path: ~/.cache/pip
83-
key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
84113

85114
- name: Install docs deps
86115
run: bash .github/workflows/install_docs_deps.sh

.github/workflows/hvd-tests.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,24 @@ jobs:
3939
run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
4040
shell: bash -l {0}
4141

42-
- name: Get pip cache dir
43-
id: pip-cache
44-
run: |
45-
python3 -m pip install -U pip
46-
echo "pip_cache=$(python3 -m pip cache dir)" >> $GITHUB_OUTPUT
47-
shell: bash -l {0}
48-
49-
- uses: actions/cache@v4
50-
with:
51-
path: |
52-
~/conda_pkgs_dir
53-
${{ steps.pip-cache.outputs.pip_cache }}
54-
key: ${{ steps.get-date.outputs.date }}-horovod-${{ hashFiles('requirements-dev.txt') }}
55-
56-
- uses: actions/setup-python@v5
42+
- uses: astral-sh/setup-uv@v6
5743
with:
44+
version: "latest"
5845
python-version: ${{ matrix.python-version }}
46+
activate-environment: true
47+
enable-cache: true
48+
cache-suffix: "${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}"
49+
cache-dependency-glob: |
50+
**/requirements-dev.txt
51+
**/pyproject.toml
5952
6053
- name: Install dependencies
6154
shell: bash -l {0}
6255
run: |
6356
64-
#install other dependencies
65-
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
66-
pip install -r requirements-dev.txt
57+
# Install other dependencies
58+
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
59+
uv pip install -r requirements-dev.txt
6760
6861
# Install Horovod from source and apply a patch to build with recent pytorch
6962
# We can't use pip install <whatever> as build-env can't find pytorch and
@@ -78,7 +71,9 @@ jobs:
7871
python -c "import horovod.torch as hvd; hvd.mpi_ops.Sum"
7972
8073
# Install ignite
81-
pip install .
74+
uv pip install .
75+
76+
uv pip list
8277
8378
# Download MNIST: https://github.com/pytorch/ignite/issues/1737
8479
# to "/tmp" for cpu tests
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# remove pkg-resources as it causes failure when installing https://github.com/pytorch-ignite/sphinxcontrib-versioning
2-
pip uninstall -y pkg-resources setuptools && pip install --upgrade setuptools pip wheel
3-
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu -U
4-
pip install -r requirements-dev.txt
5-
pip install -r docs/requirements.txt
6-
pip install git+https://github.com/pytorch-ignite/sphinxcontrib-versioning.git
2+
uv pip uninstall pkg-resources setuptools && pip install setuptools pip wheel
3+
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
4+
uv pip install -r requirements-dev.txt
5+
uv pip install -r docs/requirements.txt
6+
uv pip install git+https://github.com/pytorch-ignite/sphinxcontrib-versioning.git

.github/workflows/mps-tests.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,43 @@ jobs:
6868
with:
6969
python-version: ${{ matrix.python-version }}
7070

71+
- name: Install uv
72+
shell: bash -l {0}
73+
run: |
74+
conda shell.bash hook
75+
conda activate $CONDA_ENV
76+
pip install uv
77+
7178
- name: Install PyTorch
7279
if: ${{ matrix.pytorch-channel == 'pytorch' }}
7380
shell: bash -l {0}
7481
run: |
7582
conda shell.bash hook
7683
conda activate $CONDA_ENV
77-
pip install -U torch torchvision
84+
uv pip install torch torchvision
7885
7986
- name: Install PyTorch (nightly)
8087
if: ${{ matrix.pytorch-channel == 'pytorch-nightly' }}
8188
shell: bash -l {0}
8289
run: |
8390
conda shell.bash hook
8491
conda activate $CONDA_ENV
85-
pip install --pre -U torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
92+
uv pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
8693
8794
- name: Install dependencies
8895
shell: bash -l {0}
8996
working-directory: ${{ github.repository }}
9097
run: |
98+
conda shell.bash hook
9199
conda activate $CONDA_ENV
92100
# TODO: We add set -xe to explicitly fail the CI if one of the commands is failing.
93101
# Somehow the step is passing even if a subcommand failed
94102
set -xe
95-
pip install -r requirements-dev.txt
103+
uv pip install -r requirements-dev.txt
96104
echo "1 returned code: $?"
97-
pip install -e .
105+
uv pip install .
98106
echo "2 returned code: $?"
99-
pip list
107+
uv pip list
100108
echo "3 returned code: $?"
101109
102110
# Download MNIST: https://github.com/pytorch/ignite/issues/1737
@@ -115,6 +123,7 @@ jobs:
115123
shell: bash -l {0}
116124
working-directory: ${{ github.repository }}
117125
run: |
126+
conda shell.bash hook
118127
conda activate $CONDA_ENV
119128
SKIP_DISTRIB_TESTS=${{ matrix.skip-distrib-tests }} bash tests/run_cpu_tests.sh
120129
@@ -129,5 +138,6 @@ jobs:
129138
shell: bash -l {0}
130139
working-directory: ${{ github.repository }}
131140
run: |
141+
conda shell.bash hook
132142
conda activate $CONDA_ENV
133143
python examples/mnist/mnist.py --epochs=1

.github/workflows/tpu-tests.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ on:
66
- "*.*.*"
77
paths:
88
- "ignite/**"
9+
- "pyproject.toml"
910
- "tests/ignite/**"
1011
- "tests/run_tpu_tests.sh"
1112
- "requirements-dev.txt"
1213
- ".github/workflows/tpu-tests.yml"
1314
pull_request:
1415
paths:
1516
- "ignite/**"
17+
- "pyproject.toml"
1618
- "tests/ignite/**"
1719
- "tests/run_tpu_tests.sh"
1820
- "requirements-dev.txt"
@@ -30,25 +32,33 @@ jobs:
3032
strategy:
3133
fail-fast: false
3234
matrix:
33-
xla-version: [nightly]
35+
xla-version: ["nightly"]
36+
PYTHON_VERSION: ["3.10"]
3437

3538
steps:
3639
- uses: actions/checkout@v4
37-
- name: Set up Python 3.10
38-
uses: actions/setup-python@v5
39-
with:
40-
python-version: "3.10"
41-
architecture: "x64"
4240

4341
- name: Get year & week number
4442
id: get-date
4543
run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
4644
shell: bash -l {0}
4745

46+
- name: Set up Python 3.10
47+
uses: astral-sh/setup-uv@v6
48+
with:
49+
# architecture: "x64"
50+
version: "latest"
51+
python-version: "${{ matrix.PYTHON_VERSION }}"
52+
activate-environment: true
53+
enable-cache: true
54+
cache-suffix: "${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}"
55+
cache-dependency-glob: |
56+
**/requirements-dev.txt
57+
**/pyproject.toml
58+
4859
- name: Get pip cache dir
4960
id: pip-cache
5061
run: |
51-
pip3 install -U "pip<24"
5262
echo "pip_cache=$(pip cache dir)" >> $GITHUB_OUTPUT
5363
shell: bash -l {0}
5464

@@ -65,18 +75,21 @@ jobs:
6575
6676
## Install mkl (alternative approach to https://github.com/pytorch/xla/blob/b0ba29f98a695671972d4a4cc07441014dba2892/.kokoro/common.sh#L31-L32)
6777
sudo apt-get update && sudo apt-get install -y libopenblas-dev libomp5
68-
pip install mkl==2021.4.0
78+
uv pip install mkl==2021.4.0
6979
7080
## Install torch & xla and torchvision
71-
pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
72-
pip install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl
81+
uv pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
82+
# https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl
83+
python scripts/install_torch_xla.py "${{ matrix.PYTHON_VERSION }}" "${{ matrix.xla-version }}"
7384
7485
# Check installation
7586
python -c "import torch"
7687
7788
## Install test deps and Ignite
78-
pip install -r requirements-dev.txt
79-
pip install .
89+
uv pip install -r requirements-dev.txt
90+
uv pip install .
91+
92+
uv pip list
8093
8194
# Download MNIST: https://github.com/pytorch/ignite/issues/1737
8295
# to "/tmp" for tpu tests

0 commit comments

Comments
 (0)