From a0c41587b626e662fab31ab883ae4825683f1018 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Thu, 3 Dec 2026 18:41:13 +0100 Subject: [PATCH] fix: update DataLad homes from origin only Without a sibling, `datalad update` fetches from every remote of every dataset. Each template autoenables a git remote on GIN (gin-src), so a DataLad home failed to update whenever GIN refused one fetch, although the update merges from origin (GitHub) only. CircleCI's test_setup_home[on] failed this way when GIN answered 403 for all 30 templates. File contents are unaffected: git-annex still gets them from S3 or GIN. Co-Authored-By: Claude Opus 5.5 --- templateflow/conf/cache.py | 5 ++++- templateflow/tests/test_conf.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/templateflow/conf/cache.py b/templateflow/conf/cache.py index 62e6ea1b..a4622aca 100644 --- a/templateflow/conf/cache.py +++ b/templateflow/conf/cache.py @@ -104,7 +104,10 @@ def update(self, path: Path, local: bool, overwrite: bool, silent: bool, timeout print('Updating TEMPLATEFLOW_HOME using DataLad ...') try: - update(dataset=path, recursive=True, merge=True) + # Fetch from origin only, which the update merges from: without a sibling, + # DataLad also fetches from every other remote, such as GIN (gin-src), + # and fails when one of them does + update(dataset=path, sibling='origin', recursive=True, merge=True) except Exception as e: # noqa: BLE001 warn( f"Error updating TemplateFlow's home directory (using DataLad): {e}", diff --git a/templateflow/tests/test_conf.py b/templateflow/tests/test_conf.py index 59aeb86c..93c78941 100644 --- a/templateflow/tests/test_conf.py +++ b/templateflow/tests/test_conf.py @@ -163,3 +163,21 @@ def mock_import(name, globals=None, locals=None, fromlist=(), level=0): # noqa: m.setattr(builtins, '__import__', mock_import) with pytest.raises(ImportError): myfunc() + + +def test_datalad_update_fetches_origin(monkeypatch, tmp_path): + """DataLad homes fetch from origin only: other siblings, such as GIN, may refuse.""" + import sys + from types import ModuleType + + from templateflow.conf.cache import DataladManager + + calls = [] + api = ModuleType('datalad.api') + api.update = lambda **kwargs: calls.append(kwargs) + monkeypatch.setitem(sys.modules, 'datalad', ModuleType('datalad')) + monkeypatch.setitem(sys.modules, 'datalad.api', api) + + manager = DataladManager(source='https://github.com/templateflow/templateflow.git') + assert manager.update(tmp_path, local=False, overwrite=True, silent=True, timeout=10) + assert calls == [{'dataset': tmp_path, 'sibling': 'origin', 'recursive': True, 'merge': True}]