From 3d84b280305a6193ac7061ba73f392e46fd778d7 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Mon, 20 Oct 2025 21:33:21 -0700 Subject: [PATCH 1/5] Document TemplateFlow cache management in CLI and API stubs --- .gitignore | 1 - docs/api/templateflow.api.rst | 12 ++++++ docs/api/templateflow.cli.rst | 7 ++++ docs/api/templateflow.client.rst | 18 +++++++++ docs/api/templateflow.conf.rst | 22 +++++++++++ docs/cli.rst | 67 ++++++++++++++++++++++++++++++-- docs/datalad.rst | 16 ++++++++ 7 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 docs/api/templateflow.api.rst create mode 100644 docs/api/templateflow.cli.rst create mode 100644 docs/api/templateflow.client.rst create mode 100644 docs/api/templateflow.conf.rst diff --git a/.gitignore b/.gitignore index a31c2a55..48a6924c 100644 --- a/.gitignore +++ b/.gitignore @@ -73,7 +73,6 @@ instance/ # Sphinx documentation docs/_build/ -docs/api/ # PyBuilder target/ diff --git a/docs/api/templateflow.api.rst b/docs/api/templateflow.api.rst new file mode 100644 index 00000000..bbc491ae --- /dev/null +++ b/docs/api/templateflow.api.rst @@ -0,0 +1,12 @@ +templateflow.api module +======================= + +``templateflow.api`` mirrors the long-standing global helpers while delegating +all heavy lifting to a shared :class:`templateflow.client.TemplateFlowClient` +instance. The directives below document both the public functions and the +proxied client so that migration guides can reference consistent API signatures. + +.. automodule:: templateflow.api + :members: get, ls, templates, get_metadata, get_citations, TemplateFlowClient + :imported-members: + :member-order: bysource diff --git a/docs/api/templateflow.cli.rst b/docs/api/templateflow.cli.rst new file mode 100644 index 00000000..f9eaed25 --- /dev/null +++ b/docs/api/templateflow.cli.rst @@ -0,0 +1,7 @@ +templateflow.cli module +======================= + +.. automodule:: templateflow.cli + :members: + :undoc-members: + :member-order: bysource diff --git a/docs/api/templateflow.client.rst b/docs/api/templateflow.client.rst new file mode 100644 index 00000000..53f3929a --- /dev/null +++ b/docs/api/templateflow.client.rst @@ -0,0 +1,18 @@ +templateflow.client module +========================== + +The client module provides the object-oriented entry point around the global +cache described in :mod:`templateflow.conf`. Its documentation surfaces the +constructor, cache descriptor, and convenience methods so that downstream code +can migrate from the module-level API to the richer class interface. + +.. automodule:: templateflow.client + :members: TemplateFlowClient + :undoc-members: + :member-order: bysource + +.. autoclass:: templateflow.client.TemplateFlowClient + :members: + :special-members: __init__, __repr__ + :member-order: bysource + :show-inheritance: diff --git a/docs/api/templateflow.conf.rst b/docs/api/templateflow.conf.rst new file mode 100644 index 00000000..002731d3 --- /dev/null +++ b/docs/api/templateflow.conf.rst @@ -0,0 +1,22 @@ +templateflow.conf package +========================= + +``templateflow.conf`` centralizes configuration state for both the legacy module +level helpers (``update``/``wipe``) and the newer :class:`~templateflow.conf.cache.TemplateFlowCache` +object. The documentation below highlights the migration path so that users can +incrementally adopt the cache classes without losing backwards-compatible entry +points. + +.. automodule:: templateflow.conf + :members: requires_layout, setup_home, update, wipe + :imported-members: + :member-order: bysource + +Cache management classes +------------------------ + +.. automodule:: templateflow.conf.cache + :members: CacheConfig, TemplateFlowCache, S3Manager, DataladManager + :special-members: __init__ + :undoc-members: + :member-order: bysource diff --git a/docs/cli.rst b/docs/cli.rst index 33012261..c91fa119 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -9,7 +9,66 @@ Examples -------- Listing all the compressed NIfTI files in ``fsaverage``:: - $ templateflow ls fsaverage -x .nii.gz - ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_den-41k_T1w.nii.gz - ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_desc-brain_mask.nii.gz - ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_T1w.nii.gz + $ templateflow ls fsaverage -x .nii.gz + ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_den-41k_T1w.nii.gz + ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_desc-brain_mask.nii.gz + ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_T1w.nii.gz + +Managing client configuration +----------------------------- +The ``templateflow`` CLI transparently manipulates the same cache configuration used +by :class:`templateflow.client.TemplateFlowClient`. Running ``templateflow config`` +exposes the options stored in the underlying :class:`templateflow.conf.cache.CacheConfig` +instance:: + + $ templateflow config show + TEMPLATEFLOW_HOME=/home/user/.cache/templateflow + TEMPLATEFLOW_USE_DATALAD=0 + TEMPLATEFLOW_AUTOUPDATE=1 + TEMPLATEFLOW_GET_TIMEOUT=10 + +Changing a value updates the cached client configuration immediately. For example, +enabling the DataLad backend is equivalent to instantiating a client with +``TemplateFlowClient(use_datalad=True)`` because the command mutates the +``CacheConfig`` object used by the global client:: + + $ templateflow config set TEMPLATEFLOW_USE_DATALAD 1 + Updated TEMPLATEFLOW_USE_DATALAD → 1 (DataLad downloads will be used on next access) + +When the CLI is invoked afterwards, the cache will be re-initialized using +``use_datalad=True`` without requiring any additional Python code. The same +mechanism applies to paths (``TEMPLATEFLOW_HOME``), origins, and timeout +settings provided via ``templateflow config``. + +Updating an existing cache +-------------------------- +The :mod:`templateflow.conf` module exposes an ``update`` helper that the CLI +mirrors through ``templateflow update``. Executing the command instructs the +underlying :class:`templateflow.conf.cache.TemplateFlowCache` instance to refresh +its content using the currently selected backend:: + + $ templateflow update --silent + Cache mode: S3 + Cache root: /home/user/.cache/templateflow + TemplateFlow cache is up to date + +If ``TEMPLATEFLOW_USE_DATALAD`` (or ``--use-datalad``) is enabled, the command +delegates to :class:`templateflow.conf.cache.DataladManager` and performs a +recursive ``datalad update``. Otherwise the S3 manager fetches new or changed +files while keeping existing downloads intact. + +Wiping the cache +---------------- +The ``templateflow wipe`` command is a thin wrapper around +:meth:`templateflow.conf.cache.TemplateFlowCache.wipe`. It clears the local cache +and invalidates the in-memory layout so that subsequent ``templateflow`` CLI +calls or new :class:`templateflow.client.TemplateFlowClient` instances trigger a clean re-install:: + + $ templateflow wipe + Removing cache at /home/user/.cache/templateflow … + Cache cleared; next access will reinstall the archive + +In DataLad mode the wipe operation reports that no deletion occurs because +``TemplateFlowCache`` delegates to :class:`~templateflow.conf.cache.DataladManager`, +preserving the working tree. This makes it safe to toggle between backends via +``templateflow config`` without unintentionally removing a managed repository. diff --git a/docs/datalad.rst b/docs/datalad.rst index 22c97452..0a45c5ed 100644 --- a/docs/datalad.rst +++ b/docs/datalad.rst @@ -5,6 +5,22 @@ Therefore, it is possible (and recommended for those who want to leverage the power of DataLad) to access the Archive using just DataLad. +.. tip:: Prefer the Python client for routine access + + The high-level :class:`templateflow.client.TemplateFlowClient` can be + configured with ``use_datalad=True`` (or via ``templateflow config set + TEMPLATEFLOW_USE_DATALAD 1``) to transparently manage the cache with + DataLad. This is a good default when you want TemplateFlow to perform + ``datalad get`` and ``datalad update`` commands automatically while still + interacting with the archive through the familiar client API. + +.. note:: Drop down to raw DataLad when you need full control + + Advanced workflows—such as pinning remotes, creating custom siblings, or + operating entirely offline—are better served by running DataLad commands + directly. In those scenarios leave ``use_datalad`` disabled in the client + and use the instructions below to operate on the repository yourself. + Installing the Archive ---------------------- The archive is indexed by a superdataset, which can be installed with:: From c46cd4cc2cd1ce5f7883b94b54db3880c6b268a4 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 3 Dec 2026 17:57:11 +0100 Subject: [PATCH 2/5] docs: move the API pages' text into module docstrings sphinxcontrib-apidoc writes docs/api at every build, so the committed pages were overwritten and their text never reached the published docs. The text now lives in the docstrings of templateflow.api, templateflow.client, templateflow.conf and templateflow.conf.cache, which apidoc renders and help() shows; docs/api is ignored again. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + docs/api/templateflow.api.rst | 12 ------------ docs/api/templateflow.cli.rst | 7 ------- docs/api/templateflow.client.rst | 18 ------------------ docs/api/templateflow.conf.rst | 22 ---------------------- templateflow/api.py | 2 ++ templateflow/client.py | 8 +++++++- templateflow/conf/__init__.py | 9 ++++++++- templateflow/conf/cache.py | 7 +++++++ 9 files changed, 25 insertions(+), 61 deletions(-) delete mode 100644 docs/api/templateflow.api.rst delete mode 100644 docs/api/templateflow.cli.rst delete mode 100644 docs/api/templateflow.client.rst delete mode 100644 docs/api/templateflow.conf.rst diff --git a/.gitignore b/.gitignore index 48a6924c..a31c2a55 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/api/ # PyBuilder target/ diff --git a/docs/api/templateflow.api.rst b/docs/api/templateflow.api.rst deleted file mode 100644 index bbc491ae..00000000 --- a/docs/api/templateflow.api.rst +++ /dev/null @@ -1,12 +0,0 @@ -templateflow.api module -======================= - -``templateflow.api`` mirrors the long-standing global helpers while delegating -all heavy lifting to a shared :class:`templateflow.client.TemplateFlowClient` -instance. The directives below document both the public functions and the -proxied client so that migration guides can reference consistent API signatures. - -.. automodule:: templateflow.api - :members: get, ls, templates, get_metadata, get_citations, TemplateFlowClient - :imported-members: - :member-order: bysource diff --git a/docs/api/templateflow.cli.rst b/docs/api/templateflow.cli.rst deleted file mode 100644 index f9eaed25..00000000 --- a/docs/api/templateflow.cli.rst +++ /dev/null @@ -1,7 +0,0 @@ -templateflow.cli module -======================= - -.. automodule:: templateflow.cli - :members: - :undoc-members: - :member-order: bysource diff --git a/docs/api/templateflow.client.rst b/docs/api/templateflow.client.rst deleted file mode 100644 index 53f3929a..00000000 --- a/docs/api/templateflow.client.rst +++ /dev/null @@ -1,18 +0,0 @@ -templateflow.client module -========================== - -The client module provides the object-oriented entry point around the global -cache described in :mod:`templateflow.conf`. Its documentation surfaces the -constructor, cache descriptor, and convenience methods so that downstream code -can migrate from the module-level API to the richer class interface. - -.. automodule:: templateflow.client - :members: TemplateFlowClient - :undoc-members: - :member-order: bysource - -.. autoclass:: templateflow.client.TemplateFlowClient - :members: - :special-members: __init__, __repr__ - :member-order: bysource - :show-inheritance: diff --git a/docs/api/templateflow.conf.rst b/docs/api/templateflow.conf.rst deleted file mode 100644 index 002731d3..00000000 --- a/docs/api/templateflow.conf.rst +++ /dev/null @@ -1,22 +0,0 @@ -templateflow.conf package -========================= - -``templateflow.conf`` centralizes configuration state for both the legacy module -level helpers (``update``/``wipe``) and the newer :class:`~templateflow.conf.cache.TemplateFlowCache` -object. The documentation below highlights the migration path so that users can -incrementally adopt the cache classes without losing backwards-compatible entry -points. - -.. automodule:: templateflow.conf - :members: requires_layout, setup_home, update, wipe - :imported-members: - :member-order: bysource - -Cache management classes ------------------------- - -.. automodule:: templateflow.conf.cache - :members: CacheConfig, TemplateFlowCache, S3Manager, DataladManager - :special-members: __init__ - :undoc-members: - :member-order: bysource diff --git a/templateflow/api.py b/templateflow/api.py index 3b0be03a..06419fd1 100644 --- a/templateflow/api.py +++ b/templateflow/api.py @@ -23,6 +23,8 @@ """TemplateFlow's Python Client. ``templateflow.api`` provides a global, high-level interface to query the TemplateFlow archive. +Its functions keep the signatures of the original module-level helpers, and delegate to +one shared :class:`~templateflow.client.TemplateFlowClient`. There are two methods to initialize a client: diff --git a/templateflow/client.py b/templateflow/client.py index d0aa8782..5a7d4b11 100644 --- a/templateflow/client.py +++ b/templateflow/client.py @@ -20,7 +20,13 @@ # # https://www.nipreps.org/community/licensing/ # -"""TemplateFlow's Python Client.""" +"""TemplateFlow's Python Client. + +:class:`TemplateFlowClient` is the object-oriented interface to the TemplateFlow archive. +Each client has its own cache configuration (home folder, S3 or DataLad), while +:mod:`templateflow.api` shares one client set up from environment variables. Code written +for the module-level functions can move to a client without changing its queries. +""" from __future__ import annotations diff --git a/templateflow/conf/__init__.py b/templateflow/conf/__init__.py index ab7c24f2..da3d019c 100644 --- a/templateflow/conf/__init__.py +++ b/templateflow/conf/__init__.py @@ -1,4 +1,11 @@ -"""Configuration and settings.""" +"""Configuration and settings. + +``templateflow.conf`` holds the global cache that :mod:`templateflow.api` uses, and the +module-level helpers that act on it: :func:`setup_home`, ``update()`` and ``wipe()``. +The cache itself is a :class:`~templateflow.conf.cache.TemplateFlowCache`, configured by a +:class:`~templateflow.conf.cache.CacheConfig`; create one of these to manage another home +folder, and keep the module-level helpers for the global cache. +""" from functools import wraps from warnings import warn diff --git a/templateflow/conf/cache.py b/templateflow/conf/cache.py index 5de4f583..797bfbf1 100644 --- a/templateflow/conf/cache.py +++ b/templateflow/conf/cache.py @@ -20,6 +20,13 @@ # # https://www.nipreps.org/community/licensing/ # +"""The cache of a TemplateFlow home folder. + +:class:`CacheConfig` says where the home folder is and how it is filled; +:class:`TemplateFlowCache` installs, updates and wipes it, through :class:`S3Manager` or, +when DataLad is enabled, :class:`DataladManager`. +""" + from __future__ import annotations import re From 32bcb83419ace9ca1df8866b140f627efcaf7305 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 3 Dec 2026 19:11:08 +0100 Subject: [PATCH 3/5] docs: describe the CLI commands as they behave The CLI page documented commands and options that do not exist (`templateflow config show`, `config set`, `update --silent`, `--use-datalad`) and invented the output of `update` and `wipe`. Rewrite those sections from the real commands: `config` only prints the settings, which come from environment variables or TemplateFlowClient arguments; `update` adds missing skeleton files and keeps existing ones; `wipe` asks twice and deletes nothing in DataLad mode. The DataLad page's tip now points to the environment variable. Co-Authored-By: Claude Opus 5.5 --- docs/cli.rst | 116 +++++++++++++++++++++++++---------------------- docs/datalad.rst | 4 +- 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/docs/cli.rst b/docs/cli.rst index c91fa119..384b9197 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -14,61 +14,67 @@ Listing all the compressed NIfTI files in ``fsaverage``:: ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_desc-brain_mask.nii.gz ~/.cache/templateflow/tpl-fsaverage/tpl-fsaverage_res-01_T1w.nii.gz -Managing client configuration ------------------------------ -The ``templateflow`` CLI transparently manipulates the same cache configuration used -by :class:`templateflow.client.TemplateFlowClient`. Running ``templateflow config`` -exposes the options stored in the underlying :class:`templateflow.conf.cache.CacheConfig` -instance:: - - $ templateflow config show - TEMPLATEFLOW_HOME=/home/user/.cache/templateflow - TEMPLATEFLOW_USE_DATALAD=0 - TEMPLATEFLOW_AUTOUPDATE=1 - TEMPLATEFLOW_GET_TIMEOUT=10 - -Changing a value updates the cached client configuration immediately. For example, -enabling the DataLad backend is equivalent to instantiating a client with -``TemplateFlowClient(use_datalad=True)`` because the command mutates the -``CacheConfig`` object used by the global client:: - - $ templateflow config set TEMPLATEFLOW_USE_DATALAD 1 - Updated TEMPLATEFLOW_USE_DATALAD → 1 (DataLad downloads will be used on next access) - -When the CLI is invoked afterwards, the cache will be re-initialized using -``use_datalad=True`` without requiring any additional Python code. The same -mechanism applies to paths (``TEMPLATEFLOW_HOME``), origins, and timeout -settings provided via ``templateflow config``. - -Updating an existing cache --------------------------- -The :mod:`templateflow.conf` module exposes an ``update`` helper that the CLI -mirrors through ``templateflow update``. Executing the command instructs the -underlying :class:`templateflow.conf.cache.TemplateFlowCache` instance to refresh -its content using the currently selected backend:: - - $ templateflow update --silent - Cache mode: S3 - Cache root: /home/user/.cache/templateflow - TemplateFlow cache is up to date - -If ``TEMPLATEFLOW_USE_DATALAD`` (or ``--use-datalad``) is enabled, the command -delegates to :class:`templateflow.conf.cache.DataladManager` and performs a -recursive ``datalad update``. Otherwise the S3 manager fetches new or changed -files while keeping existing downloads intact. - -Wiping the cache ----------------- -The ``templateflow wipe`` command is a thin wrapper around -:meth:`templateflow.conf.cache.TemplateFlowCache.wipe`. It clears the local cache -and invalidates the in-memory layout so that subsequent ``templateflow`` CLI -calls or new :class:`templateflow.client.TemplateFlowClient` instances trigger a clean re-install:: +Showing the configuration +------------------------- +``templateflow config`` prints the settings the client runs with:: + + $ templateflow config + Current TemplateFlow settings: + + TEMPLATEFLOW_HOME=/home/user/.cache/templateflow + TEMPLATEFLOW_USE_DATALAD=off + TEMPLATEFLOW_AUTOUPDATE=on + +The command only reports these values. +They come from environment variables, read each time the client starts, +so a change applies to the commands run after it:: + + $ export TEMPLATEFLOW_HOME=$HOME/data/templateflow + +:doc:`installation` describes each variable. +In Python, :class:`~templateflow.client.TemplateFlowClient` also takes these +settings as arguments, for example ``TemplateFlowClient(use_datalad=True)``. + +Updating the Archive +-------------------- +``templateflow update`` brings the home folder up to date with the Archive. +In the default mode (direct download), it fetches the Archive's skeleton: +every file of every template, with the text files complete and empty +placeholders for images and surfaces. +It adds the files the home is missing and keeps those it already has, +downloaded or not. +Data are downloaded later, when ``templateflow get`` or the Python client +asks for them:: + + $ templateflow update + Updating TEMPLATEFLOW_HOME using S3. Adding: + tpl-Fischer344/ + tpl-Fischer344/template_description.json + tpl-Fischer344/tpl-Fischer344_T2w.nii.gz + ... + Successfully updated local TemplateFlow Archive: /home/user/.cache/templateflow. + +The list shows every file of the skeleton, including those the home already has. +With ``--no-overwrite`` it shows only the files added, and the command +prints ``TemplateFlow Archive not updated.`` when there are none. +``--local`` uses the skeleton that comes with the installed client instead of +downloading the latest one. + +In DataLad mode, the command runs ``datalad update --merge`` recursively, +which brings in the new commits of the superdataset and of every template. + +Wiping the home folder +---------------------- +``templateflow wipe`` deletes the home folder and everything downloaded into it. +It asks twice first: once to confirm, and once to type the folder's path:: $ templateflow wipe - Removing cache at /home/user/.cache/templateflow … - Cache cleared; next access will reinstall the archive + This will wipe out all data downloaded into /home/user/.cache/templateflow. + Do you want to continue? [y/N]: y + Please write the path of your local archive (/home/user/.cache/templateflow): /home/user/.cache/templateflow + /home/user/.cache/templateflow was wiped out. -In DataLad mode the wipe operation reports that no deletion occurs because -``TemplateFlowCache`` delegates to :class:`~templateflow.conf.cache.DataladManager`, -preserving the working tree. This makes it safe to toggle between backends via -``templateflow config`` without unintentionally removing a managed repository. +The next ``templateflow`` command sets the home folder up again, with the +skeleton and no data. +In DataLad mode nothing is deleted: the command prints +``TemplateFlow is configured in DataLad mode, wipe() has no effect``. diff --git a/docs/datalad.rst b/docs/datalad.rst index 0a45c5ed..981eca5f 100644 --- a/docs/datalad.rst +++ b/docs/datalad.rst @@ -8,8 +8,8 @@ DataLad. .. tip:: Prefer the Python client for routine access The high-level :class:`templateflow.client.TemplateFlowClient` can be - configured with ``use_datalad=True`` (or via ``templateflow config set - TEMPLATEFLOW_USE_DATALAD 1``) to transparently manage the cache with + configured with ``use_datalad=True`` (or with the environment variable + ``TEMPLATEFLOW_USE_DATALAD=on``) to transparently manage the cache with DataLad. This is a good default when you want TemplateFlow to perform ``datalad get`` and ``datalad update`` commands automatically while still interacting with the archive through the familiar client API. From 9cab7fffd8ef5a4cd2c8e52165af7febef82102d Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 3 Dec 2026 19:38:39 +0100 Subject: [PATCH 4/5] docs: drop the em dashes from the DataLad note Co-Authored-By: Claude Opus 5.5 --- docs/datalad.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/datalad.rst b/docs/datalad.rst index 981eca5f..10d39ff0 100644 --- a/docs/datalad.rst +++ b/docs/datalad.rst @@ -16,8 +16,8 @@ DataLad. .. note:: Drop down to raw DataLad when you need full control - Advanced workflows—such as pinning remotes, creating custom siblings, or - operating entirely offline—are better served by running DataLad commands + Advanced workflows, such as pinning remotes, creating custom siblings or + operating entirely offline, are better served by running DataLad commands directly. In those scenarios leave ``use_datalad`` disabled in the client and use the instructions below to operate on the repository yourself. From 51dcc3bc6c34e163e0bbc011d5c1470bae075d21 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 3 Dec 2026 20:01:31 +0100 Subject: [PATCH 5/5] docs: describe config and update as templateflow 26.0 behaves `templateflow config` now shows the home's layout, and `update` works differently in v2 homes (matched to the skeleton, with a one-line summary) and legacy homes (the 25.x listing); `--migrate` moves a legacy home to v2. Checked on a new home, a home created by templateflow 25.1.2, and its migration. Co-Authored-By: Claude Opus 5.5 --- docs/cli.rst | 59 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/docs/cli.rst b/docs/cli.rst index 384b9197..f297954e 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -25,6 +25,12 @@ Showing the configuration TEMPLATEFLOW_USE_DATALAD=off TEMPLATEFLOW_AUTOUPDATE=on + Home layout: v2 + +The home layout is ``v2`` for home folders created by templateflow 26.0 or +migrated to the TemplateFlow 2.0 names, ``legacy`` for those created by older +clients, and ``DataLad`` in DataLad mode. + The command only reports these values. They come from environment variables, read each time the client starts, so a change applies to the commands run after it:: @@ -38,30 +44,61 @@ settings as arguments, for example ``TemplateFlowClient(use_datalad=True)``. Updating the Archive -------------------- ``templateflow update`` brings the home folder up to date with the Archive. -In the default mode (direct download), it fetches the Archive's skeleton: +In the default mode (direct download), the home follows the Archive's skeleton: every file of every template, with the text files complete and empty placeholders for images and surfaces. -It adds the files the home is missing and keeps those it already has, -downloaded or not. Data are downloaded later, when ``templateflow get`` or the Python client -asks for them:: +asks for them. + +In ``v2`` homes, the command makes the home match the skeleton: it adds missing +files, refreshes text files, prunes placeholders of names the Archive no longer +uses, and turns downloads the Archive changed back into placeholders, so that +they are downloaded again when needed. +Other downloads are kept. +It prints what changed, or that nothing did:: + + $ templateflow update + Updating TEMPLATEFLOW_HOME using S3. Changes: 13 added. + Successfully updated local TemplateFlow Archive: /home/user/.cache/templateflow. + + $ templateflow update + TEMPLATEFLOW_HOME directory (S3 type) was up-to-date. + TemplateFlow Archive not updated. + +``legacy`` homes keep the names older clients use, so that those clients can +still share them. +There, the command adds the files the home is missing and keeps those it +already has:: $ templateflow update Updating TEMPLATEFLOW_HOME using S3. Adding: tpl-Fischer344/ tpl-Fischer344/template_description.json - tpl-Fischer344/tpl-Fischer344_T2w.nii.gz ... Successfully updated local TemplateFlow Archive: /home/user/.cache/templateflow. The list shows every file of the skeleton, including those the home already has. -With ``--no-overwrite`` it shows only the files added, and the command -prints ``TemplateFlow Archive not updated.`` when there are none. -``--local`` uses the skeleton that comes with the installed client instead of -downloading the latest one. +With ``--no-overwrite`` it shows only the files added, and the command prints +``TemplateFlow Archive not updated.`` when there are none. +``--no-overwrite`` has no effect in ``v2`` homes. + +``--migrate`` moves a ``legacy`` home to the TemplateFlow 2.0 names, making it a +``v2`` home: placeholders of old names are removed, and files downloaded under an +old name move to the new one when their checksum matches. +Older clients sharing the home lose the old names until they update it:: + + $ templateflow update --migrate + Updating TEMPLATEFLOW_HOME using S3. Changes: 1 added. + Successfully updated local TemplateFlow Archive: /home/user/.cache/templateflow. + +``--local`` does not download the latest skeleton: a ``v2`` home applies the +skeleton it already follows, and a ``legacy`` home the one that comes with the +installed client. -In DataLad mode, the command runs ``datalad update --merge`` recursively, -which brings in the new commits of the superdataset and of every template. +In DataLad mode, the command runs ``datalad update --merge`` recursively from +``origin``, which brings in the new commits of the superdataset and of every +template. +``--migrate`` has no effect there. Wiping the home folder ----------------------