Skip to content

Commit

Permalink
docs: Finish Loader.cache
Browse files Browse the repository at this point in the history
Not using doctest style here, none of these return anything but I want them hinted at
  • Loading branch information
dangotbanned committed Nov 24, 2024
1 parent 71423ea commit 7dd9c18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions altair/datasets/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 12 additions & 6 deletions altair/datasets/_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7dd9c18

Please sign in to comment.