Skip to content

Commit 5c1da63

Browse files
committed
CI: Need to conserve runner disk space
1 parent 6759bcd commit 5c1da63

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
USE_ANTSPY_SOURCE_BUILD: false
12-
12+
ANTSXNET_CACHE_DIR: ${{ runner.temp }}/ANTsXNet
1313
jobs:
1414

1515
###########################################
@@ -40,7 +40,7 @@ jobs:
4040
uses: actions/cache/restore@v4
4141
with:
4242
key: ${{ steps.compute-key.outputs.cache-key }}
43-
path: ${{ runner.temp }}/ANTsXNet
43+
path: ${{ env.ANTSXNET_CACHE_DIR }}
4444

4545
- name: Cache hit — skip download
4646
if: steps.restore-cache.outputs.cache-hit == 'true'
@@ -69,17 +69,14 @@ jobs:
6969
if: steps.restore-cache.outputs.cache-hit != 'true'
7070
run: |
7171
pip install -e .
72-
python download_all_data.py --strict
73-
# Move to cache save location
74-
mkdir -p ${{ runner.temp }}/ANTsXNet
75-
cp -r ~/.keras/ANTsXNet/* ${{ runner.temp }}/ANTsXNet/
72+
python download_all_data.py --strict --cache-dir ${{ env.ANTSXNET_CACHE_DIR }}
7673
7774
- name: Save newly downloaded ANTsXNet data to cache
7875
if: steps.restore-cache.outputs.cache-hit != 'true'
7976
uses: actions/cache/save@v4
8077
with:
8178
key: ${{ steps.compute-key.outputs.cache-key }}
82-
path: ${{ runner.temp }}/ANTsXNet
79+
path: ${{ env.ANTSXNET_CACHE_DIR }}
8380

8481

8582
###########################################
@@ -125,12 +122,7 @@ jobs:
125122
uses: actions/cache/restore@v4
126123
with:
127124
key: ${{ needs.prepare-data.outputs.cache-key }}
128-
path: ${{ runner.temp }}/ANTsXNet
129-
130-
- name: Move cached data into ~/.keras
131-
run: |
132-
mkdir -p ~/.keras/ANTsXNet
133-
cp -r ${{ runner.temp }}/ANTsXNet/* ~/.keras/ANTsXNet/
125+
path: ~/.keras/ANTsXNet
134126

135127
- name: Install ANTsPyNet
136128
run: |

download_all_data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
import argparse
33
import sys
44

5-
def download_all_data(strict=False):
5+
def download_all_data(strict=False, cache_dir=None):
66
print("Downloading data files from get_antsxnet_data...")
7+
if cache_dir is not None:
8+
antspynet.set_antsxnet_cache_directory(cache_dir)
9+
print(f"Using custom cache directory: {cache_dir}")
710
try:
811
data_keys = antspynet.get_antsxnet_data("show")
912
for key in data_keys:
@@ -44,10 +47,11 @@ def download_all_data(strict=False):
4447
if __name__ == "__main__":
4548
parser = argparse.ArgumentParser()
4649
parser.add_argument("--strict", action="store_true", help="Exit on first failed download.")
50+
parser.add_argument("--cache-dir", type=str, help="Custom cache directory for downloads.", default=None)
4751
args = parser.parse_args()
4852

4953
try:
50-
download_all_data(strict=args.strict)
54+
download_all_data(strict=args.strict, cache_dir=args.cache_dir)
5155
except Exception as e:
5256
print(f"\nAborted due to error: {e}")
5357
sys.exit(1)

0 commit comments

Comments
 (0)