CachePolicy#

class scikitplot.corpus.CachePolicy(unpinned='bypass', revision_resolver=None, max_entries=None, max_bytes=None)[source]#

How EmbeddingEngine uses its disk cache.

Parameters:
unpinned{“bypass”, “allow”, “resolve”}, default=”bypass”

What to do for a model not pinned to a commit (no model_revision, or a sentence-transformers branch or tag, which can move). "bypass" computes and does not cache. "allow" caches under the name given (an entry can outlive an upstream change of the model). "resolve" (sentence-transformers, empty model_revision) calls revision_resolver once per engine, then loads and keys that commit; when it fails, for another backend, or for a branch or tag given in model_revision (which is not resolved), the call bypasses the cache.

revision_resolvercallable or None, default=None

(model_name) -> commit hash; required by, and only valid with, unpinned="resolve". resolve_hub_revision is one. An answer that is not a 40- or 64-hex commit counts as a failure.

max_entriesint or None, default=None

Most entries kept in the cache directory; None is unbounded.

max_bytesint or None, default=None

Most bytes kept in the cache directory; None is unbounded.

Raises:
ValueError

On an unknown unpinned, a resolver without "resolve" (or "resolve" without one), or a bound that is not a positive int.

Parameters:

Notes

User. A custom provider’s identity is its custom_fn_id; a sentence-transformers model is identified by a commit in model_revision; another backend by any model_revision you state. Each makes the cache usable whatever unpinned says.

Developer. Eviction is least recently used: a hit refreshes the entry’s modification time, and after a store the oldest entries (ties by name) are removed until both bounds hold. Only <64 hex>.npy files are counted or removed.

Examples

>>> CachePolicy(max_entries=1000).unpinned
'bypass'
>>> CachePolicy(unpinned="resolve")
Traceback (most recent call last):
...
ValueError: CachePolicy: unpinned='resolve' requires a revision_resolver (for example resolve_hub_revision).
property bounded: bool#

Whether a bound is set (eviction runs after each store).

max_bytes: int | None = None#
max_entries: int | None = None#
revision_resolver: Callable[[str], str] | None = None#
unpinned: str = 'bypass'#