equinor / ert

ERT - Ensemble based Reservoir Tool - is designed for running ensembles of dynamical models such as reservoir models, in order to do sensitivity analysis and data assimilation. ERT supports data assimilation using the Ensemble Smoother (ES), Ensemble Smoother with Multiple Data Assimilation (ES-MDA) and Iterative Ensemble Smoother (IES).
https://ert.readthedocs.io/en/latest/
GNU General Public License v3.0
101 stars 104 forks source link

XML parsing error when reading LSF output files #8231

Closed xjules closed 3 months ago

xjules commented 3 months ago

The following error occurred Describe the bug An XML parsing exception occurred when parsing the output from the LSF exit files.

Exception in scheduler task job-5_task: Extra content at the end of the document, line 17, column 1 (ERROR, line 17)
Traceback: Traceback (most recent call last):
  File "/opt/rh/rh-python38/root/usr/lib64/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/prog/res/komodo/2024.06.05-py38-rhel7/root/lib64/python3.8/site-packages/_ert/async_utils.py", line 53, in _done_callback
    raise exc
  File "/prog/res/komodo/2024.06.05-py38-rhel7/root/lib64/python3.8/site-packages/ert/scheduler/job.py", line 151, in run
    await self._send(State.FAILED)
  File "/prog/res/komodo/2024.06.05-py38-rhel7/root/lib64/python3.8/site-packages/ert/scheduler/job.py", line 216, in _send
    await self._handle_failure()
  File "/prog/res/komodo/2024.06.05-py38-rhel7/root/lib64/python3.8/site-packages/ert/scheduler/job.py", line 203, in _handle_failure
    log_info_from_exit_file(Path(self.real.run_arg.runpath) / ERROR_file)
  File "/prog/res/komodo/2024.06.05-py38-rhel7/root/lib64/python3.8/site-packages/ert/scheduler/job.py", line 242, in log_info_from_exit_file
    exit_file = etree.parse(exit_file_path)
  File "src/lxml/etree.pyx", line 3570, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1952, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1978, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1881, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1200, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 633, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 743, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 672, in lxml.etree._raiseParseError
  File "/<PATH>/realization-5/pred/ERROR", line 17
lxml.etree.XMLSyntaxError: Extra content at the end of the document, line 17, column 1

Expected behaviour A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment

Additional context Add any other context about the problem here.

berland commented 3 months ago

The offending XML file is not to be found.

A guess is that this might happen on a a realization rerun and that the ERROR file is written twice in append mode. Let us check that and see if a problem can be found.

berland commented 3 months ago

The function log_info_from_exit_file is is there only to do a logger.error call. If it fails to parse the XML file it can just as well display the raw ERROR file instead.

Add a test for log_info_from_exit_file to assert it will never raise on any input.