Skip to content

Lazily initialize diskcache to avoid creating cache directory on import#127

Open
andrewjcg wants to merge 1 commit intoopenai:mainfrom
andrewjcg:lazy-diskcache-init
Open

Lazily initialize diskcache to avoid creating cache directory on import#127
andrewjcg wants to merge 1 commit intoopenai:mainfrom
andrewjcg:lazy-diskcache-init

Conversation

@andrewjcg
Copy link

The module-level dc.Cache("cache") call in data.py creates a cache/ directory in the current working directory at import time, even when the cache is never used (e.g. during test discovery). This is problematic for environments where mlebench is imported from a read-only or shared directory.

Replace the eager cache initialization with a lazy _get_cache() helper that only creates the diskcache when get_checksum() is actually called.

The module-level `dc.Cache("cache")` call in `data.py` creates a `cache/`
directory in the current working directory at import time, even when the
cache is never used (e.g. during test discovery). This is problematic for
environments where mlebench is imported from a read-only or shared directory.

Replace the eager cache initialization with a lazy `_get_cache()` helper that
only creates the diskcache when `get_checksum()` is actually called.
@andrewjcg
Copy link
Author

This fixes some issues where this cache was being creating (in CWD) on module import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant