Skip to content

Fix --no-compute-checksum #647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cwltool/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def execute(self, t, # type: Process
if self.final_output and self.final_output[0] and finaloutdir:
self.final_output[0] = relocateOutputs(self.final_output[0], finaloutdir,
self.output_dirs, kwargs.get("move_outputs"),
kwargs["make_fs_access"](""))
kwargs["make_fs_access"](""),
kwargs["compute_checksum"])

if kwargs.get("rm_tmpdir"):
cleanIntermediate(self.output_dirs)
Expand Down
8 changes: 4 additions & 4 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def collectFilesAndDirs(obj, out):
collectFilesAndDirs(l, out)


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

if action not in ("move", "copy"):
Expand Down Expand Up @@ -299,8 +299,8 @@ def _check_adjust(f):
return f

visit_class(outputObj, ("File", "Directory"), _check_adjust)

visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))
if compute_checksum:
visit_class(outputObj, ("File",), functools.partial(compute_checksums, fs_access))

# If there are symlinks to intermediate output directories, we want to move
# the real files into the final output location. If a file is linked more than once,
Expand Down
53 changes: 39 additions & 14 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,36 +559,36 @@ def test_print_dot(self):


class TestCmdLine(unittest.TestCase):
def get_main_stderr(self, new_args):
def get_main_output(self, new_args):
process = subprocess.Popen([
sys.executable,
"-m",
"cwltool"
] + new_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

stdout, stderr = process.communicate()
return process.returncode, stderr.decode()
return process.returncode, stdout.decode(), stderr.decode()


class TestJsConsole(TestCmdLine):

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

self.assertIn("[log] Log message", output)
self.assertIn("[err] Error message", output)
self.assertIn("[log] Log message", stderr)
self.assertIn("[err] Error message", stderr)

self.assertEquals(error_code, 0, output)
self.assertEquals(error_code, 0, stderr)

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

self.assertNotIn("[log] Log message", output)
self.assertNotIn("[err] Error message", output)
self.assertNotIn("[log] Log message", stderr)
self.assertNotIn("[err] Error message", stderr)


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

@pytest.mark.skipif(onWindows(),
reason="Instance of cwltool is used, on Windows it invokes a default docker container"
"which is not supported on AppVeyor")
class TestChecksum(TestCmdLine):

def test_compute_checksum(self):
f = cwltool.factory.Factory(compute_checksum=True, use_container=False)
echo = f.make(get_data("tests/wf/cat-tool.cwl"))
output = echo(file1={
"class": "File",
"location": get_data("tests/wf/whale.txt")
},
reverse=False
)
self.assertEquals(output['output']["checksum"], "sha1$327fc7aedf4f6b69a42a7c8b808dc5a7aff61376")

def test_no_compute_checksum(self):
test_file = "tests/wf/wc-tool.cwl"
job_file = "tests/wf/wc-job.json"
error_code, stdout, stderr = self.get_main_output(["--no-compute-checksum",
get_data(test_file), get_data(job_file)])
self.assertIn("completed success", stderr)
self.assertEquals(error_code, 0)
self.assertNotIn("checksum", stdout)


if __name__ == '__main__':
unittest.main()
17 changes: 17 additions & 0 deletions tests/wf/cat-tool.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env cwl-runner

class: CommandLineTool
cwlVersion: v1.0

inputs:
file1: File

outputs:
output:
type: File
outputBinding: { glob: output }

baseCommand: [cat]

stdin: $(inputs.file1.path)
stdout: output