Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 21 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ version 2 staging run files to `policyengine/populace-uk-staging` under the
same switch. The build command also **stages the finished dataset bundle** it built,
national, dense or exact-count, under `staged/<run_id>/` in the
private `policyengine/populace-uk-private` repository so the team can inspect
it without publishing it (the build's emitter uploads it): `releases/` and `latest.json` are untouched, the
it without publishing it (the build's emitter uploads it): `releases/` and `releases.json` are untouched, the
release contract is not consulted, and a `releasable: false` size run stages
like any other. Fetch a bundle with `tools/fetch_uk_staged_dataset.py`;
re-stage a finished run directory with `tools/stage_uk_rowwise_candidate.py`.
Expand Down Expand Up @@ -741,101 +741,24 @@ of an ACS local-area build publishes into `microcosm-us-2024-local-annual`,
carrying its base local build's files
([the local projection guide](docs/us-local-annual-projection.md)).

**The switch.** `microcosm.build.build_folder_switch` moves a repository over,
once, in two steps, and a third step later deletes what the old layout left
on `main`. Each step only reads the repository and prints, as JSON, what it
would do, unless given `--write`:

```bash
# 1. Copy each tagged build, and each untagged folder --include-untagged
# names, into its folder, one commit per build; run it again later to
# copy builds published since. Hugging Face copies the large (LFS) files
# on its own servers.
uv run python -m microcosm.build.build_folder_switch copy <owner/repository> \
[--include <tag>=<release>] [--exclude <tag>] \
[--include-untagged <folder>=<release>] [--write]
# 2. In one commit, write releases.json and delete every latest*.json file.
uv run python -m microcosm.build.build_folder_switch switch <owner/repository> \
[--include <tag>=<release>] [--exclude <tag>] \
[--include-untagged <folder>=<release>] [--retire-pointer <latest file>] [--current <release>=<build>] \
[--default <release>] [--finished-branch <release-staging/ branch>] [--write]
# 3. Later, in one commit, delete the old layout's files from main.
uv run python -m microcosm.build.build_folder_switch delete-old-layout \
<owner/repository> [--write]
```

Run the switch step only while nobody publishes to the repository, and give
it the same `--include`, `--exclude` and `--include-untagged` options as the
copy step.

The copy step moves every tag of a release that publishes into build folders
whose manifest names that tag, and each release-per-build tag that
`--include` names (the June 2023 UK release, or a US release), and refuses a
build any of whose files does not match its manifest, or whose release, build
or role the emitter interface refuses; it reports both without `--write`. It
also copies the files a build's checksum ledger records but its manifest
doesn't declare (each US ACS local-area build has six), checked against the
ledger, and a manifest that declares its own `build_manifest.json` (the US
SPM builds') declares the rewritten one.

A build with no tag, as BE's builds are stored, is an untagged folder
`releases/<folder>/` on `main` holding its files directly, and moves only
when `--include-untagged <folder>=<release>` names it; its build is then
`<folder>`. The copy step copies every file the folder holds from the commit
that last changed it, and rewrites the two manifests as for a tagged build.
The release manifest's `artifacts` then lists exactly the files the folder
holds besides the manifests, and keeps the map it had, which may declare
files of the builder's output directory that the folder doesn't hold,
unchanged as `unpublished_artifacts`. Its `migrated_from` names the old
folder, that commit and the old manifest's SHA-256, and the build's
`published_at` is that commit's date. The copy step refuses a folder that is
also a tag, a release named like a folder `--include-untagged` moves, a
folder holding a checksum ledger, a subfolder or nothing but its manifests,
two files whose names give one artifact name, a folder from which a file was
deleted after the commit that last changed the files it holds, and a
manifest with no `build` object, whose `build.build_id` is not the folder's
name or that names a tag (`build.cut_tag`). A `latest.json` with no `revision` names such a folder by its
`release_id`, and its build becomes current.

The switch refuses unless every such build's folder holds exactly its copied
files, every pointer file's build moves or `--retire-pointer` deletes that
pointer file, no other build folder is on `main`, the repository's tags did
not change while it read them, no `release-staging/` branch shows a tagged
publication in progress, and the emitter interface's checks pass. A
`release-staging/` branch that a finished publication left behind is
accepted when `--finished-branch` names it, its build is tagged and the commit
it names is on `main`; the branch stays where it is. The publisher makes no
branch for a build that is already tagged, but one older than 2026-09-23
(`7053b9173`) did when retrying such a build, which looks the same while it
runs (the US leftover branch is one), so name a branch only while nobody
publishes. Each build keeps the date of its
tagged commit as `published_at` (an untagged build, the date of the commit
that last changed its old folder), and each pointer file's build becomes its
release's current build.

After the switch, `main` still holds the tagged layout's files: those each
tagged build overwrote directly in `releases/<release>/`, each
release-per-build tag's `releases/<tag>/` folder (every US build, the June
2023 UK build and builds the switch did not move), each untagged folder
`releases/<folder>/` (BE's builds), and the dataset files
(`.h5`, `.hdf5`, `.npz`) at the repository's root. The `delete-old-layout`
step deletes all of them in one commit, so build folders and `releases.json`
are the only layout. It keeps `releases.json`, every build folder it lists,
the other root files (`.gitattributes`, `README.md`) and every directory
outside `releases/`, such as the UK repository's `staged/`. It refuses a
repository without `releases.json` or with a `latest*.json` file, and a build
folder `releases.json` does not list, which it never deletes. It runs the
emitter interface's repository check on what remains, and takes none of the
other steps' options. Every tagged build stays readable at its tag, which is
where Microcosm's tag references read it, and every deleted file stays in
`main`'s history at the head the report names; the report lists any deleted
release-per-build or untagged folder that no tag names (`untagged_folders`). Anything
that reads those paths from `main` stops finding them, so run it only once
nothing does (the example notebook reads the US dataset through
`releases.json`).
The commit removes the files from `main` only: their large (LFS) objects stay
in the repository's history. A second run finds nothing to delete. The
module's docstring describes all three steps in full.
**The switch.** The US, UK and BE repositories each moved once from tags
and `latest*.json` pointer files to build folders, with a one-time tool. It
copied each build into its folder, then in one commit wrote `releases.json`
and deleted every pointer file, and later deleted the old layout's files
from `main`: the files each tagged build overwrote directly in
`releases/<release>/`, each release-per-build or untagged folder
`releases/<folder>/`, and the dataset files (`.h5`, `.hdf5`, `.npz`) at the
repository's root. The tool was removed once BE had moved; its last version
is in Git history at `d3b7f4b4a`. Build folders and `releases.json` are now
the only layout on each repository's `main`. Every tagged build stays
readable at its tag, which is where Microcosm's tag references read it, and
every deleted file stays in `main`'s history, with its large (LFS) objects.
A moved build's release manifest names where it came from in
`migrated_from`: its tag, or BE's old untagged folder, with the commit it
was copied from and the SHA-256 of the manifest it was rewritten from. A
moved BE build's folder holds no dataset; its manifest lists the files the
folder holds and keeps its old `artifacts` map as `unpublished_artifacts`
([the release contract](docs/release-contract.md), C1).

`microcosm-publish-release-build` publishes only the two manifests, the
artifacts the release manifest declares and the checksum ledger. The US
Expand Down Expand Up @@ -964,10 +887,8 @@ with the evidence contract, which refuses a build in the certified shape; the
certified contract refuses the evidence shape, so an evidence build can't be
published into the national release. The evidence release is never the
repository's default, so `microcosm.data.load("us")` never loads its builds.
Its current build in `releases.json` takes the place of `latest-evidence.json`.
The US switch deleted every `latest*.json` file, so
`microcosm.data.latest_evidence_release`, which still reads
`latest-evidence.json`, finds no pointer in the US repository.
Its current build in `releases.json` took the place of `latest-evidence.json`,
which the US switch deleted with every other `latest*.json` file.

No release command posts a Slack alert: `microcosm-publish-release-build`
sends none, and the calibration diagnostics dashboard posts release alerts
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1792-remove-build-folder-switch.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the one-time build-folder switch tool, `microcosm.build.build_folder_switch`, with its `copy`, `switch` and `delete-old-layout` steps and its tests (#1792). The US, UK and BE release repositories have all moved to build folders and `releases.json` and had their old layout deleted, so nothing is left for it to move. `microcosm-publish-release-build`'s refusal for a repository that has pointer files and no `releases.json` no longer tells the operator to run it. The tool's last version is in Git history at `d3b7f4b4a`.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop reading and writing `latest*.json` pointer files (#1794): every release repository lists its builds in `releases.json`, and each repository's switch deleted its pointer files. The loader refuses a repository without `releases.json`, online and offline, instead of following `latest.json` or a UK release's `latest-<name>.json`; `load()` loses its `unverified_root` option, since no repository holds a root dataset file; `DatasetSpec` loses `pointer_path` and must name its `release`. `microcosm.data` and `microcosm.data.release` no longer have `latest_release`, `latest_line_release`, `latest_evidence_release`, `LatestPointer`, the pointer payload builders, `line_pointer_path` or the pointer constants, and `microcosm.data.contract` no longer has `line_for_release_id` or `dataset_role_for_line`. `microcosm-publish-release-build` still refuses a repository that has a pointer file, now with one message for any repository: remove the file. AM's and NZ's release contracts name build folders and `releases.json` instead of `latest.json`. A caller of a removed reader now fails at import, for example PolicyEngine/bottom-50-tax-analysis's call of `latest_release`, which already failed because no repository has `latest.json`.
13 changes: 7 additions & 6 deletions docs/agent-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,11 @@ package stage prints both commands itself.
`tools/preflight_us_release_gates.py` runs the US national release checks that
need no calibration on the base before a build, and again with the finished
build's `--release-manifest`. The emitter changes
no current build while any `latest*.json` pointer file exists; the UK and US
repositories' switches to `releases.json` deleted them. No release publishes
with tags: the tagged publisher (`microcosm-publish-release`) has been
removed, and `microcosm-publish-release-build` takes only the releases that
no current build while any `latest*.json` pointer file exists; each
repository's switch to `releases.json` deleted them, and Microcosm neither
reads nor writes them. No release publishes with tags: the tagged publisher
(`microcosm-publish-release`) has been removed, and
`microcosm-publish-release-build` takes only the releases that
`publishes_to_build_folder` names. The UK repository's switch moved the June
2023 UK build into release `populace-uk-2023`, which takes no new builds, and
`populace-uk-<year>-<tier>-k<N>` releases have no publication path. Tests hand release changes to the
Expand All @@ -414,8 +415,8 @@ a `--publish` that publishes the build through the emitter
(`microcosm-publish-release-build`) without making it current. Never publish or promote artifacts as a side
effect of another task. A UK rowwise run's **staged** bundle
(`staged/<run_id>/` in the private repository, written by the build itself)
is inspection evidence, not a release: it never moves `releases/` or
`latest.json` and is not loadable through the certified loader. The build's
is inspection evidence, not a release: it never changes `releases/` or
`releases.json` and is not loadable through the certified loader. The build's
default is to upload that bundle (hundreds of megabytes of licensed microdata)
to the private repository; when you run `microcosm-build-uk`
(`tools/build_uk_full.py`, or its stub `tools/build_uk_rowwise_candidate.py`)
Expand Down
5 changes: 3 additions & 2 deletions docs/armenia-country-package-814/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ candidate release.
The public release must carry the country-neutral `source_coverage.json`
contract tracked by `microcosm#265`, plus calibration diagnostics, validation
bands, build/release manifests, and an explicit donor-provenance banner.
`latest.json` is an atomic pointer uploaded last; nothing in this spec-only
package publishes an artifact.
Each build is to publish into its own folder, `releases/<release>/<build>/`,
which `releases.json` lists, as the release contract says; no pointer file
names a build. Nothing in this spec-only package publishes an artifact.

## Amount and currency boundary

Expand Down
Loading
Loading