Skip to content

Commit 29d47b0

Browse files
authored
resolves CI's drive-out-of-space by prune caching and use torch fro CPU (#8673)
This pull request simplifies the caching setup for pip dependencies in the GitHub Actions workflow and ensures that all pip installs use the PyTorch CPU wheel index. The main changes involve replacing custom cache steps with the built-in `cache: 'pip'` option in `actions/setup-python`, and adding the `--extra-index-url` flag to all relevant pip install commands for consistent dependency resolution. **Workflow caching improvements:** * Replaced custom pip cache steps (using `actions/cache` and manual timestamp keys) with the built-in `cache: 'pip'` option in `actions/setup-python`, streamlining cache management across all jobs. [[1]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL36-R36) [[2]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbR69-L93) [[3]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL139-R127) [[4]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL221-R194) **Dependency installation updates:** * Updated all `pip install` commands to include `--extra-index-url https://download.pytorch.org/whl/cpu`, ensuring that PyTorch and related packages are consistently installed from the CPU wheel index. This affects installation from wheels, tarballs, requirements files, and direct package installs. [[1]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL139-R127) [[2]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL187-R156) [[3]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL198-R167) [[4]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL208-R177) [[5]](diffhunk://#diff-cbf97851bdfebccf2fcdd8848c6a93adb8d8affd5c6b1faf00238d528c3ef6cbL221-R194) --------- Signed-off-by: jirka <[email protected]>
1 parent 15fd428 commit 29d47b0

File tree

2 files changed

+10
-52
lines changed

2 files changed

+10
-52
lines changed

.github/workflows/pythonapp.yml

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,7 @@ jobs:
3333
uses: actions/setup-python@v6
3434
with:
3535
python-version: '3.9'
36-
- name: cache weekly timestamp
37-
id: pip-cache
38-
run: |
39-
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
40-
- name: cache for pip
41-
uses: actions/cache@v4
42-
id: cache
43-
with:
44-
path: ~/.cache/pip
45-
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
36+
cache: 'pip'
4637
- name: Install dependencies
4738
run: |
4839
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
@@ -75,22 +66,11 @@ jobs:
7566
uses: actions/setup-python@v6
7667
with:
7768
python-version: '3.9'
69+
cache: 'pip'
7870
- name: Prepare pip wheel
7971
run: |
8072
which python
8173
python -m pip install --upgrade pip wheel
82-
- name: cache weekly timestamp
83-
id: pip-cache
84-
run: |
85-
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
86-
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
87-
shell: bash
88-
- name: cache for pip
89-
uses: actions/cache@v4
90-
id: cache
91-
with:
92-
path: ${{ steps.pip-cache.outputs.dir }}
93-
key: ${{ matrix.os }}-latest-pip-${{ steps.pip-cache.outputs.datew }}
9474
- if: runner.os == 'windows'
9575
name: Install torch cpu from pytorch.org (Windows only)
9676
run: |
@@ -136,26 +116,15 @@ jobs:
136116
uses: actions/setup-python@v6
137117
with:
138118
python-version: '3.9'
139-
- name: cache weekly timestamp
140-
id: pip-cache
141-
run: |
142-
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
143-
- name: cache for pip
144-
uses: actions/cache@v4
145-
id: cache
146-
with:
147-
path: |
148-
~/.cache/pip
149-
~/.cache/torch
150-
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
119+
cache: 'pip'
151120
- name: Install dependencies
152121
run: |
153122
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
154123
python -m pip install --user --upgrade pip setuptools wheel twine packaging
155124
# install the latest pytorch for testing
156125
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
157126
# fresh torch installation according to pyproject.toml
158-
python -m pip install torch>=2.5.1 torchvision
127+
python -m pip install torch>=2.5.1 torchvision --extra-index-url https://download.pytorch.org/whl/cpu
159128
- name: Check packages
160129
run: |
161130
pip uninstall monai
@@ -184,7 +153,7 @@ jobs:
184153
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
185154
run: |
186155
# install from wheel
187-
python -m pip install monai*.whl
156+
python -m pip install monai*.whl --extra-index-url https://download.pytorch.org/whl/cpu
188157
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
189158
python -c 'import monai; print(monai.__file__)'
190159
python -m pip uninstall -y monai
@@ -195,7 +164,7 @@ jobs:
195164
# install from tar.gz
196165
name=$(ls *.tar.gz | head -n1)
197166
echo $name
198-
python -m pip install $name[all]
167+
python -m pip install $name[all] --extra-index-url https://download.pytorch.org/whl/cpu
199168
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
200169
python -c 'import monai; print(monai.__file__)'
201170
- name: Quick test
@@ -205,7 +174,7 @@ jobs:
205174
cp ${{ steps.root.outputs.pwd }}/requirements*.txt .
206175
cp -r ${{ steps.root.outputs.pwd }}/tests .
207176
ls -al
208-
python -m pip install -r requirements-dev.txt
177+
python -m pip install -r requirements-dev.txt --extra-index-url https://download.pytorch.org/whl/cpu
209178
python -m unittest -v
210179
env:
211180
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python # https://github.com/Project-MONAI/MONAI/issues/4354
@@ -218,22 +187,11 @@ jobs:
218187
uses: actions/setup-python@v6
219188
with:
220189
python-version: '3.9'
221-
- name: cache weekly timestamp
222-
id: pip-cache
223-
run: |
224-
echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
225-
- name: cache for pip
226-
uses: actions/cache@v4
227-
id: cache
228-
with:
229-
path: |
230-
~/.cache/pip
231-
~/.cache/torch
232-
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
190+
cache: 'pip'
233191
- name: Install dependencies
234192
run: |
235193
python -m pip install --upgrade pip wheel
236-
python -m pip install -r docs/requirements.txt
194+
python -m pip install -r docs/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
237195
- name: Make html
238196
run: |
239197
cd docs/

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ def get_cmds():
146146
cmdclass=get_cmds(),
147147
packages=find_packages(exclude=("docs", "examples", "tests")),
148148
zip_safe=False,
149-
package_data={"monai": ["py.typed", *jit_extension_source]},
149+
package_data={"monai": ["py.typed", *jit_extension_source]}, # type: ignore[arg-type]
150150
ext_modules=get_extensions(),
151151
)

0 commit comments

Comments
 (0)