diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29b..147fc9df 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Persistent cache location for data files. diff --git a/policyengine/utils/data/caching_google_storage_client.py b/policyengine/utils/data/caching_google_storage_client.py index 10de203a..e3e9c0a7 100644 --- a/policyengine/utils/data/caching_google_storage_client.py +++ b/policyengine/utils/data/caching_google_storage_client.py @@ -5,6 +5,7 @@ import logging from .simplified_google_storage_client import SimplifiedGoogleStorageClient from typing import Optional +from platformdirs import user_cache_dir logger = logging.getLogger(__name__) @@ -17,7 +18,8 @@ class CachingGoogleStorageClient(AbstractContextManager): def __init__(self): self.client = SimplifiedGoogleStorageClient() - self.cache = diskcache.Cache() + cache_folder = user_cache_dir("policyengine.py") + self.cache = diskcache.Cache(directory=cache_folder) def _data_key( self, bucket: str, key: str, version: Optional[str] = None