Skip to content

Commit 6475d4b

Browse files
author
Anton Khodak
committed
Fix --no-compute-checksum
1 parent af59ba2 commit 6475d4b

File tree

4 files changed

+62
-19
lines changed

4 files changed

+62
-19
lines changed

cwltool/executors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def execute(self, t, # type: Process
7171
if self.final_output and self.final_output[0] and finaloutdir:
7272
self.final_output[0] = relocateOutputs(self.final_output[0], finaloutdir,
7373
self.output_dirs, kwargs.get("move_outputs"),
74-
kwargs["make_fs_access"](""))
74+
kwargs["make_fs_access"](""),
75+
kwargs["compute_checksum"])
7576

7677
if kwargs.get("rm_tmpdir"):
7778
cleanIntermediate(self.output_dirs)

cwltool/process.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def collectFilesAndDirs(obj, out):
256256
collectFilesAndDirs(l, out)
257257

258258

259-
def relocateOutputs(outputObj, outdir, output_dirs, action, fs_access):
260-
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Set[Text], Text, StdFsAccess) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
259+
def relocateOutputs(outputObj, outdir, output_dirs, action, fs_access, compute_checksum):
260+
# type: (Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Set[Text], Text, StdFsAccess, bool) -> Union[Dict[Text, Any], List[Dict[Text, Any]]]
261261
adjustDirObjs(outputObj, functools.partial(get_listing, fs_access, recursive=True))
262262

263263
if action not in ("move", "copy"):
@@ -299,8 +299,8 @@ def _check_adjust(f):
299299
return f
300300

301301
visit_class(outputObj, ("File", "Directory"), _check_adjust)
302-
303-
visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
302+
if compute_checksum:
303+
visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
304304

305305
# If there are symlinks to intermediate output directories, we want to move
306306
# the real files into the final output location. If a file is linked more than once,

tests/test_examples.py

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -559,36 +559,36 @@ def test_print_dot(self):
559559

560560

561561
class TestCmdLine(unittest.TestCase):
562-
def get_main_stderr(self, new_args):
562+
def get_main_output(self, new_args):
563563
process = subprocess.Popen([
564564
sys.executable,
565565
"-m",
566566
"cwltool"
567567
] + new_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
568568

569569
stdout, stderr = process.communicate()
570-
return process.returncode, stderr.decode()
570+
return process.returncode, stdout.decode(), stderr.decode()
571571

572572

573573
class TestJsConsole(TestCmdLine):
574574

575575
def test_js_console_cmd_line_tool(self):
576576
for test_file in ("js_output.cwl", "js_output_workflow.cwl"):
577-
error_code, output = self.get_main_stderr(["--js-console", "--no-container",
578-
get_data("tests/wf/" + test_file)])
577+
error_code, stdout, stderr = self.get_main_output(["--js-console", "--no-container",
578+
get_data("tests/wf/" + test_file)])
579579

580-
self.assertIn("[log] Log message", output)
581-
self.assertIn("[err] Error message", output)
580+
self.assertIn("[log] Log message", stderr)
581+
self.assertIn("[err] Error message", stderr)
582582

583-
self.assertEquals(error_code, 0, output)
583+
self.assertEquals(error_code, 0, stderr)
584584

585585
def test_no_js_console(self):
586586
for test_file in ("js_output.cwl", "js_output_workflow.cwl"):
587-
error_code, output = self.get_main_stderr(["--no-container",
588-
get_data("tests/wf/" + test_file)])
587+
error_code, stdout, stderr = self.get_main_output(["--no-container",
588+
get_data("tests/wf/" + test_file)])
589589

590-
self.assertNotIn("[log] Log message", output)
591-
self.assertNotIn("[err] Error message", output)
590+
self.assertNotIn("[log] Log message", stderr)
591+
self.assertNotIn("[err] Error message", stderr)
592592

593593

594594
@pytest.mark.skipif(onWindows(),
@@ -597,11 +597,36 @@ def test_no_js_console(self):
597597
class TestCache(TestCmdLine):
598598
def test_wf_without_container(self):
599599
test_file = "hello-workflow.cwl"
600-
error_code, output = self.get_main_stderr(["--cachedir", "cache",
601-
get_data("tests/wf/" + test_file), "--usermessage", "hello"])
602-
self.assertIn("completed success", output)
600+
error_code, stdout, stderr = self.get_main_output(["--cachedir", "cache",
601+
get_data("tests/wf/" + test_file), "--usermessage", "hello"])
602+
self.assertIn("completed success", stderr)
603603
self.assertEquals(error_code, 0)
604604

605+
@pytest.mark.skipif(onWindows(),
606+
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
607+
"which is not supported on AppVeyor")
608+
class TestChecksum(TestCmdLine):
609+
610+
def test_compute_checksum(self):
611+
f = cwltool.factory.Factory(compute_checksum=True, use_container=False)
612+
echo = f.make(get_data("tests/wf/cat-tool.cwl"))
613+
output = echo(file1={
614+
"class": "File",
615+
"location": get_data("tests/wf/whale.txt")
616+
},
617+
reverse=False
618+
)
619+
self.assertEquals(output['output']["checksum"], "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376")
620+
621+
def test_no_compute_checksum(self):
622+
test_file = "tests/wf/wc-tool.cwl"
623+
job_file = "tests/wf/wc-job.json"
624+
error_code, stdout, stderr = self.get_main_output(["--no-compute-checksum",
625+
get_data(test_file), get_data(job_file)])
626+
self.assertIn("completed success", stderr)
627+
self.assertEquals(error_code, 0)
628+
self.assertNotIn("checksum", stdout)
629+
605630

606631
if __name__ == '__main__':
607632
unittest.main()

tests/wf/cat-tool.cwl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
class: CommandLineTool
4+
cwlVersion: v1.0
5+
6+
inputs:
7+
file1: File
8+
9+
outputs:
10+
output:
11+
type: File
12+
outputBinding: { glob: output }
13+
14+
baseCommand: [cat]
15+
16+
stdin: $(inputs.file1.path)
17+
stdout: output

0 commit comments

Comments
 (0)