Skip to content

feat: read the v2 skeleton and resolve TemplateFlow 2.0 renames - #160

Merged
oesteban merged 6 commits into
masterfrom
feat/archive-2
Dec 3, 2026
Merged

oesteban merged 6 commits into
masterfrom
feat/archive-2

Conversation

@oesteban

@oesteban oesteban commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

WP3, part 1: client 26.0 reads the v2 skeleton (templateflow/templateflow#217) and resolves the TemplateFlow 2.0 renames. Part 2 adds the compatibility matrix against released clients.

 TemplateFlowCache
-  install / update: legacy skeleton, add missing files only
+  install (new home): v2 skeleton                        generation 'v2'
+  update (legacy home): legacy skeleton, plus renames.tsv  generation 'legacy'
+  update(migrate=True) or v2 home: sync_v2
+    add files, refresh text files, reset downloads the Archive changed,
+    prune stubs of old names, move downloads to new names (md5 must match)
+  renames: bundled renames.tsv | the home's
 TemplateFlowClient.ls / get
   layout.get(...)
+  old name whose new name is in the home      -> hidden (one file per name)
+  nothing found:
+    old-style query    -> new file   + TemplateFlowAliasWarning (FutureWarning)
+    removed file (n/a) -> old path, downloaded from S3, + warning (until 27.0)
+    current query, home not migrated -> old file, silently
+    2.0 table, home not migrated     -> downloaded on demand
+  files found: also renamed files the query names by a value of their other
+    name (desc='CSF'), with the warning in migrated homes; not through None or Query.ANY
+get_atlas_metadata(template, atlas)
 templateflow update --migrate; templateflow config shows the home's layout

Behaviour decided for the TemplateFlow 2.0 overhaul:

  • Migration only on request. Existing homes keep the legacy skeleton, because older clients sharing them expect the old names.
  • Current queries in homes not yet migrated resolve silently.
  • Queries that find files also return renamed files they name by an old value: ls('A', desc=['CSF', 'brain'], suffix='probseg') returns desc-brain and the renamed label-CSF, with the warning. Entities a query requires absent (None) or present (Query.ANY) are read in the home's names, so current queries such as desc=None never warn.
  • Removed files (n/a) are served until 27.0, with a warning.
  • 2.0 metadata (atlases.tsv, cohorts.tsv, atlas descriptions) downloads on demand in legacy homes.

Smaller changes:

  • Stored skeleton: each v2 home keeps the skeleton it follows (.templateflow/skeleton.zip, 1.3 MB). Every update applies it again, so deleted folders come back, offline too.
  • Entities: new inversion (inv-), + in label, letters in scale, as in the python-manager rule set.
  • Mirrors: TEMPLATEFLOW_SKEL_URL replaces the base URL of the skeletons.
  • Fixes:
    • get_metadata() called _datalad_get with the wrong arguments;
    • get() skipped files when DataLad fetched several (it removed items from the list it iterated);
    • skeleton updates failed on network errors other than ConnectionError.

Evidence

  • Tests: 90 pass (pytest -n 4 --doctest-modules templateflow), including the existing suite against live S3. The new tests run offline:
    • test_sync.py: new homes, migration (move, delete, prune, reset, refresh; root files and foreign files kept), published skeleton updates, corrupt downloads, DataLad refusal, deleted folders coming back.
    • test_renames.py: the table and its lookup by template, and alias resolution in v2, legacy, both-names and DataLad-style homes, also next to files the query finds directly. It also has a parity check: match_entities against BIDSLayout.get() over the 2,539 indexed files of the real skeleton, for 22 queries covering None, Query.*, lists, dtype casts and regex.
  • Released client, end to end (live S3 and the published v2 skeleton):
    1. templateflow 25.1.2 creates a home and downloads tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz;
    2. this branch runs templateflow update --migrate, which adds 26 files and keeps the download;
    3. 25.1.2 still get()s the same file from the migrated home.
  • ruff, flake8 (as CI runs it) and codespell are clean.

Merge Danger

Door: two-way

Blast Radius: client users

Until a release, only master installs see it. After a release:

  • new homes are v2;
  • existing homes change only with --migrate;
  • a migrated home shared with an older client loses that client's old-name stubs until its next update().

The Archive has 23 renames today (the canaries), so most queries see no difference. Part 2 runs released clients from 0.8.1 on against both skeletons.

@oesteban
oesteban marked this pull request as ready for review December 3, 2026 10:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T10:34:40.126974Z 4d58b69 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d58b69f4e

ℹ️ 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".

Comment thread templateflow/client.py Resolved
Comment thread templateflow/conf/renames.py Resolved
oesteban and others added 2 commits December 3, 2026 16:27
New homes start from the v2 skeleton (current names, renames.tsv and a
manifest); existing homes keep the legacy skeleton until
`templateflow update --migrate`. ls() and get() resolve old names
through renames.tsv with a TemplateFlowAliasWarning (FutureWarning),
serve removed files until 27.0, and, in homes not yet migrated, find
old files with current queries. Adds get_atlas_metadata(), the
inversion entity, `+` in label and letters in scale, and fixes
get_metadata() and get() with DataLad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ones

ls() resolved old names only when a query found nothing, so a query that
also found current files dropped the renamed ones without a warning:
ls('A', desc=['CSF', 'brain'], suffix='probseg') returned desc-brain and
missed desc-CSF (now label-CSF). A query that finds files now also adds
renamed files it names by a value of their other name, with the warning
in migrated homes and silently in legacy ones. Entities it requires
absent (None) or present (Query.ANY) are still read in the home's names,
so current queries such as desc=None never warn. Removed files are
served to queries that find nothing else, as before.

Alias lookups now run on every query with renames, so rows are indexed
by template and path entities are parsed with the configuration loaded
once: 0.7 ms per query instead of 13 ms on a table of 2,700 rows. The
results are ordered like BIDSLayout.get() (natural sort).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oesteban and others added 3 commits December 3, 2026 16:37
…ames table

Runs templateflow 25.0.4, 25.1.2 and this branch (Python 3.13 and 3.14) against a
fixture Archive whose skeletons the real build-skeletons.py builds, before and after
a renames table, through a local S3 and skeleton server. Covers pinned clients,
update(), homes shared with --migrate, and DataLad homes; negative controls show the
matrix notices missing S3 copies and the v2 skeleton served at the legacy URL. The
accepted DataLad break of released clients is a strict expected failure.

The Compatibility workflow runs on pushes, pull requests and nightly, and replays a
proposed table (root rows or a template's .renames.tsv) on demand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
numpy, pandas, scipy, SQLAlchemy, PyYAML and greenlet publish cp315 wheels; the
matrix passes locally on 3.15 (16 passed, 2 xfailed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.53755% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.02%. Comparing base (418e87d) to head (839cb31).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
templateflow/client.py 75.29% 13 Missing and 8 partials ⚠️
templateflow/conf/renames.py 87.42% 6 Missing and 14 partials ⚠️
templateflow/conf/_s3.py 96.09% 2 Missing and 6 partials ⚠️
templateflow/conf/cache.py 86.00% 4 Missing and 3 partials ⚠️
templateflow/cli.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
+ Coverage   77.62%   84.02%   +6.39%     
==========================================
  Files           9       10       +1     
  Lines         447      920     +473     
  Branches       82      192     +110     
==========================================
+ Hits          347      773     +426     
- Misses         63       83      +20     
- Partials       37       64      +27     
Flag Coverage Δ
api,datalad 44.89% <36.16%> (-7.02%) ⬇️
api,dls3 20.97% <14.82%> (-6.32%) ⬇️
api,s3 52.28% <52.17%> (-4.99%) ⬇️
config 81.95% <87.74%> (+7.90%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

test: compatibility matrix of released clients before and after a renames table
@oesteban
oesteban merged commit 3e0954f into master Dec 3, 2026
19 checks passed
@oesteban
oesteban deleted the feat/archive-2 branch December 3, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant