2626from wfcommons .wfbench import AirflowTranslator
2727
2828
29- def start_docker_container (backend , working_dir ):
29+ def start_docker_container (backend , mounted_dir , working_dir , command = [ "sleep" , "infinity" ] ):
3030 # Pulling the Docker image
3131 client = docker .from_env ()
3232 sys .stderr .write ("Pulling Docker image...\n " )
@@ -43,8 +43,8 @@ def start_docker_container(backend, working_dir):
4343 sys .stderr .write ("Starting Docker container...\n " )
4444 container = client .containers .run (
4545 image_name ,
46- "sleep infinity" ,
47- volumes = {working_dir : {'bind' : working_dir , 'mode' : 'rw' }},
46+ command = command ,
47+ volumes = {mounted_dir : {'bind' : mounted_dir , 'mode' : 'rw' }},
4848 working_dir = working_dir ,
4949 tty = True ,
5050 detach = True
@@ -91,7 +91,7 @@ def create_workflow_benchmark():
9191class TestTranslators :
9292
9393 @pytest .mark .unit
94- @pytest .mark .skip (reason = "tmp" )
94+ # @pytest.mark.skip(reason="tmp")
9595 def test_dask_translator (self ) -> None :
9696
9797 # Create workflow benchmark
@@ -109,12 +109,12 @@ def test_dask_translator(self) -> None:
109109 translator .translate (output_folder = dirpath )
110110
111111 # Pulling the Docker image
112- container = start_docker_container ("dask" , str_dirpath )
112+ container = start_docker_container ("dask" , str_dirpath , str_dirpath )
113113
114114 # Installing WfCommons on container
115115 install_WfCommons_on_container (container )
116116
117- # Copy over the wfbench and cpu-benchmark executables to where they should go
117+ # Copy over the wfbench and cpu-benchmark executables to where they should go on the container
118118 exit_code , output = container .exec_run ("sudo cp -f /tmp/WfCommons/bin/wfbench " + str_dirpath + "bin/" , stdout = True , stderr = True )
119119 exit_code , output = container .exec_run ("sudo cp -f /tmp/WfCommons/bin/cpu-benchmark " + str_dirpath + "bin/" , stdout = True , stderr = True )
120120
@@ -134,7 +134,7 @@ def test_dask_translator(self) -> None:
134134
135135
136136 @pytest .mark .unit
137- @pytest .mark .skip (reason = "tmp" )
137+ # @pytest.mark.skip(reason="tmp")
138138 def test_parsl_translator (self ) -> None :
139139
140140 # Create workflow benchmark
@@ -151,8 +151,8 @@ def test_parsl_translator(self) -> None:
151151 translator = ParslTranslator (benchmark .workflow )
152152 translator .translate (output_folder = dirpath )
153153
154- # Pulling the Docker image
155- container = start_docker_container ("parsl" , str_dirpath )
154+ # Starting the Docker container
155+ container = start_docker_container ("parsl" , str_dirpath , str_dirpath )
156156
157157 # Installing WfCommons on container
158158 install_WfCommons_on_container (container )
@@ -178,7 +178,7 @@ def test_parsl_translator(self) -> None:
178178 assert (num_completed_tasks == num_tasks )
179179
180180 @pytest .mark .unit
181- @pytest .mark .skip (reason = "tmp" )
181+ # @pytest.mark.skip(reason="tmp")
182182 def test_nextflow_translator (self ) -> None :
183183
184184 # Create workflow benchmark
@@ -195,8 +195,8 @@ def test_nextflow_translator(self) -> None:
195195 translator = NextflowTranslator (benchmark .workflow )
196196 translator .translate (output_folder = dirpath )
197197
198- # Pulling the Docker image
199- container = start_docker_container ("nextflow" , str_dirpath )
198+ # Starting the Docker container
199+ container = start_docker_container ("nextflow" , str_dirpath , str_dirpath )
200200
201201 # Installing WfCommons on container
202202 install_WfCommons_on_container (container )
@@ -222,7 +222,7 @@ def test_nextflow_translator(self) -> None:
222222
223223
224224 @pytest .mark .unit
225- @pytest .mark .skip (reason = "tmp" )
225+ # @pytest.mark.skip(reason="tmp")
226226 def test_airflow_translator (self ) -> None :
227227
228228 # Create workflow benchmark
@@ -239,27 +239,37 @@ def test_airflow_translator(self) -> None:
239239 translator = AirflowTranslator (benchmark .workflow )
240240 translator .translate (output_folder = dirpath )
241241
242- # Pulling the Docker image
243- container = start_docker_container ("airflow" , str_dirpath )
242+ # Starting the Docker container
243+ container = start_docker_container ("airflow" , str_dirpath , "/home/wfcommons/" , command = None )
244+ # container = start_docker_container("airflow", str_dirpath, "/home/wfcommons/")
244245
245246 # Installing WfCommons on container
246247 install_WfCommons_on_container (container )
247248
249+
248250 # Copy over the wfbench and cpu-benchmark executables to where they should go
249- # exit_code, output = container.exec_run("sudo cp -f /tmp/WfCommons/bin/wfbench " + str_dirpath + "bin/",
250- # stdout=True, stderr=True)
251- # exit_code, output = container.exec_run("sudo cp -f /tmp/WfCommons/bin/cpu-benchmark " + str_dirpath + "bin/",
252- # stdout=True, stderr=True)
253- #
254- # # Run the workflow!
255- # sys.stderr.write("Running the Airflow workflow on the container...\n")
256- # exit_code, output = container.exec_run(f"nextflow run ./workflow.nf --pwd .", stdout=True, stderr=True)
257- # ignored, task_exit_codes = container.exec_run("find . -name .exitcode -exec cat {} \;", stdout=True, stderr=True)
258- #
259- # # Kill the container
260- # container.remove(force=True)
261- #
262- # # Do sanity checks
263- # sys.stderr.write("Checking sanity...\n")
264- # assert (exit_code == 0)
265- # assert (task_exit_codes.decode() == num_tasks * "0")
251+ exit_code , output = container .exec_run ("sudo cp -f /tmp/WfCommons/bin/wfbench /usr/local/bin/" ,
252+ stdout = True , stderr = True )
253+ exit_code , output = container .exec_run ("sudo cp -f /tmp/WfCommons/bin/cpu-benchmark /usr/local/bin/" ,
254+ stdout = True , stderr = True )
255+
256+ # Do the necessary copies (some ugly hardcoded stuff here)
257+ airflow_home = "/home/wfcommons/airflow/" # per the Dockerfile
258+ exit_code , output = container .exec_run (f"cp -r /tmp/airflow_translated_workflow { airflow_home } /dags/" ,stdout = True , stderr = True )
259+ exit_code , output = container .exec_run (f"mv { airflow_home } /dags/airflow_translated_workflow/workflow.py { airflow_home } /dags/" ,stdout = True , stderr = True )
260+
261+ # # Run the entry point script by hand (such a hack!)
262+ # exit_code, output = container.exec_run(f"/bin/bash /entrypoint.sh",stdout=True, stderr=True)
263+ # print(output)
264+
265+ # Run the workflow!
266+ sys .stderr .write ("Running the Airflow workflow on the container...\n " )
267+ exit_code , output = container .exec_run (cmd = "/bin/bash /run_a_workflow.sh Blast-Benchmark" , stdout = True , stderr = True )
268+
269+ # Kill the container
270+ container .remove (force = True )
271+
272+ # Do sanity checks
273+ sys .stderr .write ("Checking sanity...\n " )
274+ assert (exit_code == 0 )
275+ assert (output .decode ().count ("completed" ) == num_tasks * 2 )
0 commit comments