Skip to content

Commit 1d6fea7

Browse files
committed
Merge pull request #1179 from chrisfilo/fix/memory_cd
better handling of errors when using caching
2 parents 30a9453 + d2abdc9 commit 1d6fea7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nipype/caching/memory.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ def __call__(self, **kwargs):
7676
job_name = hasher.hexdigest()
7777
node = Node(interface, name=job_name)
7878
node.base_dir = os.path.join(self.base_dir, dir_name)
79-
out = node.run()
79+
80+
cwd = os.getcwd()
81+
try:
82+
out = node.run()
83+
finally:
84+
# node.run() changes to the node directory - if something goes wrong
85+
# before it cds back you would end up in strange places
86+
os.chdir(cwd)
8087
if self.callback is not None:
8188
self.callback(dir_name, job_name)
8289
return out

0 commit comments

Comments
 (0)