Skip to content

Commit 6fcbb78

Browse files
committed
Use uv for other workflows
1 parent 30a3f14 commit 6fcbb78

File tree

10 files changed

+482
-65
lines changed

10 files changed

+482
-65
lines changed

.github/workflows/code-style.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ jobs:
2121
steps:
2222
- if: github.event_name == 'push'
2323
uses: actions/checkout@v4
24-
- uses: actions/setup-python@v5
24+
- uses: astral-sh/setup-uv@v6
2525
with:
2626
python-version: "3.11"
27+
activate-environment: true
28+
enable-cache: true
29+
- name: Check lock
30+
id: check-lock
31+
run: |
32+
uv lock --check
2733
- run: |
2834
bash ./tests/run_code_style.sh install
2935
bash ./tests/run_code_style.sh fmt

.github/workflows/docs.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
23-
- uses: actions/setup-python@v5
23+
- uses: astral-sh/setup-uv@v6
2424
with:
2525
python-version: "3.10"
26+
activate-environment: true
27+
enable-cache: true
2628

2729
- 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') }}
30+
# - uses: actions/cache@v4
31+
# with:
32+
# path: ~/.cache/pip
33+
# key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
3234

3335
- name: Install docs deps
3436
run: bash .github/workflows/install_docs_deps.sh
@@ -51,14 +53,16 @@ jobs:
5153
timeout-minutes: 10
5254
steps:
5355
- uses: actions/checkout@v4
54-
- uses: actions/setup-python@v5
56+
- uses: astral-sh/setup-uv@v6
5557
with:
5658
python-version: "3.10"
59+
activate-environment: true
60+
enable-cache: true
5761

58-
- uses: actions/cache@v4
59-
with:
60-
path: ~/.cache/pip
61-
key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
62+
# - uses: actions/cache@v4
63+
# with:
64+
# path: ~/.cache/pip
65+
# key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
6266

6367
- name: Install docs deps
6468
run: bash .github/workflows/install_docs_deps.sh
@@ -72,15 +76,23 @@ jobs:
7276
runs-on: ubuntu-latest
7377
steps:
7478
- uses: actions/checkout@v4
75-
- uses: actions/setup-python@v5
79+
80+
- uses: astral-sh/setup-uv@v6
7681
with:
7782
python-version: "3.10"
83+
activate-environment: true
84+
enable-cache: true
85+
86+
- name: Check lock
87+
id: check-lock
88+
run: |
89+
uv lock --check
7890
7991
- 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') }}
92+
# - uses: actions/cache@v4
93+
# with:
94+
# path: ~/.cache/pip
95+
# key: pip-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('docs/requirements.txt') }}
8496

8597
- name: Install docs deps
8698
run: bash .github/workflows/install_docs_deps.sh

.github/workflows/hvd-tests.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,36 @@ jobs:
4141

4242
- name: Get pip cache dir
4343
id: pip-cache
44+
shell: bash -l {0}
4445
run: |
45-
python3 -m pip install -U pip
46+
uv pip install -U pip
4647
echo "pip_cache=$(python3 -m pip cache dir)" >> $GITHUB_OUTPUT
47-
shell: bash -l {0}
4848
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') }}
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') }}
5555

56-
- uses: actions/setup-python@v5
56+
- uses: astral-sh/setup-uv@v6
5757
with:
5858
python-version: ${{ matrix.python-version }}
59+
activate-environment: true
60+
enable-cache: true
5961

62+
- name: Check lock
63+
id: check-lock
64+
run: |
65+
uv lock --check
66+
6067
- name: Install dependencies
6168
shell: bash -l {0}
6269
run: |
6370
64-
#install other dependencies
65-
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
66-
pip install -r requirements-dev.txt
71+
# install other dependencies
72+
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
73+
uv pip install -r requirements-dev.txt
6774
6875
# Install Horovod from source and apply a patch to build with recent pytorch
6976
# We can't use pip install <whatever> as build-env can't find pytorch and
@@ -78,7 +85,7 @@ jobs:
7885
python -c "import horovod.torch as hvd; hvd.mpi_ops.Sum"
7986
8087
# Install ignite
81-
pip install .
88+
uv pip install .
8289
8390
# Download MNIST: https://github.com/pytorch/ignite/issues/1737
8491
# 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 --upgrade setuptools pip wheel
3+
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu -U
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/tpu-tests.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,51 @@ jobs:
3636

3737
steps:
3838
- uses: actions/checkout@v4
39+
3940
- name: Set up Python 3.10
40-
uses: actions/setup-python@v5
41+
uses: astral-sh/setup-uv@v6
4142
with:
4243
python-version: "3.10"
43-
architecture: "x64"
44+
activate-environment: true
45+
enable-cache: true
46+
47+
- name: Check lock
48+
id: check-lock
49+
run: |
50+
uv lock --check
4451
4552
- name: Get year & week number
4653
id: get-date
47-
run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
4854
shell: bash -l {0}
55+
run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
4956

