diff --git a/CHANGES.rst b/CHANGES.rst index 28495d9..04715f2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,14 +18,25 @@ Unreleased Archive are shipped with tfmanager (``migrate/data/headers-2.0.0.tsv``). Snapshots of templates, from the v2 skeleton zip or from a checkout, have the same fingerprint. * The new names of the migration to TemplateFlow 2.0: ``tfmanager.migrate.names`` renames - the files of a template (rules R01 to R20, then R99) from its snapshot, the header facts + the files of a template (rules R01 to R22, then R99) from its snapshot, the header facts and the decisions of ``migrate/config/2.0.0.yaml`` (atlas labels, renames of single templates, ``res`` keys). Every volume takes the ``res`` key of its grid: blocks that no file matches are rebuilt from their files, and volumes off their block take a new key. Findings M101 to M113 block a plan (uncovered names come with a decision to fill in), and ``migrate.renames`` merges and checks a template's ``.renames.tsv`` as the template - action reads it. A test pins the renames of the Archive - (``tests/data/renames-2.0.0.tsv``). + action reads it. A probabilistic segmentation of one volume names its class with + ``label`` (R21), and a file renamed onto a copy with the same bytes merges into it + (R22). A test pins the renames of the Archive (``tests/data/renames-2.0.0.tsv``). +* The content of the migration to TemplateFlow 2.0: ``tfmanager.migrate.content`` updates + the files of a template after its renames. References to renamed files follow them in + JSON files (T05); template_description.json takes ``res`` blocks that fit its files' + headers, ``RRID:`` prefixes, ``Funding`` as a list and cohort ages as ``[min, max]`` + (T06); files written by hand (T10), the generated files (T08) and ``.gitattributes`` + (T09) are written; and, only when the result passes the validator in strict mode, the + versions change and CHANGES gets a 2.0.0 entry (T11). ``migrate.engine.plan_template`` + joins names and content: a renamed file whose bytes change gets an ``n/a`` row, so its + old name keeps its old bytes. The config's ``edits`` correct fields of JSON files. A test + pins the ``res`` blocks of the migrated Archive (``tests/data/res-2.0.0.tsv``). * New warning TF118 redundant-entity: a ``desc``, ``seg`` or ``label`` that tells its file apart from no other file of the template (``res``, ``den``, ``hemi`` and ``cohort`` aside). Masks keep ``desc``, probabilistic segmentations keep ``label``, and diff --git a/tfmanager/migrate/config.py b/tfmanager/migrate/config.py index 88c2559..579b7ea 100644 --- a/tfmanager/migrate/config.py +++ b/tfmanager/migrate/config.py @@ -48,6 +48,24 @@ def matches(self, entities: dict, suffix: str | None, extension: str) -> bool: return True +@dataclass(frozen=True) +class Edit: + """Fields to set or remove in a JSON file of one template, after the renames (``edits``).""" + + id: str + template: str + path: str + """The file's new name, relative to the template.""" + why: str + set: dict = field(default_factory=dict) + remove: tuple[str, ...] = () + + def apply(self, data: dict) -> dict: + out = {k: v for k, v in data.items() if k not in self.remove} + out.update(self.set) + return out + + @dataclass(frozen=True) class Config: version: str @@ -56,6 +74,8 @@ class Config: renames: tuple[Rename, ...] = () res_assign: dict = field(default_factory=dict) """``tpl-