Skip to content

Commit 7fe5335

Browse files
authored
Merge pull request #1285 from nipreps/fix/1029-cache-folder
ENH: Allow moving the cache folder with an environment variable
2 parents 3fe9046 + ad475e4 commit 7fe5335

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

mriqc/cli/version.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424

2525
from contextlib import suppress
2626
from datetime import datetime, timezone
27-
from pathlib import Path
2827

2928
import requests
3029

31-
from mriqc import __version__
30+
from mriqc import __version__, config
3231

3332
RELEASE_EXPIRY_DAYS = 14
3433
DATE_FMT = '%Y%m%d'
@@ -42,7 +41,7 @@ def check_latest():
4241
latest = None
4342
date = None
4443
outdated = None
45-
cachefile = Path.home() / '.cache' / 'mriqc' / 'latest'
44+
cachefile = config.environment.cache_path / 'latest'
4645
try:
4746
cachefile.parent.mkdir(parents=True, exist_ok=True)
4847
except OSError:

mriqc/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212
else '18480913-163000_PhineasG-ageh-adhi-sacc-ident9b1ab0f'
213213
)
214214

215+
_mriqc_cache = Path(
216+
os.getenv('MRIQC_CACHE_PATH', str(Path.home() / '.cache' / 'mriqc'))
217+
).absolute()
218+
215219

216220
class _Config:
217221
"""An abstract class forbidding instantiation."""
@@ -283,6 +287,8 @@ class environment(_Config):
283287
284288
"""
285289

290+
cache_path = _mriqc_cache
291+
"""Path to the location of the cache directory."""
286292
cpu_count = os.cpu_count()
287293
"""Number of available CPUs."""
288294
exec_docker_version = _docker_ver

0 commit comments

Comments
 (0)