Skip to main content

wave_cache_lifetime

The lifetime of a background wave's decoded-record cache.

The executor opens one WaveDecodedCache per wave of a background run, or one for the whole of an unwaved background run, and makes it the wave's cache (wave_cache_scope) for every step the wave runs. A step reads from it and stores into it only inside wave_cache_consumer, which model_inference_task alone enters, on its own thread; any other step, such as an EHR step reading through the same datasource, bypasses it. The cache is closed and its directory deleted however the wave ends. Interactive runs, and datasources that have not opted in to the cache, get none.

Opening and closing touch the filesystem, so both run off the event loop. Neither they nor the wave_decoded_cache report they end in can fail the wave.

Module​

Functions​

wave_cache_lifetime​

async def wave_cache_lifetime(    dag: BackgroundDAG | InteractiveDAG,    run_ctx: DAGRunContext,    *,    wave_index: int | None = None,    wave_kind: str | None = None,) ‑> AsyncGenerator[WaveDecodedCache | None, None]:

Hold a decoded-record cache open, as the wave's cache, for the block.

A cache is opened only for a BackgroundDAG, with background_wave_cache_enabled on, and when the run carries a datasource runtime parameter whose _decoded_record_fingerprint() is not None (a datasource that has opted in); the cache is bound to that datasource. Otherwise nothing is opened, touched or reported, and the block runs with None.

A cache that cannot open is reported (outcome="unavailable") and the block runs with None. An open cache is the wave's cache for the block, and is closed, its directory deleted and its report sent when the block ends, by any route. Reports carry wave_index and wave_kind in their telemetry context when given.

Nothing from opening, closing or reporting escapes; an exception from the block propagates unchanged.

Arguments

  • dag: The DAG being run.
  • run_ctx: The run context, carrying the datasource.
  • wave_index: The wave the cache is for, or None for an unwaved run.
  • wave_kind: The wave's kind, or None for an unwaved run.