Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Compatibility

# Released clients and this branch against an Archive before and after a renames table
# (tests/compat/README.md). Nightly, it catches changes in the Archive's skeleton
# builder and in the clients' dependencies. Replay a proposed table before merging it
# into a template with "Run workflow".

on:
push:
branches: [master, 'maint/*']
pull_request:
schedule:
- cron: '23 3 * * *'
workflow_dispatch:
inputs:
renames-url:
description: >-
HTTPS URL of a renames table to replay: rows of the root renames.tsv, or a
template's .renames.tsv (set the template). Empty runs the sample table.
required: false
default: ''
template:
description: Template of a .renames.tsv fragment (tpl-X); empty for root rows
required: false
default: ''
archive-ref:
description: Ref of templateflow/templateflow whose build-skeletons.py builds the Archive
required: false
default: master

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
compat:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-26.04
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
# SPEC 0
python-version: ['3.13', '3.14', '3.15']
env:
TEMPLATEFLOW_COMPAT_PYTHON: ${{ matrix.python-version }}
TEMPLATEFLOW_ARCHIVE_SCRIPTS: ${{ github.workspace }}/archive/.github/scripts
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # hatch-vcs versions the client under test
persist-credentials: false
- uses: actions/checkout@v7
with:
repository: templateflow/templateflow
ref: ${{ inputs.archive-ref || 'master' }}
path: archive
sparse-checkout: .github/scripts
persist-credentials: false
- uses: astral-sh/setup-uv@v10.4.1
- name: Fetch the table to replay
if: inputs.renames-url != ''
env:
URL: ${{ inputs.renames-url }}
TEMPLATE: ${{ inputs.template }}
run: |
curl -fsSL --proto '=https' --max-filesize 1048576 -o "$RUNNER_TEMP/renames.tsv" "$URL"
echo "TEMPLATEFLOW_COMPAT_RENAMES=$RUNNER_TEMP/renames.tsv" >> "$GITHUB_ENV"
if [ -n "$TEMPLATE" ]; then
echo "TEMPLATEFLOW_COMPAT_TEMPLATE=$TEMPLATE" >> "$GITHUB_ENV"
fi
cat "$RUNNER_TEMP/renames.tsv"
- name: Set up the test environment
run: |
uv venv --python "$TEMPLATEFLOW_COMPAT_PYTHON" "$RUNNER_TEMP/compat"
uv pip install --python "$RUNNER_TEMP/compat/bin/python" . pytest
- name: Run the compatibility matrix
run: >-
"$RUNNER_TEMP/compat/bin/python" -m pytest -o addopts="" -rxXs
--junitxml="$RUNNER_TEMP/compat.xml" tests/compat
- uses: actions/upload-artifact@v7
if: always()
with:
name: compat-python-${{ matrix.python-version }}
path: ${{ runner.temp }}/compat.xml
34 changes: 34 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
Unreleased (26.0.0)
===================
TemplateFlow 2.0 file names: the client reads the v2 skeleton and resolves old names.

