Skip to content

Commit 152b441

Browse files
committed
fixing function name generation
1 parent 684c8ea commit 152b441

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

wfcommons/wfbench/translator/nextflow.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ def _generate_workflow_code(self, sorted_tasks: List[Task]) -> str:
298298
code += "workflow {\n"
299299
code += "\tresults = bootstrap()\n"
300300
for task in sorted_tasks:
301-
code += f"\tresults = function_{task.task_id}(results)\n"
301+
function_name = task.task_id.replace(".", "_")
302+
code += f"\tresults = function_{function_name}(results)\n"
302303
code += "}\n"
303304
return code
304305

@@ -312,26 +313,27 @@ def _generate_task_function(self, task: Task) -> str:
312313
:rtype: str
313314
"""
314315
code = f"// Function to call task {task.task_id}\n"
315-
code += f"def function_{task.task_id}(Map inputs) " + "{\n"
316+
function_name = task.task_id.replace(".", "_")
317+
code += f"def function_{function_name}(Map inputs) " + "{\n"
316318

317319
if self._find_parents(task.task_id):
318320
# Input channel mixing and then call
319-
code += f"\tdef {task.task_id}_necessary_input = Channel.empty()\n"
321+
code += f"\tdef {function_name}_necessary_input = Channel.empty()\n"
320322
for f in task.input_files:
321-
code += f"\t{task.task_id}_necessary_input = {task.task_id}_necessary_input.mix(inputs.{f.file_id})\n"
322-
code += f"\tdef {task.task_id}_necessary_input_future = {task.task_id}_necessary_input.collect()\n"
323-
code += f"\tdef {task.task_id}_produced_output = {task.task_id}({task.task_id}_necessary_input_future)\n"
323+
code += f"\t{function_name}_necessary_input = {function_name}_necessary_input.mix(inputs.{f.file_id})\n"
324+
code += f"\tdef {function_name}_necessary_input_future = {function_name}_necessary_input.collect()\n"
325+
code += f"\tdef {function_name}_produced_output = {function_name}({function_name}_necessary_input_future)\n"
324326
else:
325327
# Simple call
326-
code += f"\tdef {task.task_id}_produced_output = {task.task_id}()\n"
328+
code += f"\tdef {function_name}_produced_output = {function_name}()\n"
327329

328330
# Pass on the outputs
329331
code += "\n"
330332
code += "\tdef outputs = inputs.clone()\n"
331333
if self._find_children(task.task_id):
332334
counter = 0
333335
for f in task.output_files:
334-
code += f"\toutputs.{f.file_id} = {task.task_id}_produced_output.map" + "{it[" + str(counter) + "]}\n"
336+
code += f"\toutputs.{f.file_id} = {function_name}_produced_output.map" + "{it[" + str(counter) + "]}\n"
335337
counter += 1
336338
code += "\treturn outputs\n"
337339
code += "}\n\n"

0 commit comments

Comments
 (0)