pycsa.compute.context¶
ComputeContext: explicit container for per-task compute resources.
Bundles the BufferPool (per-task lifetime; owned by the context) and an
accessor for the worker-local tile cache (worker-process lifetime; the
context only holds a getter). Threading a single ctx through the pipeline
makes the data flow explicit, replacing the previous pattern of implicit
BufferPool creation inside get_pmf.__init__ + module-level
tile_cache.get_worker_cache() calls scattered through do_cell.
The tile_cache field is a callable rather than the cache itself because the real cache is a per-Dask-worker singleton owned by the worker process and can’t be carried across pickle boundaries. A test can substitute a stub by passing any callable that returns a cache-like object.
Classes
|
Per-task compute resources for the CSA pipeline. |
- class pycsa.compute.context.ComputeContext(buffer_pool: ~pycsa.core.buffer_pool.BufferPool = <factory>, tile_cache: ~typing.Callable[[], ~typing.Any] | None = None, prior: ~typing.Any | None = None, selector: ~typing.Any | None = None)¶
Per-task compute resources for the CSA pipeline.
- Parameters:
buffer_pool (pycsa.core.buffer_pool.BufferPool) – Owned by the context. One
BufferPoolperComputeContext.tile_cache (Callable[[], Any] | None) – Optional callable that returns the worker-local tile cache. The cache itself is not stored (it’s owned by the Dask worker process); we hold a getter that resolves at call time. Pass
Nonefor environments that don’t need tile_cache (idealised runs, tests).prior (Any | None) – Optional
pycsa.core.priors.Priorcarried through tolin_reg.do. Spike scripts thread a structured prior here without modifying any call site.None(default) means the preserved scalar-trace branch inlin_reg.doruns unchanged.selector (Any | None) – Optional
pycsa.core.mode_selection.ModeSelectorcarried through topycsa.wrappers.interface.second_appx. Spike scripts thread an alternative selector here without modifying any call site.None(default) means the preserved inlineargmaxloop insecond_appxruns unchanged.
- buffer_pool: BufferPool¶
- classmethod default() ComputeContext¶
Production setup: fresh
BufferPool+ tile_cache accessor.Imports
pycsa.core.tile_cachelazily so callers in dependency-light environments can still construct a no-cache context via plainComputeContext().