Repository navigation
Move a dataset repository's tagged builds into build folders and write releases.json in one commit (P3) - #1534
Merged
Merged
Conversation
…1533) The tests run the tool's copy and switch steps against a fake of the Hugging Face calls, laid out as the UK private repository is before its switch: a June 2023 release-per-build release that latest.json names, with a metadata object both at its top level and in its build object; two tagged national builds; and a tag-only dense build with a checksum ledger, whose tag is annotated, so the Hub lists its tag object's ID. The tool is a stub here, so every test fails on its assertions; the next commit adds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`python -m microcosm.build.build_folder_switch` is the one-time switch from tags and latest*.json pointer files to build folders and releases.json. - `copy` adds each tagged build's folder, releases/<release>/<build>/, in one commit per build: the two manifests rewritten in the build-folder layout with `migrated_from` naming the tag, its commit and the original manifest's SHA-256, the checksum ledger rewritten to match, and every other declared file copied from the tagged commit on the Hub's servers after its SHA-256 is checked. A field the build object and the top level both have becomes one object when they do not disagree, as the June 2023 UK release's two metadata objects do. Each tag is resolved to its commit, since the Hub lists an annotated tag with its tag object's ID. - `switch` writes releases.json and deletes every pointer file in one commit. Each build keeps its tagged commit's date as published_at, each pointer file's build becomes current, and default is the release of latest-national.json's build, else latest.json's. It refuses unless each folder holds exactly its copied files with the SHA-256 values the tag recorded, every pointer file is accounted for, and the emitter interface's checks pass. Both steps only read and report without --write, refuse to run offline, and commit with the head they checked as the parent commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
After the UK switch, publish UK national, dense and local-area builds only through the emitter
#1537
Merged
The copy step must report a release name or role the emitter interface refuses in its read-only run and refuse it before any commit. The switch must refuse a build folder on main that its record would not list, and a tag that appears while it reads the builds. Also cover --default, a --current that conflicts with a pointer file, and TRANSFORMERS_OFFLINE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tags (#1533) From review round 1. The copy step now builds the record its moving builds make and runs the emitter interface's checks on it and on each copy commit in its read-only run, so a release name or role the interface refuses is a reported problem before any folder is written, instead of a refusal or a traceback after earlier builds were committed. The switch refuses a build folder on main that its record would not list, and reads the tags again just before its commit, refusing if they changed, since a tag-only publication never moves main and parent_commit would not notice it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1533) The tagged publisher checks for releases.json only when it starts, then keeps a release-staging/<release> branch from before its upload until after it tags the build. A switch committed in that time would leave the build in neither the record nor a folder, so the switch must refuse while such a branch exists, at its first read and just before its commit. The fake repository lists branches as the Hub does. The other new tests pass already: the second tag listing also refuses a deleted or moved tag, the unlisted-folder refusal also covers a tag copied earlier and left out with --exclude, a read-only copy reports a release role conflict, and the tool's build-folder rule matches the interface's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The switch now reads the tagged publisher's release-staging/ branches with the tags, in one listing, both at its first read and just before its commit, and refuses while any exists: a publication that has checked for releases.json but not yet tagged its build would otherwise land in neither the record nor a folder. A branch left by a failed publication must be deleted first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The module docstring and README now say to run the switch step only while nobody publishes, and why the staging-branch check leaves a small gap. The README's synopsis of the switch step gains --exclude, which it needs whenever the copy step used it. The docstring, README and changelog say that the Hub copies LFS files on its own servers, while huggingface_hub downloads a small regular file and sends it in the commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Just before its commit, the switch lists the refs and then resolved each tag with a request of its own, so a tag made or deleted between those requests could escape the comparison, and one deleted there ended the step in a traceback. The new test fails while any request follows that listing. A tag the Hub lists as annotated gets a new tag object ID when it moves, as git's does, which the fake now models; the moved-tag test covers a lightweight and an annotated tag. Another test checks that branches other than the tagged publisher's release-staging/ ones do not refuse the switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The switch's survey keeps the ID the Hub lists for each tag beside the commit it resolves to, and just before its commit it compares a fresh listing's IDs with those, in one request, instead of resolving every tag again. A tag that moves gets another listed ID, an annotated one through its new tag object, so the comparison still sees it, and nothing between the listing and the commit can now fail on a deleted tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1533. This is plan item P3 (tracker 2c · 1): the one-time tool that moves a dataset repository from tags and
latest*.jsonpointer files to build folders andreleases.json. Running it on the UK repository is a separate manual step (tracker 2c · 3 and 2c · 4), not part of this PR.Based on
mainatf85c46970.What changes
microcosm.build.build_folder_switch(new)Run it as
uv run python -m microcosm.build.build_folder_switch <step> <owner/repository> [options]. Both steps read the repository and print, as JSON, what they would do; they change nothing without--write.copy: one commit per build, addingreleases/<release>/<build>/.<release>-<YYYYMMDDTHHMMSSZ>-<8 hex digits>of a release thatpublishes_to_build_foldernames, whose release manifest'sbuild.cut_tagis that tag. Its build is the manifest'sbuild.attempt_id.--exclude TAGleaves one out.--include TAG=RELEASEnames (the June 2023 UK release, or a US release later). Its build is the tag, inRELEASE.repo_info(revision=<tag>). The Hub lists an annotated tag with the ID of its tag object, not its commit: two UK tags are annotated,microcosm-uk-2024-25-dense-20261026T105309Z-c9df4b86among them.releaseandbuildas strings;buildobject'sbuilt_atand built-with packages at the top level;roleon each artifact (release_artifact_role), its bare file name aspath, and norevision;migrated_from: the tag, its commit and the original manifest's SHA-256.buildobject and the top level have must be equal, or be two objects that do not disagree on any field; then they become one object. The June 2023 release has ametadataobject in both places, with different fields.releaseandbuildand withoutbuild_id,attempt_idorcut_tag.CommitOperationCopy, so the Hub copies it on its own servers. Each file's SHA-256 at the tag (from the Hub's LFS information, or by reading a small file) must match the manifest.releases.json, so the repository keeps publishing through its pointer files until the switch.switch: one commit that writesreleases.jsonand deletes everylatest*.jsonfile.published_at.current.defaultis the release oflatest-national.json's build, or else oflatest.json's;--defaultoverrides it.--current RELEASE=BUILDsets a current build where no pointer file names one.migrated_from, and every declared file atmain's head has the SHA-256 it had at the tag. The rewritten bytes are not compared, so a folder copied by an earlier version of the tool still counts.--retire-pointer PATHdeletes it with nothing in its place. A pointer may name an included build's release by its old name, the tag.mainthat the record would not list.release-staging/branch at either time: the tagged publisher keeps one from before it uploads a build until after it tags it. The step runs only while nobody publishes; the remaining gap is a publication that checks forreleases.jsonjust before the switch commit and makes its branch after the switch's last read.check_change,check_repositoryandcheck_commit.check_commitis given the files that remain once the pointer files are deleted: the emitter's release writer refuses to changecurrentwhile a pointer file exists, so the tool makes this one commit through its own write path.parent_commit;releases.json;HF_HUB_OFFLINEorTRANSFORMERS_OFFLINEset;HF_TOKEN, thenHUGGINGFACE_TOKEN, then the savedhf auth login.Tests and fixture
test_support/microcosm_build/build_folder_switch.pyholdsFakeDatasetRepository, an in-memory fake of theHfApicalls the tool makes. It applies the realhuggingface_hubcommit operations and refuses a staleparent_commit.uk_repository()lays it out as the UK private repository is before its switch:latest.jsonnames, with bothmetadataobjects;latest-national.jsonnames the older;packages/microcosm-build/tests/engine_free/uk/test_build_folder_switch.pyhas 47 tests (38 node IDs). An autouse fixture setsHF_HUB_OFFLINE=1and fails any test in which the tool builds a Hub client.Docs
README.md: a paragraph on the switch under "Build folders, after a repository's switch".changelog.d/1533-build-folder-switch-tool.added.md.Checked against the UK repository (read only, nothing written)
I ran both steps without
--writeagainstpolicyengine/populace-uk-privateatmain2874b672, with a read-only token, adding--include populace-uk-2023-dd68c73-4aa4b14-20260619T023711Z=populace-uk-2023.copyexits 0:populace-uk-2023-72aeefc-20260611, whose manifest has the older format with nobuildobject;switchrefuses only with "run the copy step first", once for each of the 18 builds. The record it would write:default:microcosm-uk-2024-25-national;microcosm-uk-2024-25-national: 12 builds, currentuk-frs-calibration-attempt-20261025T091414Z-a6299504, the onelatest-national.jsonnames;microcosm-uk-2024-25-dense: 5 builds, currentnull;populace-uk-2023: 1 build, current;latest-national.jsonandlatest.json._certified_release_from_manifestaccepted the rewritten release manifest from its folder. The interface'scheck_repositoryfound no violations.metadataobjects made the rewrite refuse that build;published_atfailed.Red-green
Each run selects the 24 tests by node ID (listed below), with
HF_HUB_OFFLINE=1.5f44b0905adds the tests and the fake, with the tool as a stub that keepsmainand_default_api: 24 failed, every one on an assertion.768890d09adds the tool: 24 passed.Before those commits, the first draft of the tool, which had never been reviewed, failed 7 of the 24 tests that model the real repository; the fixes above are in
768890d09.Review round 1 (below), selected by node ID the same way:
64e048684adds 6 tests and parametrizes the offline test overHF_HUB_OFFLINEandTRANSFORMERS_OFFLINE: the 4 tests for the round's bugs failed, each on an assertion; the 4 that cover--default, a conflicting--currentand both offline variables passed, since they cover existing behaviour.f4ddb1cf8fixes the tool: those 8 passed, and all 31 tests from the 30 node IDs pass.Review round 2 (below), selected by node ID the same way:
aa95e92abadds 7 node IDs (10 tests) and lets the fake list branches: the 2 tests for the staging branch failed, each on an assertion (the switch exited 0); the 8 that cover gaps in round 1's fixes passed.209203a34fixes the tool: those 10 passed, and all 44 tests from the 36 node IDs pass.Review round 3 (below), selected by node ID the same way:
dc9cba40aadds a test that no Hub request follows the switch's last listing of the refs, a test that other branches do not refuse the switch, and a moved annotated tag to the moved-tag test, and makes the fake give a moved annotated tag a new tag object ID: the one-request test failed on its assertion (4repo_inforequests followed the listing); the other 6 selected tests passed.c1acc0acdcompares the listed tag IDs instead: those 7 passed, and all 47 tests from the 38 node IDs pass.Node IDs
Review round 1
A fresh read-only review of
768890d09found four bugs:--write, inside its commit loop and against a record holding one build. A read-only run passed a release name or role the interface refuses, and a run with--writecommitted earlier builds first, then refused or, for an unsafe name, ended in a traceback. It now builds the record of every moving build and runs the interface's checks on it and on each copy commit before its read-only return, so both are reported problems and nothing is written. Fixed inf4ddb1cf8.mainthat no writer could list or remove later. It now refuses any build folder its record would not list. Fixed inf4ddb1cf8.latest.json, which the("uk", 2023)registry entry follows. The June 2023 build moves into releasepopulace-uk-2023; After the UK switch, publish UK national, dense and local-area builds only through the emitter #1537 gives that entryrelease="populace-uk-2023", and the loader then reads it fromreleases.jsonafter the switch and followslatest.jsonuntil then. Not changed here.main, and a tag-only one never commits tomain, soparent_commitstill matched and the record left that build out. The switch now reads the tags again just before its commit and refuses if they changed. The step also runs only with nobody publishing. Fixed inf4ddb1cf8.Also from the round: the
copy_buildsand_folder_statedocstrings, the README paragraph and the changelog fragment now say what the code does (includingTRANSFORMERS_OFFLINE), and_surveyno longer listsSwitchRefusedErrorbesideValueError. Not done: aProtocolfor the sevenHfApimethods (no type checker runs in CI), and one commit-history listing per step instead of one per tag (a one-time run over about 19 tags).Review round 2
A fresh read-only review of
f4ddb1cf8found round 1's fixes correct, and refusing no correct copy or switch of the UK repository, and one more bug:releases.jsononly when it starts, then uploads on arelease-staging/<release>branch and tags the build; a tag created after the switch's second tag listing left that build in neither the record nor a folder. The switch now reads the staging branches with the tags, in one listing, at its first read and just before its commit, and refuses while any exists (a branch left by a failed publication must be deleted first). Fixed in209203a34; the saved UK inventory has no branch other thanmain.Also from the round, in
73415b30d: the module docstring and README say to run the switch step only while nobody publishes; the README's switch synopsis gains--exclude; and the docstring, README and changelog say that the Hub copies LFS files on its own servers, whilehuggingface_hubdownloads a small regular file and sends it in the commit. New tests inaa95e92abcover a tag deleted or moved while the switch reads, a folder copied earlier and left out with--exclude, a role conflict in a read-only copy, and the tool's build-folder rule against the interface's.Review round 3
A fresh read-only review of
73415b30dfound no bugs. It found round 2's fix correct against the tagged publisher's order (branch, upload, tag, then delete the branch, so any one listing from the branch's creation on shows the branch, the tag or both), refusing no correct switch of the UK repository, and checked again that the loader, the dashboard, .py and the emitter's release writer accept the switched repository. Of its two code-quality points:c1acc0acdthe switch compares the IDs the listing gives with those its survey listed, in one request.release-staging/branches.dc9cba40aadds a test that other branches, includingrelease-staging-notes, do not refuse the switch.Not in this PR
--include …=populace-uk-2023, and--currentmakes the newest dense build current.🤖 Generated with Claude Code