Skip to content

Commit c382d3a

Browse files
committed
swap to uv
1 parent da7f2f9 commit c382d3a

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

.github/workflows/ci-tests-pytorch.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ defaults:
3535
run:
3636
shell: bash
3737

38+
env:
39+
UV_SYSTEM_PYTHON: 1
40+
3841
jobs:
3942
pl-cpu:
4043
runs-on: ${{ matrix.os }}
@@ -69,33 +72,39 @@ jobs:
6972
TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/"
7073
TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/"
7174
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
72-
PYPI_CACHE_DIR: "_pip-wheels"
75+
UV_CACHE_DIR: /tmp/.uv-cache
7376
# TODO: Remove this - Enable running MPS tests on this platform
7477
DISABLE_MPS: ${{ matrix.os == 'macOS-14' && '1' || '0' }}
7578
steps:
7679
- uses: actions/checkout@v5
7780

78-
- name: Set up Python ${{ matrix.config.python-version }}
79-
uses: actions/setup-python@v5
81+
- name: Install uv and set Python version
82+
uses: astral-sh/setup-uv@v6
8083
with:
8184
python-version: ${{ matrix.config.python-version || '3.9' }}
8285

83-
- name: basic setup
84-
run: pip install -q -r .actions/requirements.txt
86+
- name: Restore uv cache
87+
uses: actions/cache@v4
88+
with:
89+
path: ${{ env.UV_CACHE_DIR }}
90+
key: uv-cache-${{ matrix.os }}-${{ matrix.config.python-version || '3.9' }}
91+
92+
- name: Basic setup
93+
run: uv pip install -q -r .actions/requirements.txt
8594

8695
- name: Set min. dependencies
8796
if: ${{ matrix.requires == 'oldest' }}
8897
run: |
8998
cd requirements/pytorch
90-
pip install -U "lightning-utilities[cli]"
99+
uv pip install -U "lightning-utilities[cli]"
91100
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'extra.txt', 'strategies.txt', 'examples.txt', 'test.txt']"
92-
pip install "cython<3.0" wheel
93-
pip install "pyyaml==5.4" --no-build-isolation
101+
uv pip install "cython<3.0" wheel
102+
uv pip install "pyyaml==5.4" --no-build-isolation
94103
95104
- name: Adjust PyTorch versions in requirements files
96105
if: ${{ matrix.requires != 'oldest' }}
97106
run: |
98-
pip install -q -r requirements/ci.txt
107+
uv pip install -q -r requirements/ci.txt
99108
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
100109
for fpath in `ls requirements/**/*.txt`; do \
101110
python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \
@@ -125,7 +134,7 @@ jobs:
125134
- name: Install package & dependencies
126135
timeout-minutes: 20
127136
run: |
128-
pip install ".[${EXTRA_PREFIX}extra,${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
137+
uv pip install ".[${EXTRA_PREFIX}extra,${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
129138
-U --upgrade-strategy=eager --prefer-binary \
130139
-r requirements/_integrations/accelerators.txt \
131140
--extra-index-url="${TORCH_URL}" \
@@ -135,10 +144,12 @@ jobs:
135144
- name: Drop LAI from extensions
136145
if: ${{ matrix.config.pkg-name != 'lightning' }}
137146
# Lightning is dependency of Habana or other accelerators/integrations so in case we test PL we need to remove it
138-
run: pip uninstall -y lightning
147+
run: uv pip uninstall -y lightning
148+
139149
- name: Drop PL for LAI
140150
if: ${{ matrix.config.pkg-name == 'lightning' }}
141-
run: pip uninstall -y pytorch-lightning
151+
run: uv pip uninstall -y pytorch-lightning
152+
142153
- name: Dump handy wheels
143154
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
144155
continue-on-error: true
@@ -215,6 +226,9 @@ jobs:
215226
name: CPU-coverage
216227
fail_ci_if_error: false
217228

229+
- name: Minimize uv cache
230+
run: uv cache prune --ci
231+
218232
pl-cpu-guardian:
219233
runs-on: ubuntu-latest
220234
needs: pl-cpu

0 commit comments

Comments
 (0)