99# (at your option) any later version.
1010
1111import pathlib
12+ import shutil
1213
1314from logging import Logger
1415from typing import List , Optional , Union
1718from ...common import Workflow
1819from ...common .task import Task
1920
21+ this_dir = pathlib .Path (__file__ ).resolve ().parent
22+
2023
2124class NextflowTranslator (Translator ):
2225 """
@@ -50,6 +53,8 @@ def translate(self, output_folder: pathlib.Path) -> None:
5053 # Create benchmark files
5154 self ._copy_binary_files (output_folder )
5255 self ._generate_input_files (output_folder )
56+ if self .workflow .workflow_id :
57+ shutil .copy (this_dir .joinpath ("templates/nextflow/flowcept_agent.py" ), output_folder .joinpath ("bin" ))
5358
5459 # Create a topological order of the tasks
5560 sorted_tasks = self ._get_tasks_in_topological_order ()
@@ -61,7 +66,7 @@ def translate(self, output_folder: pathlib.Path) -> None:
6166
6267 # Create the Nextflow workflow script and file
6368 self ._create_workflow_script (sorted_tasks )
64- run_workflow_code = self ._merge_codelines ("templates/nextflow_templates /workflow.nf" , self .script )
69+ run_workflow_code = self ._merge_codelines ("templates/nextflow /workflow.nf" , self .script )
6570 self ._write_output_file (run_workflow_code , output_folder .joinpath ("workflow.nf" ))
6671
6772 # Create the README file
@@ -95,14 +100,14 @@ def _generate_flowcept_code(self) -> str:
95100 :return: The code.
96101 :rtype: str
97102 """
98- out_files = ", " .join (f"' { item } ' " for item in self .out_files )
103+ out_files = ", " .join (f"\" { item } \" " for item in self .out_files )
99104 return "process flowcept(){\n " \
100105 " input:\n " \
101106 " output:\n " \
102107 " script:\n " \
103108 " \" \" \" \n " \
104- " ${pwd}/bin/flowcept .py " \
105- f"{ self .workflow .name } { self .workflow .workflow_id } '\\ [{ out_files } \\ ]' \n " \
109+ " ${pwd}/bin/flowcept_agent .py " \
110+ f"{ self .workflow .name } { self .workflow .workflow_id } '[{ out_files } ]' \n " \
106111 " \" \" \" \n " \
107112 "}\n \n "
108113
@@ -253,6 +258,8 @@ def _generate_workflow_code(self, sorted_tasks: List[Task]) -> str:
253258
254259 # Generate workflow function
255260 code += "workflow {\n "
261+ if self .workflow .workflow_id :
262+ code += "\t flowcept()\n "
256263 code += "\t results = bootstrap()\n "
257264 for task in sorted_tasks :
258265 function_name = task .task_id .replace ("." , "_" )
0 commit comments