cacheables package¶
Subpackages¶
- cacheables.caches package
- Submodules
- cacheables.caches.base module
BaseCacheBaseCache.adopt()BaseCache.clear()BaseCache.dump_metadata()BaseCache.evict()BaseCache.exists()BaseCache.get_last_accessed()BaseCache.get_output_path()BaseCache.list()BaseCache.load_metadata()BaseCache.read()BaseCache.read_output()BaseCache.update_last_accessed()BaseCache.write()BaseCache.write_output()
- cacheables.caches.disk module
- Module contents
- cacheables.serializers package
Submodules¶
cacheables.cli module¶
- cacheables.cli.load_function_from_qualified_name(qualified_name) CacheableFunction¶
Load a Python function from a given a qualified name.
cacheables.controllers module¶
- class cacheables.controllers.CacheController¶
Bases:
object- disable() AbstractContextManager[None]¶
- enable(read: bool = True, write: bool = True, filter: ~typing.Callable | None = <function CacheController.<lambda>>) AbstractContextManager[None]¶
- is_passing_filter(output: Any) bool¶
- is_read_enabled() bool | None¶
- is_write_enabled() bool | None¶
- class cacheables.controllers.GlobalCacheController¶
Bases:
object- disable() AbstractContextManager[None]¶
- enable(read: bool = True, write: bool = True) AbstractContextManager[None]¶
- is_read_enabled() bool | None¶
- is_write_enabled() bool | None¶
- cacheables.controllers.disable_all_caches() AbstractContextManager[None]¶
- cacheables.controllers.enable_all_caches(read: bool = True, write: bool = True) AbstractContextManager[None]¶
cacheables.core module¶
- class cacheables.core.CacheableFunction(fn: Callable, function_id: str | None = None, cache: BaseCache | None = None, serializer: BaseSerializer | None = None, key_builder: Callable | None = None)¶
Bases:
object- adopt_cache(function_id: str) None¶
- clear_cache() None¶
- disable_cache() AbstractContextManager[None]¶
- dump_output(output: Any, input_id: str) None¶
- enable_cache(read: bool = True, write: bool = True, filter: Callable | None = None) AbstractContextManager[None]¶
- get_function_id() str¶
- get_input_id(*args, **kwargs) str¶
- get_output_id(output: Any) str¶
- get_output_path(input_id: str) str¶
- load_metadata(input_id: str) dict¶
- load_output(input_id: str) Any¶
cacheables.decorator module¶
- cacheables.decorator.cacheable(_fn: Callable | None = None, function_id: str | None = None, cache: BaseCache | None = None, serializer: BaseSerializer | None = None, key_builder: Callable | None = None) Callable[[Callable], CacheableFunction]¶
cacheables.exceptions module¶
- exception cacheables.exceptions.CacheNotEnabledError¶
Bases:
Exception
- exception cacheables.exceptions.DumpException¶
Bases:
Exception
- exception cacheables.exceptions.InputKeyNotFoundError¶
Bases:
Exception
- exception cacheables.exceptions.LoadException¶
Bases:
Exception
- exception cacheables.exceptions.ReadException¶
Bases:
Exception
- exception cacheables.exceptions.WriteException¶
Bases:
Exception
cacheables.keys module¶
- class cacheables.keys.InputKey(function_id: str, input_id: str)¶
Bases:
object- function_id: str¶
- property function_key: FunctionKey¶
- input_id: str¶
- cacheables.keys.create_key_builder(exclude_args_fn: Callable[[str], bool] | None = None) Callable[[Callable, tuple, dict], str]¶
Create a key builder function that generates input_id from function arguments.
- Args:
exclude_args_fn: Function to determine which arguments to exclude (defaults to excluding args starting with “_”)
- Returns:
A key builder function with signature (fn, args, kwargs) -> str (input_id)
- cacheables.keys.default_key_builder(fn: Callable, args: tuple, kwargs: dict) str¶
Generate input_id from function arguments.
- cacheables.keys.safe_lru_cache(maxsize=128, typed=False)¶
A safe version of lru_cache that falls back to executing the wrapped function if the arguments are unhashable. Original lru_cache would raise a TypeError in this case.
cacheables.logging module¶
- cacheables.logging.disable_logging()¶
- cacheables.logging.enable_logging(level: str = 'DEBUG')¶
cacheables.metadata module¶
- cacheables.metadata.create_metadata(input_id: str, output_id: str, serializer_metadata: dict) dict¶