Skip to content

Commit 05d43b0

Browse files
matsumotosanlantiga
authored andcommitted
uv for tests-fabric (#21155)
(cherry picked from commit 663b6ce)
1 parent 1b9ef30 commit 05d43b0

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

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

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,49 +62,57 @@ jobs:
6262
env:
6363
PACKAGE_NAME: ${{ matrix.config.pkg-name }}
6464
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
65-
PYPI_CACHE_DIR: "_pip-wheels"
6665
TORCH_URL_STABLE: "https://download.pytorch.org/whl/cpu/"
6766
TORCH_URL_TEST: "https://download.pytorch.org/whl/test/cpu/"
6867
# TODO: Remove this - Enable running MPS tests on this platform
6968
DISABLE_MPS: ${{ matrix.os == 'macOS-14' && '1' || '0' }}
7069
steps:
7170
- uses: actions/checkout@v5
7271

73-
- name: Set up Python ${{ matrix.config.python-version }}
74-
uses: actions/setup-python@v5
72+
- name: Install uv and set Python version
73+
uses: astral-sh/setup-uv@v6
7574
with:
7675
python-version: ${{ matrix.config.python-version || '3.9' }}
76+
# TODO: Avoid activating environment like this
77+
# see: https://github.com/astral-sh/setup-uv/tree/v6/?tab=readme-ov-file#activate-environment
78+
activate-environment: true
79+
enable-cache: true
7780

78-
- name: basic setup
79-
run: pip install -q -r .actions/requirements.txt
81+
- name: Basic setup
82+
run: uv pip install -q -r .actions/requirements.txt
83+
84+
- name: Append Env. vars for Linux
85+
if: ${{ runner.os == 'Linux' }}
86+
run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV
87+
88+
- name: Append Env. vars for MacOS
89+
if: ${{ runner.os == 'macOS' }}
90+
run: echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV
91+
92+
- name: Append Env. vars for Windows
93+
if: ${{ runner.os == 'windows' }}
94+
run: |
95+
# Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support"
96+
echo "USE_LIBUV=0" >> $GITHUB_ENV
8097
8198
- name: Set min. dependencies
8299
if: ${{ matrix.config.requires == 'oldest' }}
83100
run: |
84101
cd requirements/fabric
85-
pip install -U "lightning-utilities[cli]"
102+
uv pip install -U "lightning-utilities[cli]"
86103
python -m lightning_utilities.cli requirements set-oldest --req_files "['base.txt', 'strategies.txt', 'test.txt']"
87-
pip install "cython<3.0" wheel
88-
pip install "pyyaml==5.4" --no-build-isolation
104+
uv pip install "cython<3.0" wheel
105+
uv pip install "pyyaml==5.4" --no-build-isolation
89106
90107
- name: Adjust PyTorch versions in requirements files
91108
if: ${{ matrix.config.requires != 'oldest' }}
92109
run: |
93-
pip install -q -r requirements/ci.txt
110+
uv pip install -q -r requirements/ci.txt
94111
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
95112
for fpath in `ls requirements/**/*.txt`; do \
96113
python ./adjust-torch-versions.py $fpath ${{ matrix.config.pytorch-version }}; \
97114
done
98115
99-
- name: pip wheels cache
100-
uses: actions/cache/restore@v4
101-
with:
102-
path: ${{ env.PYPI_CACHE_DIR }}
103-
key: pypi_wheels
104-
- run: |
105-
mkdir -p $PYPI_CACHE_DIR
106-
ls -lh $PYPI_CACHE_DIR
107-
108116
- name: Expand Env. variables
109117
run: |
110118
# Switch PyTorch URL between stable and test/future
@@ -113,25 +121,15 @@ jobs:
113121
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.config.pkg-name}}' == 'lightning' else 'lightning_fabric'))" >> $GITHUB_ENV
114122
# if you install mono-package set dependency only for this subpackage
115123
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.config.pkg-name}}' != 'lightning' else 'fabric-'))" >> $GITHUB_ENV
116-
- name: Append Env. vars for MacOS
117-
if: ${{ runner.os == 'macOS' }}
118-
run: |
119-
# trying to avoid "gloo" issue with SIGABRT
120-
echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV
121-
- name: Append Env. vars for Windows
122-
if: ${{ runner.os == 'windows' }}
123-
run: |
124-
# Avoid issue on Windows with PyTorch 2.4: "RuntimeError: use_libuv was requested but PyTorch was build without libuv support"
125-
echo "USE_LIBUV=0" >> $GITHUB_ENV
126124
127125
- name: Install package & dependencies
128126
timeout-minutes: 20
129127
run: |
130-
pip install -e ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
131-
-U --upgrade-strategy=eager --prefer-binary \
132-
--extra-index-url="${TORCH_URL}" \
133-
--find-links="${PYPI_CACHE_DIR}"
134-
pip list
128+
uv pip install ".[${EXTRA_PREFIX}test,${EXTRA_PREFIX}strategies]" \
129+
--upgrade \
130+
--find-links="${TORCH_URL}"
131+
uv pip list
132+
135133
- name: Dump handy wheels
136134
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
137135
continue-on-error: true
@@ -179,6 +177,9 @@ jobs:
179177
name: CPU-coverage
180178
fail_ci_if_error: false
181179

180+
- name: Minimize uv cache
181+
run: uv cache prune --ci
182+
182183
fabric-cpu-guardian:
183184
runs-on: ubuntu-latest
184185
needs: fabric-cpu

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
- name: Append Env. vars for Linux
9090
if: ${{ runner.os == 'Linux' }}
9191
run: echo "GLOO_SOCKET_IFNAME=eth0" >> $GITHUB_ENV
92+
9293
- name: Append Env. vars for MacOS
9394
if: ${{ runner.os == 'macOS' }}
9495
run: echo "GLOO_SOCKET_IFNAME=lo0" >> $GITHUB_ENV

0 commit comments

Comments
 (0)