Skip to content

Minimal implementation of error_message#222

Open
haneug wants to merge 14 commits intofaccts:mainfrom
haneug:feature.error_message
Open

Minimal implementation of error_message#222
haneug wants to merge 14 commits intofaccts:mainfrom
haneug:feature.error_message

Conversation

@haneug
Copy link
Copy Markdown
Contributor

@haneug haneug commented Mar 26, 2026

Closes Issues

Closes #215

Description

  • Implement a function output.error_message that goes through a list of known ErrorPatterns and checks if they are found in the output file. The pattern with the highest priority given by the position in the list will be returned. Tests for the errors can be found in tests/failure_examples. Initial errors include input errors, convergence errors for SCF, CC, geometry, and CP-SCF convergence, memory errors for SCF, MP2, and CC.

Release Notes

(Project adheres to Keep a Changelog; Every entry should start in upper-case and end with (#<pr-id>); Remove sections that don't apply)

Added

  • Added output.error_message() which retrieves the most important error message from the ORCA output file.
  • Added output.error_messages() which retrieves all error messages from known strings from the ORCA output file.
  • Added output.cc_converged and output.casscf_converged to check cc and casscf convergence.

Changed

  • ...

Deprecated

  • ...

Removed

  • ...

Fixed

  • ...

@haneug haneug added this to the 3.0.0 milestone Mar 26, 2026
@haneug haneug self-assigned this Mar 26, 2026
@haneug haneug added the enhancement New feature or request label Mar 26, 2026
@haneug haneug force-pushed the feature.error_message branch 5 times, most recently from cdf16c0 to 8ff8f77 Compare April 2, 2026 14:41
@haneug haneug force-pushed the feature.error_message branch from efb92a5 to d1c9b7a Compare April 7, 2026 11:05
@haneug haneug marked this pull request as ready for review April 7, 2026 11:08
@haneug haneug requested a review from a team as a code owner April 7, 2026 11:08
@haneug haneug changed the title WIP: Minimal implementation of error_message Minimal implementation of error_message Apr 7, 2026
@haneug haneug requested a review from timmyte April 7, 2026 13:22
Copy link
Copy Markdown
Contributor

@timmyte timmyte left a comment

Choose a reason for hiding this comment

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

This is nice improvement in the right direction. This will allow users to all add fallbacks to there OPI scripts.

But please cross-check the release notes and description again and removed sections, that are not served in this PR.

Also remove the three dots in the "Closes Issues" section.

d3a2: float | None = None

# > Number of CPSCF iterations
z_maxiter: int | None = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see this change listed in the PR description. Please cross-check.

class ErrorPattern:
"""
Represents an error pattern in the ORCA output file.
More complex error patterns derive from this class and override the extractor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
More complex error patterns derive from this class and override the extractor
More complex error patterns derive from this class and override the `extractor`.


def __init__(
self,
grep_string: str | None = None,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not just go with empty strings as default? I don't see the value of using None here.
Applies to grep_string as well as message.

critical: bool = False,
extractor: Callable[[Grepper], str] | None = None,
) -> None:
if grep_string is not None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would check as follows: if not grep_string (also applies to if message ...)
E.g. why would one want grep for an empty string?

self.grep_string = grep_string
if message is not None:
self.message = message
if critical is not None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Above it says critical is always boolean. So I don't get why you check for None here.

print(output.error_message())
assert not output.terminated_normally()
assert (
"Not enough memory available for SCF. Available: 1.0 MB" in output.error_message()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would be careful with using a fixed number of multiple consecutive blanks in a string literal if it's not meant only for printing. This where regex should be used.

Comment thread README.md
![Static Badge](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.15688425-blue)
![Static Badge](https://img.shields.io/badge/release-2.0.0-%2300AEC3)
[![JCTC Paper](https://img.shields.io/badge/JCTC-10.1021%2Faces.jctc.5c02141-blue?logo=doi)](https://doi.org/10.1021/acs.jctc.5c02141)
[![JCTC Paper](https://img.shields.io/badge/JCTC-10.1021%2Facs.jctc.5c02141-blue?logo=doi)](https://doi.org/10.1021/acs.jctc.5c02141)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this change listed in the PR description?

# > Error patterns in order of priority.
# > Critical errors will stop scanning when matched.
# > Non-critical errors will just be added and reported.
ERROR_PATTERNS: list[ErrorPattern] = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add kind of line in the form of a comment, at which point in the list we go from critical to non-critical.

return hits if hits else None


def get_error_message(file_name: Path) -> str | None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would make the function name more specific: e.g. get_first_error_message()

@@ -0,0 +1,80 @@
from opi.output.grepper.error_pattern import (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add module level docstring, describing what this file holds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error message extraction

2 participants