Skip to content

Commit 4d450da

Browse files
author
Anton Khodak
committed
Fix --no-compute-checksum
1 parent 52c276d commit 4d450da

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

cwltool/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ def output_callback(out, processStatus):
308308
if final_output and final_output[0] and finaloutdir:
309309
final_output[0] = relocateOutputs(final_output[0], finaloutdir,
310310
output_dirs, kwargs.get("move_outputs"),
311-
kwargs["make_fs_access"](""))
311+
kwargs["make_fs_access"](""),
312+
kwargs["compute_checksum"])
312313

313314
if kwargs.get("rm_tmpdir"):
314315
cleanIntermediate(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
@@ -533,36 +533,36 @@ def test_print_dot(self):
533533

534534

535535
class TestCmdLine(unittest.TestCase):
536-
def get_main_stderr(self, new_args):
536+
def get_main_output(self, new_args):
537537
process = subprocess.Popen([
538538
sys.executable,
539539
"-m",
540540
"cwltool"
541541
] + new_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
542542

543543
stdout, stderr = process.communicate()
544-
return process.returncode, stderr.decode()
544+
return process.returncode, stdout.decode(), stderr.decode()
545545

546546

547547
class TestJsConsole(TestCmdLine):
548548

549549
def test_js_console_cmd_line_tool(self):
550550
for test_file in ("js_output.cwl", "js_output_workflow.cwl"):
551-
error_code, output = self.get_main_stderr(["--js-console", "--no-container",
552-
get_data("tests/wf/" + test_file)])
551+
error_code, stdout, stderr = self.get_main_output(["--js-console", "--no-container",
552+
get_data("tests/wf/" + test_file)])
553553

554-
self.assertIn("[log] Log message", output)
555-
self.assertIn("[err] Error message", output)
554+
self.assertIn("[log] Log message", stderr)
555+
self.assertIn("[err] Error message", stderr)
556556

557-
self.assertEquals(error_code, 0, output)
557+
self.assertEquals(error_code, 0, stderr)
558558

559559
def test_no_js_console(self):
560560
for test_file in ("js_output.cwl", "js_output_workflow.cwl"):
561-
error_code, output = self.get_main_stderr(["--no-container",
562-
get_data("tests/wf/" + test_file)])
561+
error_code, stdout, stderr = self.get_main_output(["--no-container",
562+
get_data("tests/wf/" + test_file)])
563563

564-
self.assertNotIn("[log] Log message", output)
565-
self.assertNotIn("[err] Error message", output)
564+
self.assertNotIn("[log] Log message", stderr)
565+
self.assertNotIn("[err] Error message", stderr)
566566

567567

568568
@pytest.mark.skipif(onWindows(),
@@ -571,11 +571,36 @@ def test_no_js_console(self):
571571
class TestCache(TestCmdLine):
572572
def test_wf_without_container(self):
573573
test_file = "hello-workflow.cwl"
574-
error_code, output = self.get_main_stderr(["--cachedir", "cache",
575-
get_data("tests/wf/" + test_file), "--usermessage", "hello"])
576-
self.assertIn("completed success", output)
574+
error_code, stdout, stderr = self.get_main_output(["--cachedir", "cache",
575+
get_data("tests/wf/" + test_file), "--usermessage", "hello"])
576+
self.assertIn("completed success", stderr)
577577
self.assertEquals(error_code, 0)
578578

579+
@pytest.mark.skipif(onWindows(),
580+
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
581+
"which is not supported on AppVeyor")
582+
class TestChecksum(TestCmdLine):
583+
584+
def test_compute_checksum(self):
585+
f = cwltool.factory.Factory(compute_checksum=True, use_container=False)
586+
echo = f.make(get_data("tests/wf/sorttool.cwl"))
587+
output = echo(input={
588+
"class": "File",
589+
"location": "tests/wf/whale.txt"
590+
},
591+
reverse=False
592+
)
593+
self.assertEquals(output['output']["checksum"], "sha1$d6aa72aec3efd0cc7682c0139aa3ce8c10e5bcd7")
594+
595+
def test_no_compute_checksum(self):
596+
test_file = "tests/wf/wc-tool.cwl"
597+
job_file = "tests/wf/wc-job.json"
598+
error_code, stdout, stderr = self.get_main_output(["--no-compute-checksum",
599+
get_data(test_file), get_data(job_file)])
600+
self.assertIn("completed success", stderr)
601+
self.assertEquals(error_code, 0)
602+
self.assertNotIn("checksum", stdout)
603+
579604

580605
if __name__ == '__main__':
581606
unittest.main()

0 commit comments

Comments
 (0)