diff --git a/apps/cli/utilities/wf_monitor/src/wf_monitor/monitor.py b/apps/cli/utilities/wf_monitor/src/wf_monitor/monitor.py index 282def29c9e5dfbb430dcd060f0b80f5a5c2b50d..d7a9cfd94231341de44adb90406c92565281a425 100644 --- a/apps/cli/utilities/wf_monitor/src/wf_monitor/monitor.py +++ b/apps/cli/utilities/wf_monitor/src/wf_monitor/monitor.py @@ -6,7 +6,6 @@ import signal import logging import argparse import functools -import subprocess import tracemalloc from typing import List, Union, Dict, Callable, Tuple, Any from pathlib import Path @@ -131,6 +130,9 @@ def get_retval(body: str) -> Union[int, None]: class WorkflowMonitor: + """ + Class that monitors the events in a given workflow via the log file produced by it + """ def __init__(self, logfile_path: str, timeout: int = 60): self.logfile_path = Path(logfile_path) @@ -170,13 +172,14 @@ class WorkflowMonitor: """ # Regex that matches an event entry in the HTCondor log file. r_htc_event = r'(?P<eventnum>[0-9]{3}) \((?P<jobnum>[0-9]{4})\.[0-9]{3}\.[0-9]{3}\) ' \ - r'(?P<timestamp>[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}) ' \ - r'(?P<desc>[a-zA-Z0-9 ?&:=<>\-._]+)\n' \ - r'(?P<body>[\t ]+[^\.]*\n)*' \ - r'...' + r'(?P<timestamp>[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}) ' \ + r'(?P<desc>[a-zA-Z0-9 ?&:=<>\-._]+)\n' \ + r'(?P<body>[\t ]+[^\.]*\n)*' \ + r'...' jobs = {} events = [] if sum(1 for _ in re.finditer(r_htc_event, self.log)) == 0: + # Regex didn't return any matches raise ValueError('HTCondor log file not well-formatted. Was the file edited?') for match in re.finditer(r_htc_event, self.log): job_id = match.group('jobnum')