Skip to content

Orca MM Runner#224

Open
MattBurn wants to merge 9 commits intofaccts:mainfrom
MattBurn:orca-mm
Open

Orca MM Runner#224
MattBurn wants to merge 9 commits intofaccts:mainfrom
MattBurn:orca-mm

Conversation

@MattBurn
Copy link
Copy Markdown
Contributor

@MattBurn MattBurn commented Mar 31, 2026

Closes Issues

Closes #185

Description

Extracts shared ORCA execution logic from Runner into a new BaseRunner and adds OrcaMmRunner in opi.execution.mm for running orca_mm.

OrcaMmRunner adds typed helpers for supported orca_mm subcommands, validates expected output files, and raises a dedicated OrcaMmException when orca_mm reports errors on stderr. This also extends OrcaBinary with ORCA_MM and adds unit coverage for stderr handling, including the empty/deleted temporary stderr-file case.


Release Notes

Added

  • Added BaseRunner to share ORCA binary resolution, environment setup, version checks, and subprocess execution across runner implementations. (Orca MM Runner #224)
  • Added OrcaMmRunner with helpers for orca_mm commands such as convff, splitff, mergeff, repeatff, splitpdb, mergepdb, makeff, and getHDist. (Orca MM Runner #224)
  • Added OrcaBinary.ORCA_MM and unit tests covering orca_mm stderr handling. (Orca MM Runner #224)

Changed

  • Changed Runner to inherit from BaseRunner, keeping orca, orca_plot, and orca_2json behavior while moving shared execution logic into the base class. (Orca MM Runner #224)

@MattBurn MattBurn requested a review from a team as a code owner March 31, 2026 09:34
@timmyte timmyte self-requested a review April 1, 2026 09:14
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.

@MattBurn
Thanks a lot for the PR. Thanks a very nice addition and improvement for OPI. Also thanks to directly include proper tests.

I would appreciate if you could overall add more comments and documentation to the code. Most patterns are very repetitive, so they would only a single documentation somewhere prominently on module level.

Comment thread src/opi/execution/base.py Outdated
Comment thread src/opi/execution/mm.py
]


class OrcaMmException(Exception):
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.

@haneug
If we start implementing custom exceptions, we should have base class OpiError from which all custom exceptions are derived.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What path would you like to take? I can either change all OrcaMmExceptions into built in exception types or add an OpiError/OpiException if the latter do you prefer exception or error?

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 generally like the idea of adding OpiError. We could have a small implementation in opi/exceptions.py and derive OpiExecutionError from it and OrcaMmError would then be a subclass of that I guess. Would that be okay with you @timmyte ?

Comment thread src/opi/execution/mm.py Outdated
Comment thread src/opi/execution/mm.py
if raise_on_error and path.exists() and (error := path.read_text()):
raise OrcaMmException(command, arguments, error)

def run_convff(
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 document on class level, that there is also a method per command of orca_mm as this is this a repeating design pattern.

Comment thread src/opi/execution/base.py
"""
Base class that facilitates the execution of ORCA binaries.
Makes sure that correct ORCA binary and MPI libraries are used.
This class is intended to be subclassed to execute an ORCA binary.
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.

Not exactly. The class itself already allows running any ORCA binary, but for smoother a API it is helpful to subclass it.
Please reflect that in the documentation. Thanks

Comment thread src/opi/execution/mm.py
"""
expected_output = structure_file.with_suffix(self._orca_ff_suffix)

arguments = [str(structure_file)]
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 some more comments to this routine, to point out the individual steps and preparations done here, like,

  1. generating files
  2. assembling call
  3. performing call

@@ -0,0 +1,50 @@
from pathlib import Path
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 a module level description what is tested in this module and also list the individual tests.

from opi.execution.mm import OrcaMmException, OrcaMmRunner


def _set_fake_orca_path(self, orca_path: Path | None = 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.

Please add docstrings.
Mention why these fake are necessary as this is not trivial.


@pytest.mark.unit
def test_run_orca_mm_handles_deleted_empty_stderr(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(OrcaMmRunner, "set_orca_path", _set_fake_orca_path)
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.

Didn't know Pytest has MonkeyPatch. Very sophisticated. Thanks!!


runner = OrcaMmRunner()

def fake_run(binary, args, /, *, stderr=None, silent=True, timeout=-1):
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.

Again, please add docstring. Why fake execution. Please describe your design. Could also do this on module level, as the pattern is the same.

Comment thread src/opi/execution/mm.py
@@ -0,0 +1,539 @@
"""
Copy link
Copy Markdown
Contributor

@timmyte timmyte Apr 10, 2026

Choose a reason for hiding this comment

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

Also, please give the module the same name as the binary it executes/wraps. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

does this also apply to the sore orca runner or just to orca mm? What would you like the module to be called? orca_mm.py , mm_runner.py, orca_mm_runner.py?

MattBurn and others added 5 commits April 10, 2026 17:05
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
Co-authored-by: Tim Tetenberg <123412573+timmyte@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running Orca MM

3 participants