Skip to content

Commit a878979

Browse files
committed
use fms parser directly instead of mom5/6
1 parent d2de58f commit a878979

File tree

2 files changed

+27
-43
lines changed

2 files changed

+27
-43
lines changed

src/access/parsers/mom_profiling.py renamed to src/access/parsers/fms_profiling.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,3 @@ def read(self, stream: str) -> dict:
6363
stats[str(metric)].append(_convert_from_string(line.group(metric)))
6464

6565
return stats
66-
67-
68-
class MOM5ProfilingParser(FMSProfilingParser):
69-
"""MOM5 profiling output parser."""
70-
71-
def __init__(self):
72-
"""Instantiate MOM5 profiling parser."""
73-
super().__init__(has_hits=False)
74-
75-
76-
class MOM6ProfilingParser(FMSProfilingParser):
77-
"""MOM6 profiling output parser."""
78-
79-
def __init__(self):
80-
"""Instantiate MOM6 profiling parser."""
81-
super().__init__(has_hits=True)

tests/test_mom_profiling.py renamed to tests/test_fms_profiling.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33

44
import pytest
55

6-
from access.parsers.mom_profiling import MOM5ProfilingParser, MOM6ProfilingParser
6+
from access.parsers.fms_profiling import FMSProfilingParser
77

88

99
@pytest.fixture(scope="module")
10-
def mom5_parser():
11-
"""Fixture instantiating the MOM5 parser."""
12-
return MOM5ProfilingParser()
10+
def fms_hits_parser():
11+
"""Fixture instantiating the FMS parser where hits column is present."""
12+
return FMSProfilingParser()
1313

1414

1515
@pytest.fixture(scope="module")
16-
def mom6_parser():
17-
"""Fixture instantiating the MOM6 parser."""
18-
return MOM6ProfilingParser()
16+
def fms_nohits_parser():
17+
"""Fixture instantiating the FMS parser where hits column is not present."""
18+
return FMSProfilingParser(has_hits=False)
1919

2020

2121
@pytest.fixture(scope="module")
22-
def mom5_profiling():
23-
"""Fixture returning a dict holding the parsed content of a mom6_input file."""
22+
def fms_nohits_profiling():
23+
"""Fixture returning a dict holding the parsed FMS timing content without hits."""
2424
return {
2525
"region": [
2626
"Total runtime",
@@ -40,8 +40,8 @@ def mom5_profiling():
4040

4141

4242
@pytest.fixture(scope="module")
43-
def mom5_log_file():
44-
"""Fixture returning the timing content of a mom5 log file."""
43+
def fms_nohits_log_file():
44+
"""Fixture returning the FMS timing content without hits column."""
4545
return """ MPP_DOMAINS_STACK high water mark= 747000
4646
4747
Tabulating mpp_clock statistics across 49 PEs...
@@ -61,8 +61,8 @@ def mom5_log_file():
6161

6262

6363
@pytest.fixture(scope="module")
64-
def mom6_profiling():
65-
"""Fixture returning a dict holding the parsed content of a mom6_input file."""
64+
def fms_hits_profiling():
65+
"""Fixture returning a dict holding the parsed FMS timing content with hits."""
6666
return {
6767
"region": [
6868
"Total runtime",
@@ -122,8 +122,8 @@ def mom6_profiling():
122122

123123

124124
@pytest.fixture(scope="module")
125-
def mom6_log_file():
126-
"""Fixture returning the timing content of a mom6 log file."""
125+
def fms_hits_log_file():
126+
"""Fixture returning a dict holding the parsed FMS timing content wiht hits."""
127127
return """ MPP_DOMAINS_STACK high water mark= 380512
128128
129129
Tabulating mpp_clock statistics across 1 PEs...
@@ -144,23 +144,23 @@ def mom6_log_file():
144144
"""
145145

146146

147-
def test_mom5_profiling(mom5_parser, mom5_log_file, mom5_profiling):
148-
"""Test the correct parsing of MOM5 timing information."""
149-
mom5_parsed_log = mom5_parser.read(mom5_log_file)
150-
for idx, region in enumerate(mom5_profiling.keys()):
151-
assert region in mom5_parsed_log, f"{region} not found in mom5 parsed log"
147+
def test_fms_nohits_profiling(fms_nohits_parser, fms_nohits_log_file, fms_nohits_profiling):
148+
"""Test the correct parsing of FMS timing information without hits column."""
149+
parsed_log = fms_nohits_parser.read(fms_nohits_log_file)
150+
for idx, region in enumerate(fms_nohits_profiling.keys()):
151+
assert region in parsed_log, f"{region} not found in mom5 parsed log"
152152
for metric in ("tmin", "tmax", "tavg", "tstd"):
153153
assert (
154-
mom5_profiling[metric][idx] == mom5_parsed_log[metric][idx]
154+
fms_nohits_profiling[metric][idx] == parsed_log[metric][idx]
155155
), f"Incorrect {metric} for region {region} (idx: {idx})."
156156

157157

158-
def test_mom6_profiling(mom6_parser, mom6_log_file, mom6_profiling):
159-
"""Test the correct parsing of MOM6 timing information."""
160-
mom6_parsed_log = mom6_parser.read(mom6_log_file)
161-
for idx, region in enumerate(mom6_profiling.keys()):
162-
assert region in mom6_parsed_log, f"{region} not found in mom6 parsed log"
158+
def test_mom6_profiling(fms_hits_parser, fms_hits_log_file, fms_hits_profiling):
159+
"""Test the correct parsing of FMS timing information with hits column."""
160+
parsed_log = fms_hits_parser.read(fms_hits_log_file)
161+
for idx, region in enumerate(fms_hits_profiling.keys()):
162+
assert region in parsed_log, f"{region} not found in mom6 parsed log"
163163
for metric in ("hits", "tmin", "tmax", "tavg", "tstd"):
164164
assert (
165-
mom6_profiling[metric][idx] == mom6_parsed_log[metric][idx]
165+
fms_hits_profiling[metric][idx] == parsed_log[metric][idx]
166166
), f"Incorrect {metric} for region {region} (idx: {idx})."

0 commit comments

Comments
 (0)