Skip to content

Commit b125007

Browse files
committed
Makes S3DataGrabber change all paths from s3 to local
Previously, S3DataGrabber checked if outputs were lists or strings, and changed them in those cases. However, if output was a unicode, then it went unchanged. That's clearly not what we want, so we now change in all cases: iterating through all values of output if it has __iter__ attribute (is list-like), and using the value as the path if it doesn't.
1 parent 6a8f6d6 commit b125007

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

nipype/interfaces/io.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,17 @@ def _list_outputs(self):
656656
# Outputs are currently stored as locations on S3.
657657
# We must convert to the local location specified
658658
# and download the files.
659-
for key in outputs:
660-
if type(outputs[key]) == list:
661-
paths = outputs[key]
662-
for i in range(len(paths)):
663-
path = paths[i]
659+
for key,val in outputs.iteritems():
660+
#This will basically be either list-like or string-like:
661+
#if it has the __iter__ attribute, it's list-like (list,
662+
#tuple, numpy array) and we iterate through each of its
663+
#values. If it doesn't, it's string-like (string,
664+
#unicode), and we convert that value directly.
665+
if hasattr(val,'__iter__'):
666+
for i,path in enumerate(val):
664667
outputs[key][i] = self.s3tolocal(path, bkt)
665-
elif type(outputs[key]) == str:
666-
outputs[key] = self.s3tolocal(outputs[key], bkt)
668+
else:
669+
outputs[key] = self.s3tolocal(val, bkt)
667670

668671
return outputs
669672

0 commit comments

Comments
 (0)