CachePolicy#
- class scikitplot.corpus.CachePolicy(unpinned='bypass', revision_resolver=None, max_entries=None, max_bytes=None)[source]#
How
EmbeddingEngineuses 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, emptymodel_revision) callsrevision_resolveronce per engine, then loads and keys that commit; when it fails, for another backend, or for a branch or tag given inmodel_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_revisionis 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;
Noneis unbounded.- max_bytesint or None, default=None
Most bytes kept in the cache directory;
Noneis 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:
See also
EmbeddingEngine.embed_cachedReturns the
CacheStatus.
Notes
User. A custom provider’s identity is its
custom_fn_id; a sentence-transformers model is identified by a commit inmodel_revision; another backend by anymodel_revisionyou state. Each makes the cache usable whateverunpinnedsays.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>.npyfiles 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).