Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ecl not able to parce errors from MPI runs #9248

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to simplify some, since the expected output is the list of the input?
You could probably test against [prt_error] and trim away a lot in the parameter section for the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, would have been possible with the simple tests where prt_error only contains one message. I've added a test with a prt_error log containing a mix of messages, where only some will be included in the error_list to verify that the parseErrors function correctly extracts only the parts we're interested in.