diff --git a/altair/datasets/_cache.py b/altair/datasets/_cache.py index f9e3c683a..ce058c561 100644 --- a/altair/datasets/_cache.py +++ b/altair/datasets/_cache.py @@ -97,6 +97,8 @@ def get(self, key: _KT, default: _T) -> _VT | _T: class DatasetCache(Generic[IntoDataFrameT, IntoFrameT]): + """Optional caching of remote dataset requests.""" + _ENV_VAR: ClassVar[LiteralString] = "ALTAIR_DATASETS_DIR" def __init__(self, reader: _Reader[IntoDataFrameT, IntoFrameT], /) -> None: diff --git a/altair/datasets/_loader.py b/altair/datasets/_loader.py index 111af950b..ce2559aed 100644 --- a/altair/datasets/_loader.py +++ b/altair/datasets/_loader.py @@ -287,16 +287,22 @@ def url( """ return self._reader.url(name, suffix, tag=tag) - # TODO: Examples for tasklist @property def cache(self) -> DatasetCache[IntoDataFrameT, IntoFrameT]: """ - Dataset caching. + Optional caching of remote dataset requests. - - [x] Enable via 2 examples - - [x] Disable after enabling (self.cache.path = None) - - [ ] Pre-download missing - - [ ] Clear entire cache + Enable caching: + + self.cache.path = ... + + Download the latest datasets *ahead-of-time*: + + self.cache.download_all() + + Remove all downloaded datasets: + + self.cache.clear() """ return self._reader.cache