Repository navigation
feat: template snapshots and image header facts for tfmgr migrate - #20
Merged
Merged
Conversation
tfmanager.migrate.snapshot reads a template, without image data, into a Snapshot: the size and md5 of each visible file (from the annex key of annexed files), the content of files in git, and the rows of .renames.tsv. It reads from the v2 skeleton zip of the client (manifest and root renames.tsv) or from any commit of a checkout (GitTree). Both give the same fingerprint (tfm1: sha256 of path, size and md5, plus the rows), and hidden files do not count. On the Archive, the two agree for all 30 templates. `tfmgr migrate headers ARCHIVE [--needs] [-o TSV]` lists the files whose headers the migration needs (volumes without an index res, every volume of templates without res blocks, probseg without label, GIFTI files whose suffix does not allow their extension) and reads them with nibabel: shape, zooms and origin as images.grid gives them, dtype, intent and the number of GIFTI arrays. Files are read through their link in the template, because nibabel tells formats apart by the file name. The table is keyed by path and md5, so a changed file has a stale row. GitTree gains mode() and link_target(). The tests get a pinned() download helper and the v2 skeleton fixture (python-client 45755e5, md5 checked). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oesteban
force-pushed
the
feat/migrate-snapshot
branch
from
December 4, 2026 11:35
305ffce to
805b519
Compare
The facts of the 1,147 files that the migration of the Archive needs, read with `tfmgr migrate headers` from a checkout matching the v2 skeleton of python-client 45755e5 (the zip and the checkouts have the same fingerprint for all 30 templates): 242 NIfTI images and 905 GIFTI files, keyed by path and md5. Shipped as package data, so plans and CI need no image data. test_bundled_headers checks that the table covers exactly the files needed() lists in the pinned v2 zip, with matching md5s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oesteban
marked this pull request as ready for review
December 4, 2026 12:15
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a5f8fbbff
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
DirectoryTree.local_path returned an unlocked annexed file whose content is absent (a git-annex pointer) as if it were the data, so `tfmgr migrate headers --needs` left it out and reading it failed, and the content checks of `tfmgr validate` would open the pointer as an image. Such a file now has no local path, like a locked annexed file without content. needed() also selects `.nii` volumes, as the content checks do (no suffix of the rule set allows `.nii`, and the Archive has none). Reported by the Codex review of #20. 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.
Summary
Third of seven PRs for WP4 of Archive 2.0. Stacked on #19 (base
feat/generate).Snapshot. Each visible file has its size and md5 (from the annex key when annexed), the content of files in git, and the template's
.renames.tsvrows. The fingerprint is whattfmgr migrate applywill compare against before it touches a checkout:Hidden files (
.github/,.datalad/) do not count, so bot commits leave it unchanged.Header facts.
The files needed:
res(nores, orres-iso4mm);resblocks;probsegwithoutlabel(4D or not);Each file is read through its link in the template, because nibabel tells formats apart by the file name.
The facts of the Archive (for your approval)
headers-2.0.0.tsv: 1,147 files, 242 NIfTI and 905 GIFTI. Read from checkouts whose fingerprints equal the v2 skeleton's (python-client 45755e5) for all 30 templates; 25 sampled md5s re-checked against the bytes.4D probabilistic segmentations: 45 (the rows of their
probseg.tsv, T02).Grids, for
resnames and blocks (R11, R12, new blocks).res-1andres-2in its names.res: they match block 1.res-iso4mm: it matches blockiso4mm, so it becomesres-4.res-02andres-03files are on DiFuMo's own padded grid (104×123×104 at 2 and 3 mm, origin of the 1 mm block), not on blocks 02 and 03 (97×115×97 and 65×77×65). The data are right at their zooms. Their names and blocks are for PR 4 to decide.res-1files are on the 0.15 mm grid and bothres-2files on the 0.025 mm grid, while block 1 says 0.025 mm and block 2 says 0.15 mm. No file is misnamed; the blocks are rebuilt from the headers (T06). (Corrected after merge: this line first said the threeres-1tissue maps wereres-2files.)originvalues give x and y with the opposite sign of the headers, which use RAS like every other template. That looks like ITK's LPS. New blocks are built from the headers (T06).GIFTI.
.label.giifiles are meshes (pointset plus triangles), so R13's_boundary.surf.giifits. 4 of them (the CHARM lobes atscale-1) have nodesc-kN, so R13 must cover them too.atlas-CHARM_dsegandatlas-SARM_dseg(res 1 and 2; x, y, z, 1, 6): each of their 6 volumes equals the matchingdesc-levelNfile, so they duplicate them. Whether to drop or rename them is for PR 4.label.gii(18) are label tables (int32, LABEL intent), so they becomedseg.label.gii.roi.shape.gii(18) andmyelinmap.func.gii(18) are float data, so they are.shape.gii.desc-nomedialwall_dparc.label.gii(6) are float32 masks (NONE or NORMAL intent), not label tables, so R17'sdseg.label.giiwould not fit them (PR 4). onavgdesc-cortex_dparc.label.gii(6) are label tables (uint8), so R17 fits.desc-vaavg_midthickness.shape.giihold one float per vertex (vertex areas), not a mesh (PR 4).denin all 74 files that have one (10k, 32k, 41k, 59k, 164k).Evidence
On the Archive,
load_v2_zip(python-client 45755e5, md5 cfb9f247…) andload_checkoutof every template give the same fingerprint for all 30 templates.test_bundled_headers: the shipped table covers exactly the 1,147 filesneeded()lists in the pinned v2 zip, all with matching md5s.test_migrate_snapshot.py:load_checkout: annex links, unlocked pointers, non-annex links left out, rows;needed()with and withoutresblocks;ok,missingandstalestates;read_headeragainstimages.gridon NIfTI-1, NIfTI-2 (4D) and GIFTI;--needs, exit 1 without data, exit 2 naming the file when nibabel cannot read it, the table.While writing these tests, I found that reading the annex object (whose key carries its own extension) could hand nibabel the wrong format; the command now reads through the link.
An unlocked annexed file whose content is absent (a git-annex pointer) has no local path, like a locked one:
--needslists it, and the content checks oftfmgr validateno longer open it as an image (test_local_path,test_cli_headers_unlocked; both fail without 874afa8).needed()also selects.niivolumes, as the content checks do.On the Archive after 874afa8:
tfmgr migrate headers ~/tmp/templateflow --needsgives1147 files needed, 0 without data.CI only runs for pull requests into
master, so this stacked PR has no checks. The CI job, run locally on a clean worktree of 874afa8:ruff check .clean;pytest -o addopts="" --doctest-modules tfmanager: 219 passed.ruff check .clean; 219 passed.twine checkpassed; the wheel shipstfmanager/migrate/data/*.tsv.Merge Danger
Door: two-way
Blast Radius: CLI
A new command group,
tfmgr migrate, with one read-only command, and 194 KB of package data. Nothing else changes, apart fromGitTreegainingmode()andlink_target(), andDirectoryTree.local_pathreturningNonefor git-annex pointers whose content is absent (content validation then skips them, as it skips locked annexed files without content).