Skip to content

Commit

Permalink
Fix ecl not able to parce errors from MPI runs (#9248)
Browse files Browse the repository at this point in the history
  • Loading branch information
HakonSohoel authored Nov 20, 2024
1 parent b555902 commit a8f4d73
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ert/resources/forward_models/res/script/ecl_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def failed_due_to_license_problems(self) -> bool:
EclipseResult = namedtuple("EclipseResult", "errors bugs")
body_sub_pattern = r"(\s^\s@.+$)*"
date_sub_pattern = r"\s+AT TIME\s+(?P<Days>\d+\.\d+)\s+DAYS\s+\((?P<Date>(.+)):\s*$"
error_pattern_e100 = rf"^\s@-- ERROR{date_sub_pattern}${body_sub_pattern}"
error_pattern_e100 = (
rf"^\s@-- ERROR\s(FROM PROCESSOR \d+)?{date_sub_pattern}${body_sub_pattern}"
)
error_pattern_e300 = rf"^\s@--Error${body_sub_pattern}"
slave_started_pattern = (
rf"^\s@--MESSAGE{date_sub_pattern}\s^\s@\s+STARTING SLAVE.+${body_sub_pattern}"
Expand Down
67 changes: 67 additions & 0 deletions tests/ert/unit_tests/resources/test_ecl_run_new_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,70 @@ def test_slave_started_message_are_not_counted_as_errors():
assert "Warning, mismatch between stated Error count" not in str(
exception_info.value
)


_DUMMY_ERROR_MESSAGE_E100 = """\
@-- ERROR AT TIME 0.0 DAYS ( 1-JAN-2000):
@ THIS IS A DUMMY ERROR MESSAGE"""

_DUMMY_ERROR_MESSAGE_MULTIPLE_CPUS_E100 = """\
@-- ERROR FROM PROCESSOR 1 AT TIME 0.0 DAYS (21-DEC-2002):
@ LICENSE FAILURE: ERROR NUMBER IS -4"""

_DUMMY_ERROR_MESSAGE_E300 = """\
@--Error
@ ECLIPSE option not allowed in license
@ Please ask for a new license
@ Run stopping"""

_DUMMY_SLAVE_STARTED_MESSAGE = """\
@--MESSAGE AT TIME 0.0 DAYS ( 1-JAN-2000):
@ STARTING SLAVE SLAVE1 RUNNING EIGHTCEL
@ ON HOST localhost IN DIRECTORY
@ dummypath/slave1"""


@pytest.mark.usefixtures("use_tmpdir")
@pytest.mark.parametrize(
"prt_error, expected_error_list",
[
(
_DUMMY_ERROR_MESSAGE_E100,
[_DUMMY_ERROR_MESSAGE_E100],
),
(
_DUMMY_ERROR_MESSAGE_MULTIPLE_CPUS_E100,
[_DUMMY_ERROR_MESSAGE_MULTIPLE_CPUS_E100],
),
(
_DUMMY_ERROR_MESSAGE_E300,
[_DUMMY_ERROR_MESSAGE_E300],
),
(
_DUMMY_SLAVE_STARTED_MESSAGE,
[_DUMMY_SLAVE_STARTED_MESSAGE],
),
(
f"""\
@--MESSAGE AT TIME 0.0 DAYS ( 1-JAN-2000):
@ THIS IS JUST A MESSAGE, NOTHING ELSE
@--MESSAGE AT TIME 0.0 DAYS ( 1-JAN-2000):
@ THIS IS JUST A MESSAGE, NOTHING ELSE
{_DUMMY_SLAVE_STARTED_MESSAGE}
<various_output>
{_DUMMY_ERROR_MESSAGE_E100}
""",
[_DUMMY_ERROR_MESSAGE_E100, _DUMMY_SLAVE_STARTED_MESSAGE],
),
],
)
def test_can_parse_errors(prt_error, expected_error_list):
Path("ECLCASE.PRT").write_text(prt_error + "\n", encoding="utf-8")

Path("ECLCASE.DATA").write_text("", encoding="utf-8")

run = ecl_run.EclRun("ECLCASE.DATA", "dummysimulatorobject")
error_list = run.parseErrors()
assert error_list == expected_error_list

0 comments on commit a8f4d73

Please sign in to comment.