DiskCache#

Defined in: voxatlas.pipeline.cache

class voxatlas.pipeline.cache.DiskCache(cache_dir)[source]#

Bases: object

Represent the disk cache concept in VoxAtlas.

This public class exposes reusable state or behavior for the pipeline layer of VoxAtlas. It is part of the supported API surface and is intended to be composed by pipelines, registries, and feature extractors.

Parameters:

cache_dir (object) – Directory where serialized feature outputs are stored between pipeline runs.

Examples

>>> import tempfile
>>> from voxatlas.pipeline.cache import DiskCache
>>> with tempfile.TemporaryDirectory() as tmp:
...     cache = DiskCache(tmp)
...     cache.cache_dir.name != ""
True
compute_key(feature_name, audio_hash, config_hash)[source]#

Compute key from VoxAtlas inputs.

This function participates in pipeline orchestration, dependency resolution, caching, or execution. Use it to move data through the feature-centric VoxAtlas workflow without changing feature semantics.

Parameters:
  • feature_name (object) – Fully qualified VoxAtlas feature name, such as acoustic.pitch.f0.

  • audio_hash (object) – Stable hash representing the waveform payload and sampling rate for cache addressing.

  • config_hash (object) – Stable hash representing the resolved pipeline configuration for cache addressing.

Returns:

Computed value or structure produced from the supplied inputs.

Return type:

object

Examples

>>> import tempfile
>>> from voxatlas.pipeline.cache import DiskCache
>>> with tempfile.TemporaryDirectory() as tmp:
...     cache = DiskCache(tmp)
...     key = cache.compute_key("acoustic.pitch.dummy", "a" * 64, "b" * 64)
...     len(key)
64
exists(feature_name, key)[source]#

Provide the exists public API.

This function participates in pipeline orchestration, dependency resolution, caching, or execution. Use it to move data through the feature-centric VoxAtlas workflow without changing feature semantics.

Parameters:
  • feature_name (object) – Fully qualified VoxAtlas feature name, such as acoustic.pitch.f0.

  • key (object) – Cache key associated with a specific feature, audio payload, and configuration state.

Returns:

Return value produced by this API.

Return type:

object

Examples

>>> import tempfile
>>> from voxatlas.pipeline.cache import DiskCache
>>> with tempfile.TemporaryDirectory() as tmp:
...     cache = DiskCache(tmp)
...     cache.exists("acoustic.pitch.dummy", "missing")
False
load(feature_name, key)[source]#

Provide the load public API.

This function participates in pipeline orchestration, dependency resolution, caching, or execution. Use it to move data through the feature-centric VoxAtlas workflow without changing feature semantics.

Parameters:
  • feature_name (object) – Fully qualified VoxAtlas feature name, such as acoustic.pitch.f0.

  • key (object) – Cache key associated with a specific feature, audio payload, and configuration state.

Returns:

Return value produced by this API.

Return type:

object

Examples

>>> import tempfile
>>> from voxatlas.pipeline.cache import DiskCache
>>> with tempfile.TemporaryDirectory() as tmp:
...     cache = DiskCache(tmp)
...     key = cache.compute_key("acoustic.pitch.dummy", "a" * 64, "b" * 64)
...     cache.save("acoustic.pitch.dummy", key, {"value": 1})
...     cache.load("acoustic.pitch.dummy", key)
{'value': 1}
save(feature_name, key, result)[source]#

Provide the save public API.

This function participates in pipeline orchestration, dependency resolution, caching, or execution. Use it to move data through the feature-centric VoxAtlas workflow without changing feature semantics.

Parameters:
  • feature_name (object) – Fully qualified VoxAtlas feature name, such as acoustic.pitch.f0.

  • key (object) – Cache key associated with a specific feature, audio payload, and configuration state.

  • result (object) – Computed feature output object to store, cache, or return to callers.

Returns:

Return value produced by this API.

Return type:

object

Examples

>>> import tempfile
>>> from voxatlas.pipeline.cache import DiskCache
>>> with tempfile.TemporaryDirectory() as tmp:
...     cache = DiskCache(tmp)
...     key = cache.compute_key("acoustic.pitch.dummy", "a" * 64, "b" * 64)
...     cache.save("acoustic.pitch.dummy", key, {"value": 1}) is None
True
>>> with tempfile.TemporaryDirectory() as tmp:
...     cache = DiskCache(tmp)
...     key = "k"
...     cache.save("acoustic.pitch.dummy", key, 123)
...     cache.exists("acoustic.pitch.dummy", key)
True