deepcave.utils.run_caches

# RunCaches

This module defines a class for holding the caches for selected runs.

Utilities provided include updating, getting, setting and clearing.

## Classes
  • RunCaches: Hold the caches for the selected runs.

Classes

RunCaches(config)

Hold the caches for the selected runs.

class deepcave.utils.run_caches.RunCaches(config)[source]

Bases: object

Hold the caches for the selected runs.

The caches are used for the plugins to store the raw outputs so that raw outputs must not be calculated again.

Each input has its own cache. This change was necessary because it ensures that not all data is loaded if not needed.

Properties

cache_dirPath

The path to the cache directory of the run.

loggerLogger

The logger for the run cache.

clear()[source]

Remove all caches.

Return type:

None

clear_run(run)[source]

Remove all caches for the given run.

Return type:

None

get(run, plugin_id, inputs_key)[source]

Return the raw outputs for the given run, plugin and inputs key.

Parameters:
  • run (AbstractRun) – The run to get the results for.

  • plugin_id (str) – The plugin id to get the results for.

  • inputs_key (str) – The input key to get the results for. Should be the output from Plugin._dict_as_key.

Returns:

Raw outputs for the given run, plugin and inputs key.

Return type:

Optional[Dict[str, Any]]

Raises:

AssertionError – If the outputs of the cache are not a dict.

set(run, plugin_id, inputs_key, value)[source]

Set the value for the given run, plugin and inputs key.

Since each input key has it’s own cache, only necessary data are loaded.

Parameters:
  • run (AbstractRun) – The run to set the cache for.

  • plugin_id (str) – The plugin id to set the cache for.

  • inputs_key (str) – The inputs key to set the cache for. Should be the output from Plugin._dict_as_key.

  • value (Any) – The value to set.

Return type:

None

update(run)[source]

Update the cache for the given run. If the cache does not exists it will be created.

If the run hash is different from the saved variant the cache will be reset.

Parameters:

run (AbstractRun) – The run which should be updated.

Returns:

True if the run cache was updated.

Return type:

bool