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
115 changes: 20 additions & 95 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -741,101 +741,26 @@ 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 to build
folders, with a one-time tool: the US and UK repositories' builds from tags,
BE's from untagged folders on `main`, and all three from `latest*.json`
pointer files. It copied each build it moved 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
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`.
50 changes: 27 additions & 23 deletions docs/release-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,12 @@ national line's tagged `build_id` held the release's name and `attempt_id` and
its top level. Each artifact carries its role. No artifact pins a revision,
because `releases.json` and the folder locate a build's files. Both layouts
carry `schema_version` 1, and `publishes_to_build_folder` tells them apart. A
build that the switch tool (`microcosm.build.build_folder_switch`) moved from
its tag also carries `migrated_from`, which names the tag, its commit and the
SHA-256 of the manifest the tool rewrote. A build it moved from an untagged
folder on `main` (`--include-untagged`, for BE's builds) carries instead the
old folder, the commit that last changed it and that SHA-256. Its `artifacts`
build that the one-time switch tool moved from its tag also carries
`migrated_from`, which names the tag, its commit and the SHA-256 of the
manifest the tool rewrote. The tool was removed once the US, UK and BE
repositories had moved; its last version is in Git history at `d3b7f4b4a`. A
build it moved from an untagged folder on `main` (BE's builds) carries
instead the old folder, the commit that last changed it and that SHA-256. Its `artifacts`
lists the files its folder holds, each with its `path`, `repo_id`, `role` and
`sha256` but no `kind`, and `unpublished_artifacts` keeps, unchanged, the map
the old manifest had, which declares files of the builder's output directory
Expand All @@ -307,7 +308,7 @@ tagged-shape manifests in a directory named after the release and then call
both manifests in place. The US annual assembler copies its base build's two
manifests, changes `release` and `build` in both, drops `migrated_from`, and in
the release manifest adds the annual metadata and an artifact for each file the
projection adds. The switch tool rewrites the manifests of the builds it moves.
projection adds. The switch tool rewrote the manifests of the builds it moved.

The **certification** is UK-only. The validator requires
`release_certification.json` of `microcosm-uk-2024-25-national`. Whatever its
Expand Down Expand Up @@ -985,20 +986,19 @@ repository that has no `releases.json`.
listed release or `null`) and `releases`; for each release its `role`, its
`current` build or `null`, and each build's `published_at` and `withdrawn`;
a current build that the record lists and has not withdrawn; at most 4 MiB.
The record carries no country, vintage or line. The one-time `switch` step
of `microcosm.build.build_folder_switch` writes a repository's first record
itself and deletes the repository's `latest*.json` files in the same
commit; after that only the emitter's release writer changes the record.
The switch's `copy` step moves each tagged build into a folder and rewrites
its manifests, as C1 describes. Its `delete-old-layout` step then deletes,
in one commit, the files the tagged layout leaves on `main`: every file
The record carries no country, vintage or line. The one-time switch tool's
`switch` step wrote the first record of each of the US, UK and BE
repositories itself and deleted the repository's `latest*.json` files in
the same commit; after that only the emitter's release writer changes the
record. Before it, the tool's `copy` step moved each build into a folder and
rewrote its manifests, as C1 describes. Its `delete-old-layout` step then
deleted, in one commit, the files the old layout left on `main`: every file
under `releases/` outside a build folder, and every dataset file (`.h5`,
`.hdf5`, `.npz`) at the repository's root. It keeps `releases.json`, every
`.hdf5`, `.npz`) at the repository's root. It kept `releases.json`, every
build folder the record lists, the other root files and every directory
outside `releases/`, and it refuses a repository without `releases.json`,
one that still has a `latest*.json` pointer file, and a build folder the
record does not list. Each tagged build stays readable at its tag, and each
deleted file stays in `main`'s history.
outside `releases/`. Each tagged build stays readable at its tag, and each
deleted file stays in `main`'s history. The tool was removed once BE had
moved.
- **The pointer files.** Nothing writes a pointer file. The tagged publisher,
`microcosm-publish-release`, which uploaded a tagged build's files, created
its immutable tag and wrote `latest.json` or `latest-evidence.json` last, has
Expand All @@ -1014,7 +1014,8 @@ repository that has no `releases.json`.
(`latest_line_release`) only for an entry whose repository has no
`releases.json`. `latest_evidence_release` returns the evidence release's
current build from `releases.json` where the file exists, and reads
`latest-evidence.json` otherwise. The switch reads the pointer files once, to
`latest-evidence.json` otherwise. Before it was removed, the one-time switch
tool was a fourth reader: it read each repository's pointer files once, to
set each release's current build and the record's `default`.
- **The registry.** `microcosm.data.registry.REGISTRY` maps `(country, year,
variant)` to a `DatasetSpec`. Each names the Hub repository, the dataset
Expand Down Expand Up @@ -1149,9 +1150,12 @@ work.
`tools/certify_uk_cut_in_policyengine_py.py` certifies a UK build only
from its folder (#1762).
- *The default.* The loader takes each country's default release from the
registry. `releases.json` also names a `default`: in this repository only
the switch tool sets it, and no loader reads it. The gap: no check at
publication confirms that the record's `default` agrees with the registry.
registry. `releases.json` also names a `default`: the one-time switch
tool set it once in each of the US, UK and BE repositories, nothing in
this repository sets it in a live record now (the fixture generator sets
it only in the C5 golden records), and no loader reads it. The gap: no check at
publication confirms that the record's `default` agrees with the registry,
and nothing here sets it for a new repository, such as AM's or NZ's.
- *The evidence release.* Its builds answer to
`validate_evidence_release_dir` and fail C1 by design. The
[retire list](#retire-list-as-of-2026-10-15) names it as an exception:
Expand Down Expand Up @@ -1320,7 +1324,7 @@ with the interface's own functions, in the order a repository lives it.
`add_build(make_current=False)` lists the build, as a publication does.
`make_current` makes it current, as a promotion does.
`dataclasses.replace(default=...)` then names the national release as the
record's `default`, as the switch tool's `_switch_record` does; interface
record's `default`, as the one-time switch tool did; interface
0.14.0 has no function that sets `default`. `ReleasesRecord.serialize` writes
the bytes. Each release takes the role `national`: the UK's from
`RELEASE_ROLES` and the national line's dataset role, the US's from
Expand Down
Loading
Loading