Skip to content

Commit 3bd7c69

Browse files
committed
better relocation of remote resources
1 parent 50d86c5 commit 3bd7c69

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

cwltool/process.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,17 @@ def _relocate(src, dst):
304304
# outside of the source directories
305305
if any(src.startswith(path + "/") for path in source_directories):
306306
_logger.debug("Moving %s to %s", src, dst)
307-
if os.path.isdir(src) and os.path.isdir(dst):
307+
if fs_access.isdir(src) and fs_access.isdir(dst):
308308
# merge directories
309309
for dir_entry in scandir(src):
310-
_relocate(dir_entry, os.path.join(dst, dir_entry.name))
310+
_relocate(dir_entry, fs_access.join(
311+
dst, dir_entry.name))
311312
else:
312313
shutil.move(src, dst)
313314
return
314315

315316
_logger.debug("Copying %s to %s", src, dst)
316-
if os.path.isdir(src):
317+
if fs_access.isdir(src):
317318
if os.path.isdir(dst):
318319
shutil.rmtree(dst)
319320
elif os.path.isfile(dst):
@@ -326,15 +327,13 @@ def _relocate(src, dst):
326327
pm = path_mapper(outfiles, "", destination_path, separateDirs=False)
327328
stageFiles(pm, stageFunc=_relocate, symLink=False)
328329

329-
def _check_adjust(file):
330-
file["location"] = file_uri(pm.mapper(file["location"])[1])
331-
if "contents" in file:
332-
del file["contents"]
333-
return file
330+
def _check_adjust(a_file):
331+
a_file["location"] = file_uri(pm.mapper(a_file["location"])[1])
332+
if "contents" in a_file:
333+
del a_file["contents"]
334+
return a_file
334335

335336
visit_class(outputObj, ("File", "Directory"), _check_adjust)
336-
if compute_checksum:
337-
visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
338337

339338
# If there are symlinks to intermediate output directories, we want to move
340339
# the real files into the final output location. If a file is linked more than once,
@@ -369,6 +368,9 @@ def relink(relinked, # type: Dict[Text, Text]
369368
relinked = {} # type: Dict[Text, Text]
370369
relink(relinked, destination_path)
371370

371+
if compute_checksum:
372+
visit_class(outputObj, ("File",), functools.partial(
373+
compute_checksums, fs_access))
372374
return outputObj
373375

374376

cwltool/workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def __init__(self,
675675
toolpath_object[toolfield].append(param)
676676

677677
missing = []
678-
for i, tool_entry in enumerate(self.embedded_tool.tool["inputs"]):
678+
for _, tool_entry in enumerate(self.embedded_tool.tool["inputs"]):
679679
if shortname(tool_entry["id"]) not in bound:
680680
if "null" not in tool_entry["type"] and "default" not in tool_entry:
681681
missing.append(shortname(tool_entry["id"]))
@@ -730,7 +730,7 @@ def __init__(self,
730730
else:
731731
nesting = 1
732732

733-
for index in range(0, nesting):
733+
for _ in range(0, nesting):
734734
for oparam in outputparms:
735735
oparam["type"] = {"type": "array", "items": oparam["type"]}
736736
self.tool["inputs"] = inputparms

0 commit comments

Comments
 (0)