5057
- name: Get pip cache dir
5158
id: pip-cache
59+
shell: bash -l {0}
5260
run: |
53-
pip3 install -U "pip<24"
61+
uv pip install -U "pip<24"
5462
echo "pip_cache=$(pip cache dir)" >> $GITHUB_OUTPUT
55-
shell: bash -l {0}
56-
57-
- uses: actions/cache@v4
58-
with:
59-
path: |
60-
${{ steps.pip-cache.outputs.pip_cache }}
61-
key: ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.xla-version }}-${{ hashFiles('requirements-dev.txt') }}
62-
restore-keys: |
63-
${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.xla-version }}-
6463
6564
- name: Install Torch XLA and others
6665
run: |
6766
6867
## Install mkl (alternative approach to https://github.com/pytorch/xla/blob/b0ba29f98a695671972d4a4cc07441014dba2892/.kokoro/common.sh#L31-L32)
6968
sudo apt-get update && sudo apt-get install -y libopenblas-dev libomp5
70-
pip install mkl==2021.4.0
69+
uv pip install mkl==2021.4.0
7170
7271
## Install torch & xla and torchvision
73-
pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
74-
pip install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl
72+
uv pip install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
73+
## TODO: download file and rename as valid file with version
74+
curl -o torch_xla-2.5.0+gitf0bbaeb-cp310-cp310-linux_x86_64.whl https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl
75+
uv pip install torch_xla-2.5.0+gitf0bbaeb-cp310-cp310-linux_x86_64.whl
76+
# uv pip install https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-nightly-cp310-cp310-linux_x86_64.whl
7577
7678
# Check installation
7779
python -c "import torch"
7880
7981
## Install test deps and Ignite
80-
pip install -r requirements-dev.txt
81-
pip install .
82+
uv pip install -r requirements-dev.txt
83+
uv pip install .
8284
8385
# Download MNIST: https://github.com/pytorch/ignite/issues/1737
8486
# to "/tmp" for tpu tests

.github/workflows/unit-tests.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,16 @@ jobs:
5959

6060
steps:
6161
- uses: actions/checkout@v4
62-
- uses: actions/setup-python@v5
62+
- uses: astral-sh/setup-uv@v6
6363
with:
6464
python-version: ${{ matrix.python-version }}
65+
activate-environment: true
66+
enable-cache: true
67+
68+
- name: Check lock
69+
id: check-lock
70+
run: |
71+
uv lock --check
6572
6673
- name: Get year & week number
6774
id: get-date
@@ -86,17 +93,17 @@ jobs:
8693

8794
- name: Install PyTorch
8895
if: ${{ matrix.pytorch-channel == 'pytorch' }}
89-
run: pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
96+
run: uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
9097

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

95102
- name: Install dependencies
96103
run: |
97-
pip install -r requirements-dev.txt
98-
pip install .
99-
pip list
104+
uv pip install -r requirements-dev.txt
105+
uv pip install .
106+
uv pip list
100107
101108
- name: Check code formatting
102109
run: |
@@ -156,7 +163,7 @@ jobs:
156163
# 3.1) mnist_with_tensorboard.py with tbX
157164
python examples/mnist/mnist_with_tensorboard.py --epochs=1
158165
# 3.2) mnist_with_tensorboard.py with native torch tb
159-
pip uninstall -y tensorboardX
166+
uv pip uninstall tensorboardX
160167
python examples/mnist/mnist_with_tensorboard.py --epochs=1
161168
162169
- 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

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ license-files = ["LICENSE"]
1414
classifiers = [
1515
"Programming Language :: Python :: 3",
1616
]
17+
requires-python = ">=3.9,<3.13"
1718
dependencies = [
1819
"torch>=1.3,<3",
1920
"packaging"

tests/run_code_style.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
set -xeu
44

55
if [ $1 = "lint" ]; then
6-
flake8 ignite tests examples --config setup.cfg
7-
ufmt diff .
6+
uv run flake8 ignite tests examples --config setup.cfg
7+
uv run ufmt diff .
88
elif [ $1 = "fmt" ]; then
9-
ufmt format .
9+
uv run ufmt format .
1010
elif [ $1 = "mypy" ]; then
11-
mypy --config-file mypy.ini
11+
uv run mypy --config-file mypy.ini
1212
elif [ $1 = "install" ]; then
13-
pip install --upgrade flake8 "black==24.10.0" "usort==1.0.8.post1" "ufmt==2.7.3" "mypy"
13+
uv pip install --upgrade flake8 "black==24.10.0" "usort==1.0.8.post1" "ufmt==2.7.3" "mypy"
1414
fi

0 commit comments

Comments
 (0)