* New home folders start from the v2 skeleton (``templateflow-skel-v2.zip``): current
names only, with ``renames.tsv`` and a manifest of every file's size and checksum.
Updates make the home match it: they add files, refresh text files, prune stubs of
names the Archive no longer uses, and reset downloads the Archive changed.
* Existing home folders keep the legacy skeleton, which older clients read, until
``templateflow update --migrate`` (or ``templateflow.update(migrate=True)``) moves
them to the v2 skeleton. Files downloaded under an old name move to the new one when
their checksum matches. ``templateflow config`` shows the home's layout.
* ``ls()`` and ``get()`` resolve old names through ``renames.tsv``: old-style queries
find the renamed files with a ``TemplateFlowAliasWarning`` (a ``FutureWarning``)
that gives the query to use instead, and files removed from the Archive are still
served until templateflow 27.0. In homes that have not migrated, current queries
find the old names, and ``ls()`` returns one file when a home holds both names.
A query that also finds files by the home's own names adds renamed files only when
it names them by a value (``desc='CSF'``), not through ``None`` or ``Query.ANY``.
* New ``get_atlas_metadata(template, atlas)`` reads
``tpl-<template>/atlas-<atlas>_description.json``. Homes that have not migrated
download the 2.0 tables (``atlases.tsv``, ``cohorts.tsv``) and atlas descriptions on
first use.
* Entities follow the TemplateFlow 2.0 rule set: new ``inversion`` (``inv-``),
``label`` accepts ``+``, and ``scale`` accepts letters.
* ``TEMPLATEFLOW_SKEL_URL`` replaces the base URL of the skeletons.
* FIX: ``get_metadata()`` called ``_datalad_get`` with the wrong arguments.
* FIX: ``get()`` skipped files when DataLad fetched several at once, and failed for
files without a stub in the home.
* FIX: Network errors other than connection errors no longer break skeleton updates.
* MAINT: A compatibility matrix (``tests/compat``, workflow *Compatibility*) runs the
released clients and this one against an Archive before and after a renames table,
in S3 and DataLad homes. It replays a proposed table before it is merged.

25.1.2 (March 11, 2026)
=======================
Patch release to update templateflow skeleton.
Expand Down
22 changes: 22 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ client again, in case the tool has already been operated in direct download mode

$ rm -r ${TEMPLATEFLOW_HOME:-$HOME/.cache/templateflow}

**TemplateFlow 2.0 file names**.
TemplateFlow 2.0 renames files to follow BIDS 1.11 (for example, ``desc-CSF_probseg``
becomes ``label-CSF_probseg``), and records each rename in ``renames.tsv``.
Since templateflow 26.0, new home folders hold the current names only.
Home folders created by older versions keep the names they have, because older clients
sharing them expect those names, until you migrate them::

$ templateflow update --migrate

Migrating removes the stubs of old names, and moves files downloaded under an old name
to the new one when their checksum matches (otherwise they are downloaded again on
demand). Older clients sharing the folder see the old names again after their next
update.

Queries written for the old names keep working until templateflow 27.0, with a
``TemplateFlowAliasWarning`` (a ``FutureWarning``) that gives the query to use instead.
In home folders that have not migrated, queries written for the new names find the old
files without warnings.

``TEMPLATEFLOW_SKEL_URL`` replaces the base URL the client downloads skeletons from
(the list of file names of the Archive), for mirrors and tests.

**Naming conventions**.
Naming conventions for templates and atlases are available within the
`Contributing section of the TemplateFlow website
Expand Down
21 changes: 18 additions & 3 deletions templateflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def config():
TEMPLATEFLOW_HOME={CONFIG.root}
TEMPLATEFLOW_USE_DATALAD={'on' if CONFIG.use_datalad else 'off'}
TEMPLATEFLOW_AUTOUPDATE={'on' if CONFIG.autoupdate else 'off'}

Home layout: {CACHE.generation}
""")


Expand All @@ -119,15 +121,28 @@ def wipe():


@main.command()
@click.option('--local', is_flag=True)
@click.option('--local', is_flag=True, help='Use the skeleton bundled with the client.')
@click.option('--overwrite/--no-overwrite', default=True)
def update(local, overwrite):
@click.option(
'--migrate',
is_flag=True,
help=(
'Move a home created by templateflow 25.x or older to the TemplateFlow 2.0 names: '
'stubs of old names are removed, and downloaded files move to their new names. '
'Older clients sharing the home lose the old names until they update it.'
),
)
def update(local, overwrite, migrate):
"""Update the local TemplateFlow Archive."""
from templateflow.conf import update as _update

try:
updated = _update(local=local, overwrite=overwrite, migrate=migrate)
except RuntimeError as exc:
raise click.ClickException(str(exc)) from exc
click.echo(
f'Successfully updated local TemplateFlow Archive: {CONFIG.root}.'
if _update(local=local, overwrite=overwrite)
if updated
else 'TemplateFlow Archive not updated.'
)

Expand Down
Loading
Loading