From 1549a871968cfaae374b11a9b76b83d248c7cb98 Mon Sep 17 00:00:00 2001 From: Hang Yan Date: Mon, 23 Sep 2024 20:57:55 -0400 Subject: [PATCH 1/2] [TestScript] Enhanced the Robustness of the VTR Flow Log Parser Script Added affixes to the regex pattern string, i.e., `$.*(my pattern).*$` to ensure that the searched pattern is not strictly required to start from the beginning of the string or line; it only needs to be part of the line. This makes the definition of the pattern rules easier and makes the VTR flow log parser more robust. --- vtr_flow/scripts/python_libs/vtr/log_parse.py | 2 +- vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/vtr_flow/scripts/python_libs/vtr/log_parse.py b/vtr_flow/scripts/python_libs/vtr/log_parse.py index 2a217168cd8..e77559b9818 100644 --- a/vtr_flow/scripts/python_libs/vtr/log_parse.py +++ b/vtr_flow/scripts/python_libs/vtr/log_parse.py @@ -23,7 +23,7 @@ class ParsePattern: def __init__(self, name, filename, regex_str, default_value=None): self._name = name self._filename = filename - self._regex = re.compile(regex_str) + self._regex = re.compile(f'^.*{regex_str}.*$') self._default_value = default_value def name(self): diff --git a/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py b/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py index 45c927d9867..d500eca0643 100755 --- a/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py +++ b/vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py @@ -36,9 +36,6 @@ def parse_file_and_update_results(filename, patterns, results): with open(filepaths[0], "r") as file: for line in file: - while line[0] == "#": - line = line[1:] - for parse_pattern in patterns: match = parse_pattern.regex().match(line) if match and match.groups(): From ee29e880b4d1b161eb40bb9797e1a02388d38381 Mon Sep 17 00:00:00 2001 From: Hang Yan Date: Thu, 26 Sep 2024 13:12:27 -0400 Subject: [PATCH 2/2] [TestScript] Added Comments for the Regex Pattern in the Log Parser Added comments for `self._regex = re.compile(f'^.*{regex_str}.*$')` in vtr_flow/scripts/python_libs/vtr/log_parse.py. Detailed in GitHub Issue #2743. --- vtr_flow/scripts/python_libs/vtr/log_parse.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vtr_flow/scripts/python_libs/vtr/log_parse.py b/vtr_flow/scripts/python_libs/vtr/log_parse.py index e77559b9818..623c4545e22 100644 --- a/vtr_flow/scripts/python_libs/vtr/log_parse.py +++ b/vtr_flow/scripts/python_libs/vtr/log_parse.py @@ -23,6 +23,8 @@ class ParsePattern: def __init__(self, name, filename, regex_str, default_value=None): self._name = name self._filename = filename + # Look for the specified pattern somewhere in the line, but any characters + # can occur before and after it. Detailed in GitHub Issue #2743. self._regex = re.compile(f'^.*{regex_str}.*$') self._default_value = default_value