1919from tests .test_helpers import _create_fresh_local_dir
2020from tests .test_helpers import _remove_local_dir_if_it_exists
2121from tests .test_helpers import _start_docker_container
22- from tests .test_helpers import _shutdown_docker_container
22+ from tests .test_helpers import _shutdown_docker_container_and_remove_image
2323from tests .test_helpers import _compare_workflows
2424
2525from wfcommons import BlastRecipe
@@ -116,8 +116,6 @@ def _additional_setup_swiftt(container):
116116
117117def run_workflow_dask (container , num_tasks , str_dirpath ):
118118 exit_code , output = container .exec_run ("python ./dask_workflow.py" , stdout = True , stderr = True )
119- # Kill the container
120- container .remove (force = True )
121119 # Check sanity
122120 assert (exit_code == 0 )
123121 assert (output .decode ().count ("completed!" ) == num_tasks )
@@ -126,8 +124,6 @@ def run_workflow_dask(container, num_tasks, str_dirpath):
126124def run_workflow_parsl (container , num_tasks , str_dirpath ):
127125 exit_code , output = container .exec_run ("python ./parsl_workflow.py" , stdout = True , stderr = True )
128126 ignored , output = container .exec_run (f"cat { str_dirpath } /runinfo/000/parsl.log" , stdout = True , stderr = True )
129- # Kill the container
130- container .remove (force = True )
131127 # Check sanity
132128 assert (exit_code == 0 )
133129 assert ("completed" in output .decode ())
@@ -137,8 +133,6 @@ def run_workflow_nextflow(container, num_tasks, str_dirpath):
137133 # Run the workflow!
138134 exit_code , output = container .exec_run (f"nextflow run ./workflow.nf --pwd ." , stdout = True , stderr = True )
139135 ignored , task_exit_codes = container .exec_run ("find . -name .exitcode -exec cat {} \;" , stdout = True , stderr = True )
140- # Kill the container
141- container .remove (force = True )
142136 # Check sanity
143137 assert (exit_code == 0 )
144138 assert (task_exit_codes .decode () == num_tasks * "0" )
@@ -149,37 +143,28 @@ def run_workflow_airflow(container, num_tasks, str_dirpath):
149143 exit_code , output = container .exec_run (cmd = ["sh" , "-c" , "cd /home/wfcommons/ && sudo /bin/bash /run_a_workflow.sh Blast-Benchmark" ],
150144 stdout = True ,
151145 stderr = True )
152- # Kill the container
153- container .remove (force = True )
154-
155146 # Check sanity
156147 assert (exit_code == 0 )
157148 assert (output .decode ().count ("completed" ) == num_tasks * 2 )
158149
159150def run_workflow_bash (container , num_tasks , str_dirpath ):
160151 # Run the workflow!
161152 exit_code , output = container .exec_run (cmd = "/bin/bash ./run_workflow.sh" , stdout = True , stderr = True )
162- # Kill the container
163- container .remove (force = True )
164153 # Check sanity
165154 assert (exit_code == 0 )
166155 assert (output .decode ().count ("completed" ) == num_tasks )
167156
168157def run_workflow_taskvine (container , num_tasks , str_dirpath ):
169158 # Run the workflow!
170159 exit_code , output = container .exec_run (cmd = ["bash" , "-c" , "source ~/conda/etc/profile.d/conda.sh && conda activate && python3 ./taskvine_workflow.py" ], stdout = True , stderr = True )
171- # Kill the container
172- container .remove (force = True )
173- # # Check sanity
160+ # Check sanity
174161 assert (exit_code == 0 )
175162 assert (output .decode ().count ("completed" ) == num_tasks )
176163
177164def run_workflow_cwl (container , num_tasks , str_dirpath ):
178165 # Run the workflow!
179166 # Note that the input file is hardcoded and Blast-specific
180167 exit_code , output = container .exec_run (cmd = "cwltool ./main.cwl --split_fasta_00000001_input ./data/workflow_infile_0001 " , stdout = True , stderr = True )
181- # Kill the container
182- container .remove (force = True )
183168 # Check sanity
184169 assert (exit_code == 0 )
185170 # this below is ugly (the 3 is for "workflow", "compile_output_files" and "compile_log_files",
@@ -189,17 +174,13 @@ def run_workflow_cwl(container, num_tasks, str_dirpath):
189174def run_workflow_pegasus (container , num_tasks , str_dirpath ):
190175 # Run the workflow!
191176 exit_code , output = container .exec_run (cmd = "bash /home/wfcommons/run_workflow.sh" , stdout = True , stderr = True )
192- # Kill the container
193- container .remove (force = True )
194177 # Check sanity
195178 assert (exit_code == 0 )
196179 assert ("success" in output .decode ())
197180
198181def run_workflow_swiftt (container , num_tasks , str_dirpath ):
199182 # Run the workflow!
200183 exit_code , output = container .exec_run (cmd = "swift-t workflow.swift" , stdout = True , stderr = True )
201- # Kill the container
202- container .remove (force = True )
203184 # sys.stderr.write(output.decode())
204185 # Check sanity
205186 assert (exit_code == 0 )
@@ -236,7 +217,7 @@ class TestTranslators:
236217 @pytest .mark .parametrize (
237218 "backend" ,
238219 [
239- # "swiftt",
220+ "swiftt" ,
240221 "dask" ,
241222 "parsl" ,
242223 "nextflow" ,
@@ -259,22 +240,21 @@ def test_translator(self, backend) -> None:
259240 _remove_local_dir_if_it_exists (str_dirpath )
260241
261242 # Perform the translation
262- sys .stderr .write (" \n Translating workflow...\n " )
243+ sys .stderr .write (f" \n [ { backend } ] Translating workflow...\n " )
263244 translator = translator_classes [backend ](benchmark .workflow )
264245 translator .translate (output_folder = dirpath )
265246
266247 # Start the Docker container
267- sys .stderr .write ("Starting Docker container...\n " )
268248 container = _start_docker_container (backend , str_dirpath , str_dirpath , str_dirpath + "bin/" )
269249
270250 # Do whatever necessary setup
271251 additional_setup_methods [backend ](container )
272252
273253 # Run the workflow
274- sys .stderr .write (" Running workflow...\n " )
254+ sys .stderr .write (f"[ { backend } ] Running workflow...\n " )
275255 start_time = time .time ()
276256 run_workflow_methods [backend ](container , num_tasks , str_dirpath )
277- sys .stderr .write (" Workflow ran in %.2f seconds\n " % (time .time () - start_time ))
257+ sys .stderr .write (f"[ { backend } ] Workflow ran in %.2f seconds\n " % (time .time () - start_time ))
278258
279259 # Run the log parser if any
280260 if backend == "pegasus" :
@@ -285,14 +265,14 @@ def test_translator(self, backend) -> None:
285265 parser = None
286266
287267 if parser :
288- sys .stderr .write (" \n Parsing the logs...\n " )
268+ sys .stderr .write (f" \n [ { backend } ] Parsing the logs...\n " )
289269 reconstructed_workflow : Workflow = parser .build_workflow ("reconstructed_workflow" )
290270 reconstructed_workflow .write_json (pathlib .Path ("/tmp/reconstructed_workflow.json" ))
291271
292272 original_workflow : Workflow = benchmark .workflow
293273
294274 _compare_workflows (original_workflow , reconstructed_workflow )
295275
296- # Shutdown the container
297- # _shutdown_docker_container (container)
276+ # Shutdown the container (weirdly, container is already shutdown by now... not sure how)
277+ _shutdown_docker_container_and_remove_image (container )
298278
0 commit comments