Skip to content

Commit f6080e7

Browse files
committed
Nextflow with Flowcept
1 parent 7b5c7a3 commit f6080e7

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

wfcommons/wfbench/translator/nextflow.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# (at your option) any later version.
1010

1111
import pathlib
12+
import shutil
1213

1314
from logging import Logger
1415
from typing import List, Optional, Union
@@ -17,6 +18,8 @@
1718
from ...common import Workflow
1819
from ...common.task import Task
1920

21+
this_dir = pathlib.Path(__file__).resolve().parent
22+
2023

2124
class 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 += "\tflowcept()\n"
256263
code += "\tresults = bootstrap()\n"
257264
for task in sorted_tasks:
258265
function_name = task.task_id.replace(".", "_")

wfcommons/wfbench/translator/templates/nextflow_templates/flowcept.py renamed to wfcommons/wfbench/translator/templates/nextflow/flowcept_agent.py

File renamed without changes.

wfcommons/wfbench/translator/templates/nextflow_templates/workflow.nf renamed to wfcommons/wfbench/translator/templates/nextflow/workflow.nf

File renamed without changes.

0 commit comments

Comments
 (0)