Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/cwltool/tests/test_singularity.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 import sys | |
| 2 import os | |
| 3 import pytest | |
| 4 | |
| 5 import distutils.spawn | |
| 6 | |
| 7 import schema_salad.validate | |
| 8 | |
| 9 from cwltool.main import main | |
| 10 | |
| 11 from .util import (get_data, get_main_output, needs_singularity, | |
| 12 needs_singularity_2_6, working_directory) | |
| 13 | |
| 14 sys.argv = [''] | |
| 15 | |
| 16 | |
| 17 @needs_singularity_2_6 | |
| 18 def test_singularity_pullfolder(tmp_path): | |
| 19 workdir = tmp_path / "working_dir_new" | |
| 20 workdir.mkdir() | |
| 21 os.chdir(str(workdir)) | |
| 22 pullfolder = tmp_path / "pullfolder" | |
| 23 pullfolder.mkdir() | |
| 24 env = os.environ.copy() | |
| 25 env["SINGULARITY_PULLFOLDER"] = str(pullfolder) | |
| 26 result_code, stdout, stderr = get_main_output( | |
| 27 ['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"], env=env) | |
| 28 print(stdout) | |
| 29 print(stderr) | |
| 30 assert result_code == 0 | |
| 31 image = pullfolder/"debian.img" | |
| 32 assert image.exists() | |
| 33 | |
| 34 @needs_singularity | |
| 35 def test_singularity_workflow(tmpdir): | |
| 36 with working_directory(str(tmpdir)): | |
| 37 error_code, _, stderr = get_main_output( | |
| 38 ['--singularity', '--default-container', 'debian', '--debug', | |
| 39 get_data("tests/wf/hello-workflow.cwl"), "--usermessage", "hello"]) | |
| 40 assert "completed success" in stderr, stderr | |
| 41 assert error_code == 0 | |
| 42 | |
| 43 def test_singularity_iwdr(): | |
| 44 result_code = main( | |
| 45 ['--singularity', '--default-container', 'debian', | |
| 46 get_data("tests/wf/iwdr-entry.cwl"), "--message", "hello"]) | |
| 47 singularity_installed = bool(distutils.spawn.find_executable('singularity')) | |
| 48 if singularity_installed: | |
| 49 assert result_code == 0 | |
| 50 else: | |
| 51 assert result_code != 0 | |
| 52 | |
| 53 @needs_singularity | |
| 54 def test_singularity_incorrect_image_pull(): | |
| 55 result_code, _, stderr = get_main_output( | |
| 56 ['--singularity', '--default-container', 'non-existant-weird-image', | |
| 57 get_data("tests/wf/hello-workflow.cwl"), "--usermessage", "hello"]) | |
| 58 assert result_code != 0 | |
| 59 | |
| 60 @needs_singularity | |
| 61 def test_singularity_local(tmp_path): | |
| 62 workdir = tmp_path / "working_dir" | |
| 63 workdir.mkdir() | |
| 64 os.chdir(str(workdir)) | |
| 65 result_code, stdout, stderr = get_main_output( | |
| 66 ['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"]) | |
| 67 assert result_code == 0 | |
| 68 | |
| 69 @needs_singularity_2_6 | |
| 70 def test_singularity_docker_image_id_in_tool(tmp_path): | |
| 71 workdir = tmp_path / "working_dir" | |
| 72 workdir.mkdir() | |
| 73 os.chdir(str(workdir)) | |
| 74 result_code, stdout, stderr = get_main_output( | |
| 75 ['--singularity', get_data("tests/sing_pullfolder_test.cwl"), "--message", "hello"]) | |
| 76 result_code1, stdout, stderr = get_main_output( | |
| 77 ['--singularity', get_data("tests/debian_image_id.cwl"), "--message", "hello"]) | |
| 78 assert result_code1 == 0 |
