Skip to content

Fix: No search for MLatom in the virtual environment#40

Merged
cplett merged 3 commits into
faccts:mainfrom
cplett:fix/mlatom_search_path
Jul 8, 2026
Merged

Fix: No search for MLatom in the virtual environment#40
cplett merged 3 commits into
faccts:mainfrom
cplett:fix/mlatom_search_path

Conversation

@cplett

@cplett cplett commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
  • fix: Without an MLatom executable in the $PATH, the respective oet_mlatom script didn't work, even though MLatom was available in the installed virtual environment. With this fix, the MLatom executable is now searched also for in the respective virtual environment.
  • fix: Installing the dev features during the setup of the virtual environment is now done in editable mode similar to the standard installation.
  • build: bump MLatom dependency from 2.0.3 to 3.12.0.

Signed-off-by: Christoph Plett <plett@faccts.de>
@cplett cplett added this to the v2.1.0 milestone Jul 3, 2026
@cplett cplett self-assigned this Jul 3, 2026
@cplett cplett added the bug Something isn't working label Jul 3, 2026
@cplett
cplett requested a review from stgeo July 3, 2026 11:15

@stgeo stgeo left a comment

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.

Thanks for the fix! The changes look OK to me (see one comment below).

I tried a fresh install with

./install.py --venv-dir venv-mlatom --extra mlatom -d

and got a couple of issues when running the tests:

  1. With the venv activated python test_mlatom.py throws (in addition to the same warnings as below
FileNotFoundError: [Errno 2] No such file or directory: PosixPath('/redacted/orca-external-tools/venv-mlatom/lib/python3.12/site-packages/oet/../../bin/oet_mlatom')

Looks like ROOT_DIR is not what we expect.
2. Replacing ROOT_DIR with Path(__file__).resolve().parent I get

/redacted/orca-external-tools/venv-mlatom/lib/python3.12/site-packages/torchani/aev.py:16: UserWarning: cuaev not installed
  warnings.warn("cuaev not installed")
/redacted/orca-external-tools/venv-mlatom/lib/python3.12/site-packages/torchani/__init__.py:39: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import get_distribution, DistributionNotFound
/redacted/orca-external-tools/venv-mlatom/lib/python3.12/site-packages/torchani/__init__.py:55: UserWarning: Dependency not satisfied, torchani.ase will not be available
  warnings.warn("Dependency not satisfied, torchani.ase will not be available")
Checking the model files and downloading them if necessary.
/redacted/orca-external-tools/venv-mlatom/lib/python3.12/site-packages/torchani/resources/
F..
======================================================================
FAIL: test_H2O_engrad (__main__.MLatomTests.test_H2O_engrad)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/redacted/orca-external-tools/tests/mlatom/test_mlatom.py", line 104, in test_H2O_engrad
    self.assertAlmostEqual(energy, expected_energy, places=9)
AssertionError: -76.38342071073 != -76.38342071002 within 9 places (7.099885124262073e-10 difference)

----------------------------------------------------------------------
Ran 3 tests in 14.001s

FAILED (failures=1)

The deviation might be due to the mlatom update (BTW please mention the version bump in the commit message and/or PR description).

We really should integrate the tests into the CI...

I guess the torchANI/CUAEV installation is more complicated - we may want to check if we can automatically get a system-specific setup or at least expose the configuration options to the user at install time. Nothing to do now though.

Comment thread requirements/mlatom.txt
cplett added 2 commits July 7, 2026 13:19
Signed-off-by: Christoph Plett <plett@faccts.de>
Signed-off-by: Christoph Plett <plett@faccts.de>
@cplett

cplett commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@stgeo Thanks for the review.

Regarding 1: The problem with ROOT_DIR did only occur when installing the dev features during the setup of the virtual environment. This wasn't done as an editable install so the ROOT_DIR changed to the installation in site-packages. This was fixed now.

Regarding 2: I lowered the precision for the checks to 10^-7 as 10^-9 seemed to be a little bit to strict.

@cplett
cplett requested a review from stgeo July 7, 2026 11:45

@stgeo stgeo left a comment

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.

LGTM, thanks for looking into the issues!

Comment thread install.py

print("Installing developer tools.")
subprocess.check_call([pip_path, "install", ".[dev]"])
subprocess.check_call([pip_path, "install", "-e", ".[dev]"])

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.

It's not ideal if the tests only work for an editable install. We probably need a different strategy to find the binaries than using ROOT_DIR. Please open an issue or add it to the requirements for the restructuring of the test suite.

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.

Agreed. Added the point to #41.

@cplett
cplett merged commit c8585b1 into faccts:main Jul 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants