From dfa96bb4c2609c07d9614fc715097e0ac50ddf34 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Fri, 4 Dec 2026 09:11:23 +0100 Subject: [PATCH 1/2] feat: tfmgr generate writes the files generated from metadata `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 --- CHANGES.rst | 8 ++ README.rst | 21 +++- tfmanager/add.py | 18 ++- tfmanager/cli.py | 56 +++++++++ tfmanager/generate.py | 171 ++++++++++++++++++++++++++- tfmanager/tests/test_add.py | 9 ++ tfmanager/tests/test_generate.py | 195 +++++++++++++++++++++++++++++++ tfmanager/validate/atlases.py | 9 +- 8 files changed, 479 insertions(+), 8 deletions(-) create mode 100644 tfmanager/tests/test_generate.py diff --git a/CHANGES.rst b/CHANGES.rst index 0d4f67a..3ae6154 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,14 @@ Unreleased ========== * 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]`` + writes the files generated from metadata: the atlas descriptions and the cohorts table + of a template, and templates.tsv and dataset_description.json at the root of the + Archive. dataset_description.json follows BIDS 1.11 (``DatasetType: derivative``, + ``License: LicenseRef-TemplateFlow-PerTemplate``), and its ``TemplateFlowVersion`` + becomes 2.0.0 once every template is at 2.0.0. ``--check`` changes nothing and exits + with 1 when there are files to write. +* ``tfmgr add`` writes the generated files of the template before validating it. * New internals for ``tfmgr generate`` and ``tfmgr migrate``: ``GitTree`` reads a template 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 diff --git a/README.rst b/README.rst index 7472f27..cef3842 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,23 @@ and values are only checked with ``--level content``, which needs ``tfmanager[co and the images' data. The command exits with 1 when there are errors, and 2 when it could not run. +Generating files +---------------- +Some files are generated from the metadata, and ``tfmgr validate`` reports them when they +are missing or out of date. ``tfmgr generate`` writes them:: + + tfmgr generate all tpl-MyTemplate # atlas descriptions and cohorts table + tfmgr generate all path/to/templateflow # templates.tsv and dataset_description.json + tfmgr generate all tpl-MyTemplate --check # list what would change; change nothing + +In a template, ``atlases`` writes an ``atlas-