Skip to content

redplanet.user_config.get_dirpath_datacache

get_dirpath_datacache() -> Path

Get the data path where datasets are downloaded/cached. Initializes to default path ('/home//.cache/redplanet/') if not set.

Returns:

Type Description
Path
Notes

[DEVELOPER NOTES:]

  • It's good design to defer initialization of default value until first access in get_dirpath_datacache()...
    • This way, we avoid any overhead or side-effects of executing any potentially expensive / unnecessary code (esp related to file system operations) during the module import (i.e. lazy initialization).
Source code in src/redplanet/user_config/datacache.py
def get_dirpath_datacache() -> Path:
    """
    Get the data path where datasets are downloaded/cached. Initializes to default path ('/home/<user>/.cache/redplanet/') if not set.

    Returns
    -------
    Path

    Notes
    -----
    [DEVELOPER NOTES:]

    - It's good design to defer initialization of default value until first access in `get_dirpath_datacache()`...
        - This way, we avoid any overhead or side-effects of executing any potentially expensive / unnecessary code (esp related to file system operations) during the module import (i.e. lazy initialization).
    """
    ## Lazy load
    if _dirpath_datacache is None:
        set_dirpath_datacache(
            Path(user_cache_dir(appname='redplanet')).resolve()
        )
    return _dirpath_datacache