diff --git a/.github/workflows/build_docs.yaml b/.github/workflows/build_docs.yaml
index 251347f..2d15a05 100644
--- a/.github/workflows/build_docs.yaml
+++ b/.github/workflows/build_docs.yaml
@@ -25,10 +25,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v7
with:
- python-version: '3.12'
- - name: Build in confined environment and interpolate version
+ python-version: '3.13'
+ - name: Install tfmanager and Sphinx
run: |
- python -m pip install -U pip "setuptools >= 42.0" "setuptools_scm[toml] >= 8"
- python setup.py --version
- python -m pip install -r docs/requirements.txt
- make -C docs/ html
+ python -m pip install -U pip
+ python -m pip install ".[content]" -r docs/requirements.txt
+ - name: Build (warnings are errors)
+ run: make -C docs/ html SPHINXOPTS="-W --keep-going"
diff --git a/CHANGES.rst b/CHANGES.rst
index 1575980..dff48c9 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,5 +1,8 @@
-Unreleased
-==========
+26.0.0rc5 (December 5, 2026)
+============================
+The tools of the migration to TemplateFlow 2.0: ``tfmgr migrate`` plans and applies it,
+template by template, and ``tfmgr generate`` writes the generated files.
+
* Python 3.13 or newer, following `SPEC 0 `__
(tested on 3.13 to 3.15).
* New command ``tfmgr generate atlases|cohorts|templates|dataset|all [--check] [PATH]``
@@ -117,6 +120,12 @@ Unreleased
from a git commit without checking it out, ``collect_archive`` gathers what the
Archive's files and checks need from its templates, and ``renames_problems`` checks a
root renames table from its text. The checks report the same issues as before.
+* New documentation page, *Migration to TemplateFlow 2.0*: what changes for the users of
+ the Archive, how a template is migrated, the config, and every rename rule, content
+ transform and finding of a plan, with examples from the Archive. A test keeps the page
+ and the code in step.
+* The documentation builds on Python 3.13 with tfmanager installed, and fails on
+ warnings; ``docs/requirements.txt`` and the ``doc`` extra list only what the build uses.
26.0.0rc4 (December 3, 2026)
============================
diff --git a/docs/conf.py b/docs/conf.py
index 1f10c9d..4b480a2 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -10,7 +10,10 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
+import builtins
+
from packaging.version import Version
+from sphinx.addnodes import pending_xref
from tfmanager import __version__, __copyright__, __packagename__
@@ -40,19 +43,6 @@
"sphinx.ext.napoleon",
]
-autodoc_mock_imports = [
- "matplotlib",
- "nilearn",
- "nipy",
- "nitime",
- "numpy",
- "pandas",
- "seaborn",
- "skimage",
- "svgutils",
- "transforms3d",
-]
-
# Accept custom section names to be parsed for numpy-style docstrings
# of parameters (supported by Sphinx's built-in napoleon).
napoleon_use_param = False
@@ -78,7 +68,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
-language = None
+language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -218,3 +208,19 @@
# -- Options for versioning extension ----------------------------------------
scv_show_banner = True
+
+
+# -- Builtin types in annotations --------------------------------------------
+def _builtin_types(app, doctree):
+ """Link builtins named by annotations (``set[str]``) to Python, not to API attributes.
+
+ Sphinx looks up types in signatures by suffix, so ``set`` would also match the
+ ``set`` attributes of ``tfmanager.migrate.config`` (an ambiguous reference).
+ """
+ for node in doctree.findall(pending_xref):
+ if node.get("refdomain") == "py" and hasattr(builtins, node.get("reftarget", "")):
+ node.attributes.pop("refspecific", None)
+
+
+def setup(app):
+ app.connect("doctree-read", _builtin_types)
diff --git a/docs/index.rst b/docs/index.rst
index 93a5048..f9839a0 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -11,6 +11,7 @@ Contents
:maxdepth: 3
usage
+ migration
api
What's new
diff --git a/docs/migration.rst b/docs/migration.rst
new file mode 100644
index 0000000..028365d
--- /dev/null
+++ b/docs/migration.rst
@@ -0,0 +1,560 @@
+.. _migration:
+
+Migration to TemplateFlow 2.0
+=============================
+
+TemplateFlow 2.0 names the files of the Archive as BIDS 1.11 does, and describes each
+template with SPDX licenses, a table of its atlases, BIDS lookup tables and a README.
+``tfmgr migrate`` moves each template there. It *plans* the migration of a template from
+its files, the facts of their headers and the decisions of its config, without image data,
+and it *applies* the plan to a checkout of the template as git commits, which become the
+template's pull request. ``tfmgr`` never pushes.
+
+This page says what changes for the users of the Archive, how a template is migrated, and
+what each code of a plan means: rename rules (R), content transforms (T) and findings (M).
+The commands are described in :doc:`usage`.
+
+What users see
+--------------
+
+Every file the migration renames or removes gets a row in the template's ``.renames.tsv``
+(columns ``old_path`` and ``new_path``). The template's action checks the table, and copies
+its rows into the ``renames.tsv`` of the superdataset.
+
+Rename rows
+ The file keeps its bytes under its new name. Its old S3 key keeps serving it (the
+ template action stores the current content of the new name under the old key), and
+ the legacy skeleton, which released clients read, keeps listing the old name. The
+ Python client 26.0 finds the file by its old name, with a ``TemplateFlowAliasWarning``
+ that gives the query to use instead, until its version 27.0.
+
+``n/a`` rows
+ The file was removed, or renamed and its bytes changed (policy ``content_change:
+ freeze``). Its old S3 key keeps serving its last old bytes, and the legacy skeleton keeps
+ listing its old name. The client 26.0 serves it, with a warning, until its version 27.0.
+
+Files that keep their name
+ ``template_description.json``, ``LICENSE``, ``CHANGES`` and the JSON sidecars that keep
+ their name change for every client. ``plan.md`` lists them under *Impact*.
+
+New files
+ The atlases and cohorts tables, the atlas descriptions and ``docs/`` are listed in the
+ v2 skeleton only, which clients read from version 26.0.
+
+The migration writes no ``purge`` rows: no file leaves S3.
+
+.. important::
+
+ A later change to a file that has a rename row also changes what its old name serves,
+ because the template action stores the current content of the new name under the old
+ key. To keep the old bytes for released clients, turn the file's row into ``n/a`` in
+ the same pull request.
+
+Migrating a template
+--------------------
+
+The steps for a template ``tpl-X``, checked out at ``path/to/tpl-X``:
+
+1. **Facts.** Plans need no image data: the facts of image headers and the label values of
+ segmentations are shipped with tfmanager (``migrate/data/``), keyed by md5. When files
+ of the template changed since (findings M110 and M111), read their facts again from a
+ checkout of the Archive whose data are present:
+
+ .. code-block:: shell
+
+ tfmgr migrate headers -t tpl-X --needs path/to/templateflow
+ tfmgr migrate labels -t tpl-X --needs path/to/templateflow
+ # fetch the files they list (datalad get), then:
+ tfmgr migrate headers -t tpl-X -o headers.tsv path/to/templateflow
+ tfmgr migrate labels -t tpl-X -o labels/ path/to/templateflow
+
+2. **Plan.**
+
+ .. code-block:: shell
+
+ tfmgr migrate plan -t tpl-X --source path/to/tpl-X -o plans/ \
+ --authored authored/ --legacy-skeleton templateflow-skel.zip
+
+ ``--source`` also takes the v2 skeleton zip of the Python client, or a checkout of the
+ Archive (``--all`` plans every template). ``--authored`` adds the files written by hand,
+ as ``authored/tpl-X/README.md`` or ``authored/tpl-X/docs/...``; ``--headers`` and
+ ``--labels`` add the facts of step 1; ``--legacy-skeleton`` gives M301 the exact names
+ that released clients know. The command writes ``plans/tpl-X/plan.json`` (what
+ ``apply`` reads), ``plan.md`` (the complete plan, for review), ``pr.md`` (the body of
+ the pull request) and ``renames.tsv`` (the template's ``.renames.tsv`` after the
+ migration). It exits with 1 when the plan is blocked.
+
+3. **Review** ``plan.md``. A blocked plan lists its blocking findings under *Needs a
+ decision*, most of them with a decision to complete and add to the config (`The
+ config`_); *Notes* lists the findings that do not block. Then come the decisions of the
+ config that the plan used, the renames by rule, the diff of every file written, the diff
+ of ``.renames.tsv``, the strict validation before and after, and the impact on users.
+
+4. **Apply.**
+
+ .. code-block:: shell
+
+ tfmgr migrate apply plans/tpl-X/plan.json path/to/tpl-X
+
+ It refuses a blocked plan, a checkout that is not the one the plan was made from (it
+ lists the files that differ), changes in the worktree, an existing branch, an
+ ``adjusted/`` branch of git-annex and unlocked annexed files. It builds two commits
+ without touching HEAD or the worktree: the file names (renamed files keep their blobs,
+ so annexed files keep their keys), then the metadata (the files written,
+ ``.gitattributes`` and the final ``.renames.tsv``). A commit that would change nothing
+ is left out, and a plan that changes nothing is refused. It checks the commits
+ (fingerprints, annex keys, only planned paths changed, the validation the plan
+ predicted), and only then creates the branch ``migrate/2.0.0`` and checks it out. On
+ any failure, it switches back and deletes the branch. ``--dry-run`` builds and checks
+ the commits in a temporary object store, and keeps nothing.
+
+5. **Pull request.** Push the branch (``git push origin migrate/2.0.0``), open the pull
+ request with ``pr.md`` as its body, and replay its rows through the compatibility tests
+ of the Python client (``tests/compat`` of templateflow/python-client, with
+ ``TEMPLATEFLOW_COMPAT_RENAMES`` and ``TEMPLATEFLOW_COMPAT_TEMPLATE``).
+
+6. **Verify** the branch again after a rebase:
+
+ .. code-block:: shell
+
+ tfmgr migrate verify plans/tpl-X/plan.json path/to/tpl-X --ref HEAD
+
+ It checks that the commit is the plan's result, that its ``.renames.tsv`` passes the
+ checks of the template action, and that it validates as the plan predicted.
+
+``plan.json`` records the sha256 of every input (the source, the config, the facts and the
+files written by hand), and each commit carries a ``Migration-Plan`` trailer with the
+sha256 of its ``plan.json``.
+
+When a template moves to 2.0
+----------------------------
+
+A template's ``TemplateFlowVersion`` becomes 2.0.0, and its ``BIDSVersion`` 1.11.0, only
+when the result of its plan passes ``tfmgr validate`` in strict mode at the metadata level
+(policy ``flip: when-clean``); its CHANGES then gets a 2.0.0 entry (T11). Otherwise the plan
+reports M205, and the versions and CHANGES stay as they are: the template still takes its
+new names and metadata, and a later plan, once the missing files are written (most often
+README.md), moves it to 2.0. Planning a migrated template again renames nothing, because
+the rules only match names from before 2.0, so that plan makes the metadata commit only
+(use ``--branch`` if ``migrate/2.0.0`` still exists).
+
+The ``dataset_description.json`` of the Archive moves to 2.0.0 (``tfmgr generate
+dataset``) once every template has.
+
+The config
+----------
+
+The decisions of the migration are in ``tfmanager/migrate/config/2.0.0.yaml``, shipped
+with tfmanager and checked against ``schema.json`` before use. Each decision says why,
+citing its evidence, and a plan reports a decision that no longer matches the files it was
+written for (M108). Decisions change through pull requests on tfmanager; ``tfmgr migrate
+plan --config FILE`` tries a change first.
+
+.. list-table::
+ :header-rows: 1
+ :widths: 25 75
+
+ * - Section
+ - Decides
+ * - ``policies``
+ - ``res_key: zoom`` (R11, R12, R19), ``content_change: freeze`` (rows) and
+ ``flip: when-clean`` (versions).
+ * - ``gitattributes``
+ - The ``.gitattributes`` of every template (T09).
+ * - ``atlas_labels``
+ - Atlas labels that change (R01).
+ * - ``renames``
+ - Names of files that no rule covers, and files to remove: ``match`` selects files of
+ one template by entity, suffix and extension, ``set`` writes entities, suffix and
+ extension, ``remove: true`` removes them (``n/a`` rows), and ``count`` says how many
+ files it matches.
+ * - ``res_assign``
+ - The ``res`` key of single files (M109, and files whose grid is known to be wrong).
+ * - ``edits``
+ - Fields to set or remove in JSON files after the renames; ``create: true`` writes a
+ new sidecar.
+ * - ``tables``
+ - ``layouts``: how each layout of lookup tables converts (T01). ``sources``: tables
+ written from cited upstream files, kept under ``migrate/config/tables/`` (T02).
+ * - ``participants``
+ - The participants tables (T03).
+ * - ``licenses``
+ - ``table``: the license of each template, atlas and subset of files, citing its
+ upstream statement (T07). ``texts``: license texts that tfmanager does not bundle,
+ kept under ``migrate/config/licenses/``.
+ * - ``atlases``
+ - The rows of the atlases tables (T04).
+
+Rename rules
+------------
+
+Each file goes through the config's ``renames`` decisions about its template, then the
+rules in the order of their codes; R99 comes last. A file without a BIDS name is renamed by R15
+only. The ``res`` rules (R11, R12, R16 for ``res``, R19) are computed for the whole
+template first, from the header facts and the ``res`` blocks of
+``template_description.json``. The examples come from the Archive.
+
+``R01`` Atlas labels that are versions or typos become names
+ The config's ``atlas_labels``: WHS ``atlas-v3`` becomes ``atlas-Osen2019``, Fischer344
+ ``atlas-v4`` becomes ``atlas-Goerzen2020``, and ``CerebA`` becomes ``CerebrA``.
+
+ .. code-block:: text
+
+ tpl-Fischer344_atlas-v4_dseg.tsv
+ tpl-Fischer344_atlas-Goerzen2020_dseg.tsv
+
+``R02`` ``desc-DKT31`` is an atlas
+ ``desc-DKT31`` becomes ``atlas-DKT31``.
+
+ .. code-block:: text
+
+ tpl-MNI152NLin2009cAsym_res-02_desc-DKT31_dseg.nii.gz
+ tpl-MNI152NLin2009cAsym_atlas-DKT31_res-2_dseg.nii.gz
+
+``R03`` Schaefer parcellations
+ ``desc-ParcelsNetworks`` becomes ``seg-n_scale-``.
+
+ .. code-block:: text
+
+ tpl-MNI152NLin6Asym_atlas-Schaefer2018_desc-100Parcels7Networks_dseg.tsv
+ tpl-MNI152NLin6Asym_atlas-Schaefer2018_seg-7n_scale-100_dseg.tsv
+
+``R04`` DiFuMo dimensions
+ ``desc-dimensions`` becomes ``scale-``.
+
+ .. code-block:: text
+
+ tpl-MNI152NLin6Asym_atlas-DiFuMo_desc-64dimensions_probseg.tsv
+ tpl-MNI152NLin6Asym_atlas-DiFuMo_scale-64_probseg.tsv
+
+``R05`` Levels of atlas hierarchies
+ ``desc-level`` becomes ``scale-``.
+
+ .. code-block:: text
+
+ tpl-NMT31Sym_atlas-SARM_desc-level1_dseg.tsv
+ tpl-NMT31Sym_atlas-SARM_scale-1_dseg.tsv
+
+``R06`` Harvard-Oxford thresholds
+ ``desc-th`` becomes ``seg-th``.
+
+ .. code-block:: text
+
+ tpl-MNI152NLin6Asym_res-01_atlas-HOCPA_desc-th0_dseg.nii.gz
+ tpl-MNI152NLin6Asym_atlas-HOCPA_seg-th0_res-1_dseg.nii.gz
+
+``R07`` Tissue classes are labels
+ ``desc-CSF``, ``desc-GM`` and ``desc-WM`` become ``label-``; masks keep ``desc``.
+
+ .. code-block:: text
+
+ tpl-MouseIn_res-1_desc-GM_probseg.nii.gz
+ tpl-MouseIn_res-1_label-GM_probseg.nii.gz
+
+``R08`` Subcortical gray matter
+ ``label-SCGM`` becomes ``label-SGM``, the BIDS label.
+
+ .. code-block:: text
+
+ tpl-PNC_res-01_label-SCGM_probseg.nii.gz
+ tpl-PNC_res-1_label-SGM_probseg.nii.gz
+
+``R09`` Masks say what they cover with ``desc``
+ ``label-_mask`` becomes ``desc-_mask``.
+
+ .. code-block:: text
+
+ tpl-UNCInfant_cohort-1_label-brain_mask.nii.gz
+ tpl-UNCInfant_cohort-1_res-1_desc-brain_mask.nii.gz
+
+``R10`` ``stat`` is not an entity
+ ``stat-`` becomes ``desc-``.
+
+ .. code-block:: text
+
+ tpl-SUIT_atlas-Buckner2011_seg-7n_stat-confidence_dseg.nii.gz
+ tpl-SUIT_atlas-Buckner2011_seg-7n_res-1_desc-confidence_dseg.nii.gz
+
+``R11`` ``res`` keys that are not indexes
+ A key such as ``iso4mm`` follows the policy ``res_key: zoom``: the voxel size when it
+ is an integer, isotropic and free, otherwise the smallest free index. The key of the
+ ``res`` block changes with it.
+
+ .. code-block:: text
+
+ tpl-MNI152NLin2009cSym_res-iso4mm_desc-face_mask.nii.gz
+ tpl-MNI152NLin2009cSym_res-4_desc-face_mask.nii.gz
+
+``R12`` Volumes without ``res``
+ A volume without ``res`` takes the key of the block its grid matches (shape, voxel
+ size and origin, compared as TF701 does), or a new key (policy ``res_key: zoom``).
+
+ .. code-block:: text
+
+ tpl-SUIT_T1w.nii.gz
+ tpl-SUIT_res-1_T1w.nii.gz
+
+``R13`` Boundary meshes of atlas labels
+ A ``.label.gii`` file with ``label`` and no suffix, whose content is a mesh (a pointset
+ and its triangles, M112 otherwise), becomes ``_boundary.surf.gii``; ``desc-k``
+ goes.
+
+ .. code-block:: text
+
+ tpl-NMT31Sym_atlas-CHARM_label-frontal_scale-1.label.gii
+ tpl-NMT31Sym_atlas-CHARM_scale-1_label-frontal_boundary.surf.gii
+
+``R14`` ``PET`` becomes ``pet``
+ The suffix in lower case, as BIDS writes it.
+
+ .. code-block:: text
+
+ tpl-MNI152Lin_desc-SPM12_res-02_PET.nii.gz
+ tpl-MNI152Lin_res-3_desc-SPM12_pet.nii.gz
+
+``R15`` Participants tables
+ ``template_sample.tsv`` becomes ``tpl-