Skip to content

Commit

Permalink
Merge pull request #273 from naik-aakash/raise_informative_actions
Browse files Browse the repository at this point in the history
Raise informative errors on missing non-python dependencies when invoked
  • Loading branch information
naik-aakash authored Nov 28, 2024
2 parents e48bd5e + 9983167 commit 092ac51
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ RUN curl -fsSL https://download.lammps.org/tars/lammps.tar.gz -o /opt/lammps.tar
&& make install-python \
&& cmake --build . --target clean

# Add LAMMPS to PATH
# Add LAMMPS to PATH and Shared LAMMPS library to LD_LIBRARY_PATH
ENV PATH="${PATH}:/root/.local/bin"
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/root/.local/lib"

# Set the working directory
WORKDIR /workspace
Expand Down
10 changes: 10 additions & 0 deletions src/autoplex/data/rss/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
from dataclasses import dataclass
from multiprocessing import Pool
from pathlib import Path
from shutil import which
from subprocess import run
from typing import TYPE_CHECKING

from monty.dev import requires

if TYPE_CHECKING:
from pymatgen.core import Structure

Expand Down Expand Up @@ -69,6 +72,13 @@ class RandomizedStructure(Maker):
fragment_file: str | None = None
fragment_numbers: list[str] | None = None

@requires(
which("buildcell"),
"RSS flows requires the executable 'buildcell' to be in PATH. "
"Please follow the instructions in the autoplex documentation to install "
"the AIRSS library and add it to PATH. Link to the documentation:"
" https://autoatml.github.io/autoplex/user/index.html#enabling-rss-workflows",
)
@job
def make(self):
"""Maker to create random structures by buildcell."""
Expand Down
21 changes: 21 additions & 0 deletions src/autoplex/data/rss/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,27 @@ def process_rss(
elif mlip_type == "J-ACE":
from ase.calculators.lammpslib import LAMMPSlib

try:
from lammps import lammps

lmp = lammps()
if "ML-PACE" not in lmp.installed_packages:
raise RuntimeError(
"To use RSS flow with J-ACE potential, it needs LAMMPS compiled with"
"lammps-user-pace library. ML-PACE is not found in the current LAMMPS binary installation."
"Please follow the instructions in the autoplex documentation to install"
"LAMMPS with the required packages. Link to the documentation: "
" https://autoatml.github.io/autoplex/user/index.html#lammps-installation"
)
except Exception as exc:
raise RuntimeError(
"To use RSS flow with J-ACE potential, it needs LAMMPS compiled with"
"python bindings and lammps-user-pace. Please follow the instructions in"
"the autoplex documentation to install LAMMPS with the required packages. "
"Link to the documentation:"
" https://autoatml.github.io/autoplex/user/index.html#lammps-installation"
) from exc

ace_label = os.path.join(mlip_path, "acemodel.yace")
ace_json = os.path.join(mlip_path, "acemodel.json")
ace_table = os.path.join(mlip_path, "acemodel_pairpot.table")
Expand Down
19 changes: 19 additions & 0 deletions src/autoplex/fitting/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from pathlib import Path
from typing import TYPE_CHECKING

from monty.dev import requires

if TYPE_CHECKING:
from pymatgen.core import Structure

Expand Down Expand Up @@ -253,6 +255,23 @@ def gap_fitting(
}


@requires(
(
subprocess.run(
'julia -e "using Pkg; println(haskey(Pkg.dependencies(), '
'Base.UUID(\\"3b96b61c-0fcc-4693-95ed-1ef9f35fcc53\\")))"',
shell=True,
capture_output=True,
text=True,
check=False,
).stdout.strip()
)
== "true",
"J-ACE fitting requires the executable 'julia' and ACEPotentials.jl v0.6.7 library to be in PATH. "
"Please follow the instructions in the autoplex documentation to install the required julia dependencies "
"and add them to PATH. Link to the documentation:"
" https://autoatml.github.io/autoplex/user/index.html#standard-installation",
)
def jace_fitting(
db_dir: str | Path,
path_to_default_hyperparameters: Path | str = MLIP_RSS_DEFAULTS_FILE_PATH,
Expand Down
4 changes: 0 additions & 4 deletions tests/data/log.lammps

This file was deleted.

0 comments on commit 092ac51

Please sign in to comment.