Cache
- exception grapheval.cache.CacheException
- class grapheval.cache.FileCache(cache_dir='.', cache_name='')
Provides methods for caching and restoring with pickle.
- cache_path(name)
- exists(name)
Return True if the is cached data existing under name, else return False.
- get(name, callback, clear)
in-place caching: looks for an existing cache file under name and loads it. If it is not existing, callback is executed, the return value is cached in this file and returned.
clear overrides this behaviour: if set to true, the potentially existing cache file is ignored and overriden after regeneration via callback
- load(name, loglevel=10)
Load the data cache under the given name. Throw an CacheException if no cache called name can be found.
- store(name, data, loglevel=10)
Store the given data under name, potentially overriding existing data
- class grapheval.cache.KwargsCacheMixin
- kwargs_changed(name, kwargs)
Return True if the cached kwargs differ from the kwargs that have been stored
Return False if they are the same.
If no kwargs can be cached (NodeCache not supporting it) always return False
- load_kwargs(name)
It is not advised to use this method, even if it is in priciple useful. You should only use
store_kwargs()
andkwargs_changed()
. Especially for comparing an possibly different kwargs use the latter method instead of this method and a manual comparison.
- replace_kwargs_item(item)
If any possible content type of a kwargs dict (or sub-lists/dicts) is not cacheable by the class using this mixin, override this method so that those objects get overriden with some (arbitrary) placeholder.
If not overridden nothing happens.
- store_kwargs(name, kwargs)
Store the new kwargs (overriding the old)
- class grapheval.cache.NodeCache
Handles caching of data calculated by nodes (not yet: and tracks nodes that were already evaluated)
- abstract exists(name)
Return True if the is cached data existing under name, else return False.
- abstract get(name, callback, clear)
in-place caching: looks for an existing cache file under name and loads it. If it is not existing, callback is executed, the return value is cached in this file and returned.
clear overrides this behaviour: if set to true, the potentially existing cache file is ignored and overriden after regeneration via callback
- abstract load(name)
Load the data cache under the given name. Throw an CacheException if no cache called name can be found.
- abstract store(name, data)
Store the given data under name, potentially overriding existing data
- class grapheval.cache.PickleNodeCache(*args, **kwargs)
Provides methods for caching and restoring with pickle.
- replace_kwargs_item(item)
If any possible content type of a kwargs dict (or sub-lists/dicts) is not cacheable by the class using this mixin, override this method so that those objects get overriden with some (arbitrary) placeholder.
If not overridden nothing happens.