Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion templateflow/conf/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
18 changes: 18 additions & 0 deletions templateflow/tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Loading