Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/cwltool/tests/test_singularity.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import distutils.spawn | |
2 import os | |
3 import sys | |
4 from pathlib import Path | |
5 | |
6 from cwltool.main import main | |
7 | |
8 from .util import ( | |
9 get_data, | |
10 get_main_output, | |
11 needs_singularity, | |
12 needs_singularity_2_6, | |
13 working_directory, | |
14 ) | |
15 | |
16 sys.argv = [""] | |
17 | |
18 | |
19 @needs_singularity_2_6 | |
20 def test_singularity_pullfolder(tmp_path: Path) -> None: | |
21 workdir = tmp_path / "working_dir_new" | |
22 workdir.mkdir() | |
23 os.chdir(workdir) | |
24 pullfolder = tmp_path / "pullfolder" | |
25 pullfolder.mkdir() | |
26 env = os.environ.copy() | |
27 env["SINGULARITY_PULLFOLDER"] = str(pullfolder) | |
28 result_code, stdout, stderr = get_main_output( | |
29 [ | |
30 "--singularity", | |
31 get_data("tests/sing_pullfolder_test.cwl"), | |
32 "--message", | |
33 "hello", | |
34 ], | |
35 env=env, | |
36 ) | |
37 print(stdout) | |
38 print(stderr) | |
39 assert result_code == 0 | |
40 image = pullfolder / "debian.img" | |
41 assert image.exists() | |
42 | |
43 | |
44 @needs_singularity | |
45 def test_singularity_workflow(tmp_path: Path) -> None: | |
46 with working_directory(tmp_path): | |
47 error_code, _, stderr = get_main_output( | |
48 [ | |
49 "--singularity", | |
50 "--default-container", | |
51 "debian", | |
52 "--debug", | |
53 get_data("tests/wf/hello-workflow.cwl"), | |
54 "--usermessage", | |
55 "hello", | |
56 ] | |
57 ) | |
58 assert "completed success" in stderr, stderr | |
59 assert error_code == 0 | |
60 | |
61 | |
62 def test_singularity_iwdr() -> None: | |
63 result_code = main( | |
64 [ | |
65 "--singularity", | |
66 "--default-container", | |
67 "debian", | |
68 get_data("tests/wf/iwdr-entry.cwl"), | |
69 "--message", | |
70 "hello", | |
71 ] | |
72 ) | |
73 singularity_installed = bool(distutils.spawn.find_executable("singularity")) | |
74 if singularity_installed: | |
75 assert result_code == 0 | |
76 else: | |
77 assert result_code != 0 | |
78 | |
79 | |
80 @needs_singularity | |
81 def test_singularity_incorrect_image_pull() -> None: | |
82 result_code, _, stderr = get_main_output( | |
83 [ | |
84 "--singularity", | |
85 "--default-container", | |
86 "non-existant-weird-image", | |
87 get_data("tests/wf/hello-workflow.cwl"), | |
88 "--usermessage", | |
89 "hello", | |
90 ] | |
91 ) | |
92 assert result_code != 0 | |
93 | |
94 | |
95 @needs_singularity | |
96 def test_singularity_local(tmp_path: Path) -> None: | |
97 workdir = tmp_path / "working_dir" | |
98 workdir.mkdir() | |
99 os.chdir(workdir) | |
100 result_code, stdout, stderr = get_main_output( | |
101 [ | |
102 "--singularity", | |
103 get_data("tests/sing_pullfolder_test.cwl"), | |
104 "--message", | |
105 "hello", | |
106 ] | |
107 ) | |
108 assert result_code == 0 | |
109 | |
110 | |
111 @needs_singularity_2_6 | |
112 def test_singularity_docker_image_id_in_tool(tmp_path: Path) -> None: | |
113 workdir = tmp_path / "working_dir" | |
114 workdir.mkdir() | |
115 os.chdir(workdir) | |
116 result_code, stdout, stderr = get_main_output( | |
117 [ | |
118 "--singularity", | |
119 get_data("tests/sing_pullfolder_test.cwl"), | |
120 "--message", | |
121 "hello", | |
122 ] | |
123 ) | |
124 result_code1, stdout, stderr = get_main_output( | |
125 ["--singularity", get_data("tests/debian_image_id.cwl"), "--message", "hello"] | |
126 ) | |
127 assert result_code1 == 0 |