← 输入框|github.com|刷新
Skip to content

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

Open
oesteban wants to merge 1 commit into
masterfrom
feat/archive-2
Open

oesteban wants to merge 1 commit 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
+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.
  • 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: 79 pass (pytest -n 4 --doctest-modules templateflow), including the existing suite against live S3. The 40 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 alias resolution in v2, legacy, both-names and DataLad-style homes. 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.

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>
@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
paths.append(path)
notes.append(f'{row.old} was removed from the Archive and S3 no longer serves it.')

if paths or not renames and self.cache.generation != 'legacy':

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve rename fallbacks alongside direct matches

When a query has any directly indexed results, this returns before checking renamed or removed entries. For example, in a v2 home ls('fsaverage', suffix='dseg', segmentation=None) finds current dseg files but skips the renamed tpl-fsaverage_dseg.tsv, whose old name matches that query. Merge the fallback results with direct matches instead of only checking fallbacks when paths is empty.

Useful? React with 👍 / 👎.

continue
none = None in values or Query.NONE in values
required = Query.REQUIRED in values
values = [v for v in values if v is not None and not isinstance(v, Query)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat Query.ANY as an entity-presence check

Alias matching uses match_entities(), but this removes Query.ANY from values without treating it as a presence requirement. The subsequent comparison against the empty list returns false even when the entity is present, so a current-name query such as ls('A', label=Query.ANY, suffix='probseg') cannot resolve old-name files in a legacy home. Handle Query.ANY as a presence check before filtering query sentinels.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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