caching

This file contains utilities that are useful for caching

tensiometer.utilities.caching.cache_input(func, check_input=True)[source]

Cache a function’s positional and keyword arguments on disk.

The decorator expects cache_dir and root_name keyword arguments on the wrapped function. It persists the arguments to <cache_dir>/<root_name>_function_cache.plk and reloads them on subsequent calls, optionally validating they match the current inputs.

Parameters:
  • func – function to decorate.

  • check_input – whether to verify cached inputs match current values.

Returns:

wrapped function that reuses cached arguments when available.

Raises:

ValueError – if required cache kwargs are missing or inputs differ from the cached values when check_input is True.