Skip to content

Commit

Permalink
enh: allow moving the cache folder with an environment variable
Browse files Browse the repository at this point in the history
Resolves: #1029.
  • Loading branch information
oesteban committed Apr 17, 2024
1 parent 3fe9046 commit 494d4ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mriqc/cli/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@

from contextlib import suppress
from datetime import datetime, timezone
from pathlib import Path

import requests

from mriqc import __version__
from mriqc import __version__, config

RELEASE_EXPIRY_DAYS = 14
DATE_FMT = '%Y%m%d'
Expand All @@ -42,7 +41,7 @@ def check_latest():
latest = None
date = None
outdated = None
cachefile = Path.home() / '.cache' / 'mriqc' / 'latest'
cachefile = config.environment.cache_path / 'latest'
try:
cachefile.parent.mkdir(parents=True, exist_ok=True)
except OSError:
Expand Down
7 changes: 7 additions & 0 deletions mriqc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@
else '18480913-163000_PhineasG-ageh-adhi-sacc-ident9b1ab0f'
)

_mriqc_cache = Path(os.getenv(
'MRIQC_CACHE_PATH',
str(Path.home() / '.cache' / 'mriqc')
)).absolute()


class _Config:
"""An abstract class forbidding instantiation."""
Expand Down Expand Up @@ -283,6 +288,8 @@ class environment(_Config):
"""

cache_path = _mriqc_cache
"""Path to the location of the cache directory."""
cpu_count = os.cpu_count()
"""Number of available CPUs."""
exec_docker_version = _docker_ver
Expand Down

0 comments on commit 494d4ad

Please sign in to comment.