Skip to content
Merged
1 change: 1 addition & 0 deletions changelog.d/v2-cache-level-handlers.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The v2 report app's cache now plans, builds and looks up its files through the same level handlers as the run_simulation app, with its own list of the levels it covers (US national and state year files, and the 20 state-group baselines). Its keys, store paths, files and fixed baseline IDs are unchanged. The files now sit under `prebuilt/us/<dataset>/<state or "all">/` in the US worker image, every manifest entry records its folder, so the manifest digest changes once, and the image build checks the years and file counts the deploying machine computes from the handler settings.
20 changes: 14 additions & 6 deletions docs/migration/stage-12-modal-worker-foundation.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,20 @@ filter, and stores each state's file under the year file's own name. It
refuses data in which a household's district code names another state's
district, because district runs read their state's file.

Precompute publishes a canonical manifest containing the 63 national files and
the state datasets. The deployment passes that manifest's SHA-256 digest into
the US image build. The image build downloads and verifies every listed file,
placing each state dataset in `state-datasets/<dataset>/<state>/` under the
data folder, then records the exact cache release in worker-validation
metadata and the v2 version manifest. A state or district calculation reads
Precompute plans these files through the level handlers in
`stage12_cache/levels*.py`, which the run_simulation app also uses: the years
come from the US handler settings, the files from the handlers of the levels
`stage12_cache/cache_levels.py` lists for this cache (US national and state
year files, and the state-group baselines). It publishes a canonical manifest
containing the 63 national files and the state datasets, each entry naming the
prebuilt folder its file lands in. The deployment passes that manifest's
SHA-256 digest, and the years and counts the cache must hold
(`expected_cache_contents`), into the US image build. The image build
downloads and verifies every listed file into its folder under the data
folder: the national year files and the baselines computed on them in
`prebuilt/us/<default dataset>/all/`, and each state dataset in
`prebuilt/us/<dataset>/<state>/`. It then records the exact cache release in
worker-validation metadata and the v2 version manifest. A state or district calculation reads
its state's file when the image holds it for the requested year and .py would
reuse it, and prepares the dataset during the calculation otherwise. The UK
and coordinator images do not contain these files. Deployment validation runs
Expand Down
18 changes: 12 additions & 6 deletions projects/policyengine-simulation-executor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,15 @@ workers, its image and functions mount only the read-only
`pe-uk-private-hf-read-token` Hugging Face secret, which supplies
`HUGGING_FACE_TOKEN`, and
`stage12-evaluation-gcp-credentials`; the US data it reads comes from the
public `policyengine/populace-us` dataset repository. The US worker image
downloads and verifies the manifest's files during image construction: the 63
national files into the data folder, and each state dataset into
`state-datasets/<dataset>/<state>/` under the year file's own name. The
public `policyengine/populace-us` dataset repository. The plan comes from
the level handlers in `stage12_cache/levels*.py` and the cache's own levels in
`stage12_cache/cache_levels.py`. The US worker image downloads and verifies
the manifest's files during image construction, each into the prebuilt folder
its manifest entry names: the 63 national files into
`prebuilt/us/<default dataset>/all/`, and each state dataset into
`prebuilt/us/<dataset>/<state>/` under the year file's own name. The
deploying machine passes the image build the years and file counts to expect
(`expected_cache_contents`). The
release validation checks the recorded manifest, hashes a baseline file, and
requires a real calculation to load that file without recomputing it. Worker
validation also calculates a US household under a nonempty CTC reform using
Expand All @@ -460,8 +465,9 @@ digest is then stored in the separate v2 version manifest.

The cache is an optimization, not required state for a calculation: an absent
file causes a normal calculation, and a file missing planned output columns is
recalculated. Only empty-policy baseline region-group calculations against the
bundle's default dataset are eligible to read it. Reform calculations never
recalculated. Only empty-policy baseline calculations of a group of states against
the bundle's default dataset, at a level `cache_levels.py` lists, are eligible
to read it. Reform calculations never
read a baseline file.

## Observability
Expand Down
Loading