Skip to content

Commit 7b5c7a3

Browse files
committed
Nextflow with Flowcept
1 parent 4400ba0 commit 7b5c7a3

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

wfcommons/wfbench/translator/nextflow.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def translate(self, output_folder: pathlib.Path) -> None:
4444
:type output_folder: pathlib.Path
4545
"""
4646
# Create the output folder
47-
output_folder.mkdir(parents=True)
47+
self.output_folder = output_folder
48+
self.output_folder.mkdir(parents=True)
4849

4950
# Create benchmark files
5051
self._copy_binary_files(output_folder)
@@ -56,7 +57,7 @@ def translate(self, output_folder: pathlib.Path) -> None:
5657

5758
# Create the bash script for each task
5859
for task in sorted_tasks:
59-
self._create_task_script(output_folder, task)
60+
self._create_task_script(task)
6061

6162
# Create the Nextflow workflow script and file
6263
self._create_workflow_script(sorted_tasks)
@@ -90,6 +91,7 @@ def _create_workflow_script(self, tasks: list[Task]):
9091

9192
def _generate_flowcept_code(self) -> str:
9293
"""
94+
9395
:return: The code.
9496
:rtype: str
9597
"""
@@ -108,6 +110,8 @@ def _get_tasks_in_topological_order(self) -> List[Task]:
108110
"""
109111
Sort the workflow tasks in topological order.
110112
113+
:param output_folder: The path to the output folder.
114+
:type output_folder: pathlib.Path
111115
:return: A sorted list of tasks.
112116
:rtype: List[Task]
113117
"""
@@ -124,22 +128,18 @@ def _get_tasks_in_topological_order(self) -> List[Task]:
124128
for potential_task in all_children:
125129
num_children = len(self.task_children[potential_task.task_id])
126130
if not num_children:
127-
self.out_files.add(potential_task.output_files[0])
131+
self.out_files.add(f"{self.output_folder.absolute()}/{potential_task.output_files[0]}")
128132
if all(parent in sorted_tasks for parent in self._find_parents(potential_task.task_id)):
129133
tasks_in_current_level.append(potential_task)
130134
levels[current_level] = tasks_in_current_level
131135
sorted_tasks += tasks_in_current_level
132136
current_level += 1
133137
return sorted_tasks
134138

135-
136-
@staticmethod
137-
def _create_task_script(output_folder: pathlib.Path, task: Task):
139+
def _create_task_script(self, task: Task):
138140
"""
139141
Generate the bash script for invoking a task.
140142
141-
:param output_folder: The path to the output folder.
142-
:type output_folder: pathlib.Path
143143
:param task: The task.
144144
:type task: Task
145145
:return: The code.
@@ -151,16 +151,16 @@ def _create_task_script(output_folder: pathlib.Path, task: Task):
151151
# Generate input spec
152152
input_spec = "'\\["
153153
for f in task.input_files:
154-
input_spec += f"\"{output_folder.resolve()}/data/{f.file_id}\","
154+
input_spec += f"\"{self.output_folder.resolve()}/data/{f.file_id}\","
155155
input_spec = input_spec[:-1] + "\\]'"
156156

157157
# Generate output spec
158158
output_spec = "'\\{"
159159
for f in task.output_files:
160-
output_spec += f"\"{output_folder.resolve()}/data/{f.file_id}\":{str(f.size)},"
160+
output_spec += f"\"{self.output_folder.resolve()}/data/{f.file_id}\":{str(f.size)},"
161161
output_spec = output_spec[:-1] + "\\}'"
162162

163-
code += f"{output_folder.resolve()}/bin/{task.program} "
163+
code += f"{self.output_folder.resolve()}/bin/{task.program} "
164164

165165
for a in task.args:
166166
if "--output-files" in a:
@@ -171,7 +171,7 @@ def _create_task_script(output_folder: pathlib.Path, task: Task):
171171
code += f"{a} "
172172
code += "\n"
173173

174-
script_file_path = output_folder.joinpath(f"bin/script_{task.task_id}.sh")
174+
script_file_path = self.output_folder.joinpath(f"bin/script_{task.task_id}.sh")
175175
with open(script_file_path, "w") as out:
176176
out.write(code)
177177

0 commit comments

Comments
 (0)