Skip to content

Commit 003c889

Browse files
committed
FIX: Ensure templateflow Layout is re-indexed when updating
1 parent 1c473df commit 003c889

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

templateflow/conf/__init__.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@
4545
def update(local=False, overwrite=True, silent=False):
4646
"""Update an existing DataLad or S3 home."""
4747
if TF_USE_DATALAD and _update_datalad():
48-
return True
49-
50-
from ._s3 import update as _update_s3
48+
success = True
49+
else:
50+
from ._s3 import update as _update_s3
51+
success = _update_s3(TF_HOME, local=local, overwrite=overwrite, silent=silent)
5152

52-
return _update_s3(TF_HOME, local=local, overwrite=overwrite, silent=silent)
53+
# update Layout only if necessary
54+
if success and TF_LAYOUT is not None:
55+
init_layout()
56+
# ensure the api uses the updated layout
57+
import importlib
58+
from .. import api
59+
importlib.reload(api)
60+
return success
5361

5462

5563
def setup_home(force=False):
@@ -76,9 +84,12 @@ def _update_datalad():
7684

7785

7886
TF_LAYOUT = None
79-
try:
87+
88+
89+
def init_layout():
8090
from .bids import Layout
8191

92+
global TF_LAYOUT
8293
TF_LAYOUT = Layout(
8394
TF_HOME,
8495
validate=False,
@@ -92,5 +103,9 @@ def _update_datalad():
92103
"scripts",
93104
],
94105
)
106+
107+
108+
try:
109+
init_layout()
95110
except ImportError:
96111
pass

0 commit comments

Comments
 (0)