Skip to content

Commit 1843211

Browse files
committed
Use astral uv on CI testing for faster installs
1 parent d78eb34 commit 1843211

File tree

7 files changed

+111
-75
lines changed

7 files changed

+111
-75
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: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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
3+
uv pip install setuptools pip wheel
4+
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
5+
uv pip install -r requirements-dev.txt
6+
uv pip install -r docs/requirements.txt
7+
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/unit-tests.yml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,44 +59,39 @@ jobs:
5959

6060
steps:
6161
- uses: actions/checkout@v4
62-
- uses: actions/setup-python@v5
63-
with:
64-
python-version: ${{ matrix.python-version }}
6562

6663
- name: Get year & week number
6764
id: get-date
6865
run: |
6966
echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
7067
71-
- name: Get pip cache dir
72-
id: pip-cache
73-
run: |
74-
pip install -U pip || python -m pip install -U pip
75-
echo "pip_cache=$(pip cache dir)" >> $GITHUB_OUTPUT
76-
77-
- uses: actions/cache@v4
68+
- uses: astral-sh/setup-uv@v6
7869
with:
79-
path: |
80-
${{ steps.pip-cache.outputs.pip_cache }}
81-
key: ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}-${{ hashFiles('requirements-dev.txt') }}
82-
restore-keys: |
83-
${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}-
70+
version: "latest"
71+
python-version: ${{ matrix.python-version }}
72+
activate-environment: true
73+
enable-cache: true
74+
cache-suffix: "${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-channel }}"
75+
cache-dependency-glob: |
76+
**/requirements-dev.txt
77+
**/pyproject.toml
8478
85-
- run: pip install pip wheel setuptools -Uqq
79+
- name: Install dev tools
80+
run: uv pip install wheel setuptools -Uqq
8681

8782
- name: Install PyTorch
8883
if: ${{ matrix.pytorch-channel == 'pytorch' }}
89-
run: pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
84+
run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
9085

9186
- name: Install PyTorch (nightly)
9287
if: ${{ matrix.pytorch-channel == 'pytorch-nightly' }}
93-
run: pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
88+
run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu --pre
9489

9590
- name: Install dependencies
9691
run: |
97-
pip install -r requirements-dev.txt
98-
pip install .
99-
pip list
92+
uv pip install -r requirements-dev.txt
93+
uv pip install .
94+
uv pip list
10095
10196
- name: Check code formatting
10297
run: |
@@ -155,7 +150,7 @@ jobs:
155150
# 3.1) mnist_with_tensorboard.py with tbX
156151
python examples/mnist/mnist_with_tensorboard.py --epochs=1
157152
# 3.2) mnist_with_tensorboard.py with native torch tb
158-
pip uninstall -y tensorboardX
153+
uv pip uninstall tensorboardX
159154
python examples/mnist/mnist_with_tensorboard.py --epochs=1
160155
161156
- name: Run MNIST Example With Crash

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sphinx<6
2-
-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
2+
git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
33
sphinxcontrib-katex
44
sphinx-copybutton==0.4.0
55
docutils<0.18

0 commit comments

Comments
 (0)