Repository navigation
feat: tfmgr generate writes the files generated from metadata - #19
Merged
Merged
Conversation
oesteban
marked this pull request as ready for review
December 4, 2026 09:08
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. |
`tfmgr generate atlases|cohorts|templates|dataset|all [--check] [PATH]`: - in a template, the atlas descriptions (one per row of the atlases table) and the cohorts table with its sidecar (from the cohort block of template_description.json); descriptions and tables no longer generated are deleted; - at the root of the Archive, templates.tsv and dataset_description.json (BIDS 1.11, DatasetType derivative, License LicenseRef-TemplateFlow-PerTemplate). Its TemplateFlowVersion becomes 2.0.0 only once every template is at 2.0.0, since that switches the Archive's checks to strict mode; no tfmanager version is recorded, so the file does not change when tfmanager does. Every registered template must be installed, or templates.tsv would leave it out. The files are the strings the validator compares against (TF410, TF607, TF801), written atomically (an annex link is replaced by a regular file). `--check` changes nothing and exits with 1 when there are files to write; errors exit with 2. `tfmgr add` writes the generated files before its strict validation, so contributors only write the atlases table and template_description.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oesteban
force-pushed
the
feat/generate
branch
from
December 4, 2026 09:11
1ce8184 to
dfa96bb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ce81840f0
ℹ️ 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".
template_outputs deleted the cohorts table when template_description.json was valid JSON but not an object (such as `[]`), and every atlas description when the atlases table was annexed, too large or had no atlas_id column. It now raises GenerateError (exit 2) when: - template_description.json is missing, annexed, too large, not JSON or not an object, or its "cohort" is neither absent, null nor an object; - the atlases table exists but cannot be read, or has no atlas_id column; - a row cannot become a description: a malformed JSON cell (this crashed with a traceback) or an atlas_id that is not a label (it could name a path outside the template). Files are deleted only when readable metadata says they are not generated: no atlases table, no row for a description, or no cohort block (absent, null or empty). Reported by the Codex review of #19. 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
Second of seven PRs for WP4 of Archive 2.0. Stacked on #18 (base
refactor/archive-collector; it retargets tomasterwhen that one merges).tfmgr add copy: mirror the source, write template_description.json, LICENSE, CHANGES + write the generated files (as `tfmgr generate all`) validate (strict)The files are the strings the validator already compares against (TF410, TF607, TF801), written atomically; an annex link at a generated path is replaced by a regular file.
For your approval: the Archive's
dataset_description.json(whattfmgr generate datasetwrites on today's Archive):{ "Name": "TemplateFlow", "BIDSVersion": "1.11.0", "DatasetType": "derivative", "TemplateFlowVersion": "1.0.0", "License": "LicenseRef-TemplateFlow-PerTemplate", "GeneratedBy": [{"Name": "tfmanager", "CodeURL": "https://github.com/templateflow/python-manager"}], "ReferencesAndLinks": ["https://doi.org/10.1038/s41592-022-01681-2"] }TemplateFlowVersionbecomes 2.0.0 only when every registered template is installed and at 2.0.0; otherwise it keeps its current value. This value switches the Archive's checks (TF8xx) to strict mode, so it flips with the last migrated template.GeneratedBy, so--checkdoes not fail after every tfmanager release.LicenseRef-TemplateFlow-PerTemplateneeds one that points to each template's LICENSE. It belongs with the superdataset workflow that will run this command (after rc5).Evidence
tfmgr generate all ~/tmp/templateflow --checkon today's Archive:would update dataset_description.json,would create templates.tsv, exit 1.tfmgr generate all tpl-MNIInfant --check:would create tpl-MNIInfant_cohorts.jsonand.tsv, exit 1.tpl-MNI152NLin2009cSym:Up to date., exit 0.tfmgr generate templates tpl-MNIInfant: exit 2. Nothing was written.test_generate.py(21 tests):test_add.py::test_generated_files_are_written: a submission without its atlas description passes strict validation. Without theadd.pychange the test fails.cohortthat is not an object, an atlases table that cannot be read or has noatlas_idcolumn, and a row that cannot become a description (malformed JSON cell, or anatlas_idthat is not a label) stop the command with exit 2 and touch nothing (test_unreadable_metadata,test_malformed_atlas_row; all fail without 71bd7b6).tfmgr generate atlases ~/tmp/templateflow --check:Up to date.for all 30 templates.tfmgr generate cohortsstops at tpl-dhcpAsym, whose cohort ages are numbers rather than[min, max](as before 71bd7b6).master, so this stacked PR has no checks. The CI job, run locally on a clean worktree of 71bd7b6:ruff check .clean;pytest -o addopts="" --doctest-modules tfmanager: 208 passed.ruff check .clean; 208 passed.twine checkpassed.Merge Danger
Door: two-way
Blast Radius: CLI
A new command.
tfmgr addnow writes atlas descriptions and cohorts tables into the dataset it builds, replacing stale copies from the submission. Nothing runstfmgr generateon the Archive yet.