Skip to content

Commit 63f828b

Browse files
Merge pull request #164 from wfcommons/nextflow_log_parser_tweaks
Minor tweaks to the nextflow log parser and translator
2 parents 6c18f32 + 567e8f8 commit 63f828b

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

wfcommons/wfbench/translator/nextflow.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,20 @@ def _write_readme_file(self, output_folder: pathlib.Path) -> None:
299299

300300
out.write(f"Executions of large workflows can lead to large numbers of concurrent tasks, \n")
301301
out.write(f"which can hit system concurrency limits and/or lead to out-of-memory errors in the JVM that runs\n")
302-
out.write(f"the Nextflow engine. The f{nextflow_config_file_name} configuration file in this directory\n")
302+
out.write(f"the Nextflow engine. The {nextflow_config_file_name} configuration file in this directory\n")
303303
out.write(f"has settings to impose (pretty stringent) limits on concurrency and memory usage. These settings\n")
304-
out.write(f"many not be appropriate for your purposes, you should INSPECT AND MODIFY settings in that file.\n\n")
304+
out.write(f"many not be appropriate for your purposes, you should INSPECT AND MODIFY the settings in that file.\n\n")
305305

306-
out.write(f"If hitting JVM out-of-memory errors one possible solution, up to a point,\n")
307-
out.write(f"is to define the NXF_OPTS environment variable, e.g.:\n")
306+
out.write(f"If hitting JVM out-of-memory errors one possible solution, up to a point, it to define\n")
307+
out.write(f"the NXF_OPTS environment variable, e.g.:\n\n")
308308

309309
out.write(f"\texport NXF_OPTS='-Xms2g -Xmx24g'\n\n")
310310

311311

312-
out.write(f"Note that the workflow has been split into {len(self.subworkflows)} module file(s), ")
313-
out.write(f"each containing a maximum of {self.max_tasks_per_subworkflow} tasks.\n")
314-
out.write(f"\nModule files are located in the 'modules/' directory.\n")
312+
out.write(f"Note that the Nextflow workflow has been split into {len(self.subworkflows)} module file(s), ")
313+
out.write(f"each containing a maximum of {self.max_tasks_per_subworkflow} tasks. \n")
314+
out.write(f"This is to avoid the 'code too long' limit of Groovy. ")
315+
out.write(f"Module files are located in the 'modules/' directory.\n")
315316

316317
def _write_nf_config_file(self, output_folder: pathlib.Path) -> None:
317318
"""

wfcommons/wfinstances/logs/nextflow.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
class NextflowLogsParser(LogsParser):
2727
""""
28-
Parse Nextflow execution directory to generate a workflow trace. The workflow
29-
must have been executed with two features enabled: 1) the nf-prov plugin, and
28+
Parse Nextflow execution directory to generate a workflow trace. Note that the workflow
29+
reconstruction is not perfect, and will likely only capture file-based data dependencies.
30+
The workflow must have been executed with two features enabled: 1) the nf-prov plugin, and
3031
2) execution tracing. This can be achieved by invoking Nextflow with a config
3132
file, e.g.::
3233
@@ -60,6 +61,8 @@ class NextflowLogsParser(LogsParser):
6061
:type execution_dir: pathlib.Path
6162
:param nextflow_version: The Nextflow version used to execute the workflow
6263
:type nextflow_version: str
64+
:param trace_file_name_pattern: The trace file name pattern to find the trace file (default: "*trace*.txt")
65+
:type trace_file_name_pattern: str
6366
:param description: Workflow instance description.
6467
:type description: Optional[str]
6568
:param logger: The logger where to log information/warning or errors (optional).
@@ -69,6 +72,7 @@ class NextflowLogsParser(LogsParser):
6972
def __init__(self,
7073
execution_dir: pathlib.Path,
7174
nextflow_version: str,
75+
trace_file_name_pattern: Optional[str] = "*trace*.txt",
7276
description: Optional[str] = None,
7377
logger: Optional[Logger] = None) -> None:
7478
"""Create an object of the nextflow log parser."""
@@ -78,8 +82,8 @@ def __init__(self,
7882
self.execution_dir = execution_dir
7983

8084
# Load the Nextflow execution trace, and create a task runtime dictionary
81-
nextflow_execution_trace_files = list(self.execution_dir.rglob("execution_trace_*.txt"))
82-
if len(nextflow_execution_trace_files) == 0:
85+
self.nextflow_execution_trace_files = list(self.execution_dir.rglob(trace_file_name_pattern))
86+
if len(self.nextflow_execution_trace_files) == 0:
8387
raise FileNotFoundError("No execution_trace_*.txt file found in Nextflow execution directory.")
8488

8589

@@ -94,11 +98,8 @@ def build_workflow(self, workflow_name: Optional[str] = None) -> Workflow:
9498
:rtype: Workflow
9599
"""
96100

97-
# Parse the Nextflow execution trace to create a dict of task runtimes
98-
nextflow_execution_trace_files = list(self.execution_dir.rglob("execution_trace_*.txt"))
99-
if len(nextflow_execution_trace_files) == 0:
100-
raise FileNotFoundError("No execution_trace_*.txt file found in Nextflow execution directory.")
101-
nextflow_execution_trace_file: pathlib.Path = max(nextflow_execution_trace_files,
101+
# Parse the Nextflow (most recent) execution trace file to create a dict of task runtimes
102+
nextflow_execution_trace_file: pathlib.Path = max(self.nextflow_execution_trace_files,
102103
key=lambda p: p.stat().st_mtime)
103104
nextflow_task_runtimes = self._load_nextflow_trace(nextflow_execution_trace_file)
104105

0 commit comments

Comments
 (0)