Skip to content

redplanet.user_config.set_dirpath_datacache

set_dirpath_datacache(
    target_path: str | pathlib.Path,
) -> None

Set the data path where datasets will be downloaded/cached.

Parameters:

Name Type Description Default
target_path str | Path

The file system path to store datasets.

required

Raises:

Type Description
TypeError

Path must be a string or a Path object.

ValueError

Invalid path string provided.

Source code in src/redplanet/user_config/datacache.py
def set_dirpath_datacache(target_path: str | Path) -> None:
    """
    Set the data path where datasets will be downloaded/cached.

    Parameters
    ----------
    target_path : str | Path
        The file system path to store datasets.

    Raises
    ------
    TypeError
        Path must be a string or a Path object.
    ValueError
        Invalid path string provided.
    """
    ## Input type validation && conversion to Path object
    match target_path:

        case Path():
            target_path = target_path.resolve()

        case str():
            try:
                target_path = Path(target_path).resolve()
            except Exception as e:
                raise ValueError(f'Invalid path string provided: {target_path}\n{e}')

        case _:
            raise TypeError('Path must be a string or a Path object.')

    ## Proceed
    global _dirpath_datacache
    _dirpath_datacache = target_path
    return