From 2590edfa025ee875bc45dbadcb14f279bdfb0f27 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Wed, 27 Nov 2024 13:05:29 +0100 Subject: [PATCH 01/12] add requires info --- src/autoplex/data/rss/jobs.py | 7 +++++++ src/autoplex/fitting/common/utils.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/autoplex/data/rss/jobs.py b/src/autoplex/data/rss/jobs.py index 39ad75000..e5ffa2dc7 100644 --- a/src/autoplex/data/rss/jobs.py +++ b/src/autoplex/data/rss/jobs.py @@ -8,7 +8,9 @@ from multiprocessing import Pool from pathlib import Path from subprocess import run +from shutil import which from typing import TYPE_CHECKING +from monty.dev import requires if TYPE_CHECKING: from pymatgen.core import Structure @@ -69,6 +71,11 @@ 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 README (https://autoatml.github.io/autoplex/user/index.html) to install required dependencies and add them to PATH.", + ) @job def make(self): """Maker to create random structures by buildcell.""" diff --git a/src/autoplex/fitting/common/utils.py b/src/autoplex/fitting/common/utils.py index 74e3c6bc9..0b5e8e81d 100644 --- a/src/autoplex/fitting/common/utils.py +++ b/src/autoplex/fitting/common/utils.py @@ -12,7 +12,9 @@ import xml.etree.ElementTree as ET from functools import partial from pathlib import Path +from shutil import which from typing import TYPE_CHECKING +from monty.dev import requires if TYPE_CHECKING: from pymatgen.core import Structure @@ -246,6 +248,11 @@ def gap_fitting( } +@requires( + which("julia"), + "J-ACE fitting requires the executables 'julia' and ACEPotentials.jl library to be in PATH. " + "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install required dependencies and add them to PATH.", + ) def jace_fitting( db_dir: str | Path, path_to_default_hyperparameters: Path | str = MLIP_RSS_DEFAULTS_FILE_PATH, From b6de25e861e5fa18c9a1c0ee866d21b08881f3fe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:08:29 +0000 Subject: [PATCH 02/12] pre-commit auto-fixes --- src/autoplex/data/rss/jobs.py | 3 ++- src/autoplex/fitting/common/utils.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/autoplex/data/rss/jobs.py b/src/autoplex/data/rss/jobs.py index e5ffa2dc7..25b702cc9 100644 --- a/src/autoplex/data/rss/jobs.py +++ b/src/autoplex/data/rss/jobs.py @@ -7,9 +7,10 @@ from dataclasses import dataclass from multiprocessing import Pool from pathlib import Path -from subprocess import run from shutil import which +from subprocess import run from typing import TYPE_CHECKING + from monty.dev import requires if TYPE_CHECKING: diff --git a/src/autoplex/fitting/common/utils.py b/src/autoplex/fitting/common/utils.py index 0b5e8e81d..c9d1607fb 100644 --- a/src/autoplex/fitting/common/utils.py +++ b/src/autoplex/fitting/common/utils.py @@ -14,6 +14,7 @@ from pathlib import Path from shutil import which from typing import TYPE_CHECKING + from monty.dev import requires if TYPE_CHECKING: @@ -249,10 +250,10 @@ def gap_fitting( @requires( - which("julia"), - "J-ACE fitting requires the executables 'julia' and ACEPotentials.jl library to be in PATH. " - "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install required dependencies and add them to PATH.", - ) + which("julia"), + "J-ACE fitting requires the executables 'julia' and ACEPotentials.jl library to be in PATH. " + "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install required dependencies and add them to PATH.", +) def jace_fitting( db_dir: str | Path, path_to_default_hyperparameters: Path | str = MLIP_RSS_DEFAULTS_FILE_PATH, From da35d43a28f33e0d0afd30a730152929ba09c043 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Wed, 27 Nov 2024 13:12:20 +0100 Subject: [PATCH 03/12] fix linting --- src/autoplex/data/rss/jobs.py | 3 ++- src/autoplex/fitting/common/utils.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/autoplex/data/rss/jobs.py b/src/autoplex/data/rss/jobs.py index 25b702cc9..4e0472c84 100644 --- a/src/autoplex/data/rss/jobs.py +++ b/src/autoplex/data/rss/jobs.py @@ -75,7 +75,8 @@ class RandomizedStructure(Maker): @requires( which("buildcell"), "RSS flows requires the executable 'buildcell' to be in PATH. " - "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install required dependencies and add them to PATH.", + "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to " + "install required dependencies and add them to PATH.", ) @job def make(self): diff --git a/src/autoplex/fitting/common/utils.py b/src/autoplex/fitting/common/utils.py index c9d1607fb..9df5cc984 100644 --- a/src/autoplex/fitting/common/utils.py +++ b/src/autoplex/fitting/common/utils.py @@ -251,8 +251,9 @@ def gap_fitting( @requires( which("julia"), - "J-ACE fitting requires the executables 'julia' and ACEPotentials.jl library to be in PATH. " - "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install required dependencies and add them to PATH.", + "J-ACE fitting requires the executable 'julia' and ACEPotentials.jl library to be in PATH. " + "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install " + "required dependencies and add them to PATH.", ) def jace_fitting( db_dir: str | Path, From 60b7a4611338dd6e08d54b8e14c3fed015d5620f Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Wed, 27 Nov 2024 14:40:48 +0100 Subject: [PATCH 04/12] raise error on lammps import error --- src/autoplex/data/rss/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/autoplex/data/rss/utils.py b/src/autoplex/data/rss/utils.py index bad022e45..5ffe5d571 100644 --- a/src/autoplex/data/rss/utils.py +++ b/src/autoplex/data/rss/utils.py @@ -407,6 +407,16 @@ def process_rss( elif mlip_type == "J-ACE": from ase.calculators.lammpslib import LAMMPSlib + try: + pass + except Exception as exc: + raise ImportError( + "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." + "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") From a972cb32217166e7fe6fe06b31c2b78442e23488 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Wed, 27 Nov 2024 14:42:20 +0100 Subject: [PATCH 05/12] fix import --- src/autoplex/data/rss/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/autoplex/data/rss/utils.py b/src/autoplex/data/rss/utils.py index 5ffe5d571..6fca907dc 100644 --- a/src/autoplex/data/rss/utils.py +++ b/src/autoplex/data/rss/utils.py @@ -408,7 +408,9 @@ def process_rss( from ase.calculators.lammpslib import LAMMPSlib try: - pass + from lammps import lammps + + _ = lammps() except Exception as exc: raise ImportError( "To use RSS flow with J-ACE potential, it needs LAMMPS compiled with" From 64c5a3ec1e5eaf53d4c5fb802b25e2083d076840 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Wed, 27 Nov 2024 14:45:38 +0100 Subject: [PATCH 06/12] change to Runtimeerror --- src/autoplex/data/rss/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autoplex/data/rss/utils.py b/src/autoplex/data/rss/utils.py index 6fca907dc..032dbe53d 100644 --- a/src/autoplex/data/rss/utils.py +++ b/src/autoplex/data/rss/utils.py @@ -412,7 +412,7 @@ def process_rss( _ = lammps() except Exception as exc: - raise ImportError( + 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." From 1ab7c5b4ce79fa724fc57b1cf32aa8adcef814c2 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 28 Nov 2024 10:07:45 +0100 Subject: [PATCH 07/12] remove non necessary log.lammps --- tests/data/log.lammps | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tests/data/log.lammps diff --git a/tests/data/log.lammps b/tests/data/log.lammps deleted file mode 100644 index 7fa9b2bdc..000000000 --- a/tests/data/log.lammps +++ /dev/null @@ -1,4 +0,0 @@ -LAMMPS (27 Jun 2024) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) - using 1 OpenMP thread(s) per MPI task -Total wall time: 0:00:23 From 7bf74e70fe5d76dabe025daaff01e19ed152cb4f Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 28 Nov 2024 10:08:41 +0100 Subject: [PATCH 08/12] add missing liblammps.so path to LD_LIBRARY_PATH to env variable --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 01cec1dfa..ee55f0f5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 From 2ebbea158e77d57f855fb15212b91608f4e45c9c Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 28 Nov 2024 10:13:31 +0100 Subject: [PATCH 09/12] update warnings --- src/autoplex/data/rss/jobs.py | 5 +++-- src/autoplex/data/rss/utils.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/autoplex/data/rss/jobs.py b/src/autoplex/data/rss/jobs.py index 4e0472c84..2adf5231e 100644 --- a/src/autoplex/data/rss/jobs.py +++ b/src/autoplex/data/rss/jobs.py @@ -75,8 +75,9 @@ class RandomizedStructure(Maker): @requires( which("buildcell"), "RSS flows requires the executable 'buildcell' to be in PATH. " - "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to " - "install required dependencies and add them to PATH.", + "Please follow the instructions in the README to install AIRSS library " + "and add it to PATH here:" + " https://autoatml.github.io/autoplex/user/index.html#enabling-rss-workflows", ) @job def make(self): diff --git a/src/autoplex/data/rss/utils.py b/src/autoplex/data/rss/utils.py index 032dbe53d..22a8cc27d 100644 --- a/src/autoplex/data/rss/utils.py +++ b/src/autoplex/data/rss/utils.py @@ -410,13 +410,21 @@ def process_rss( try: from lammps import lammps - _ = 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 here:" + " 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." - "https://autoatml.github.io/autoplex/user/index.html#lammps-installation" + "the autoplex Documentation to install LAMMPS with the required packages here:" + " https://autoatml.github.io/autoplex/user/index.html#lammps-installation" ) from exc ace_label = os.path.join(mlip_path, "acemodel.yace") From c104fcc18187ddf4354985e82c31368fbb40e0f4 Mon Sep 17 00:00:00 2001 From: Aakash Ashok Naik <91958822+naik-aakash@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:05:16 +0100 Subject: [PATCH 10/12] accept suggestion Co-authored-by: Christina Ertural <52951132+QuantumChemist@users.noreply.github.com> --- src/autoplex/data/rss/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autoplex/data/rss/utils.py b/src/autoplex/data/rss/utils.py index 22a8cc27d..f05fe8fd0 100644 --- a/src/autoplex/data/rss/utils.py +++ b/src/autoplex/data/rss/utils.py @@ -423,7 +423,7 @@ def process_rss( 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 here:" + "the autoplex documentation to install LAMMPS with the required packages here:" " https://autoatml.github.io/autoplex/user/index.html#lammps-installation" ) from exc From b8a250d95a878e29fd05796759af6b288ad19182 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 28 Nov 2024 12:08:26 +0100 Subject: [PATCH 11/12] address review comments --- src/autoplex/data/rss/jobs.py | 4 ++-- src/autoplex/data/rss/utils.py | 7 ++++--- src/autoplex/fitting/common/utils.py | 24 +++++++++++++++++++++--- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/autoplex/data/rss/jobs.py b/src/autoplex/data/rss/jobs.py index 2adf5231e..cd0b48046 100644 --- a/src/autoplex/data/rss/jobs.py +++ b/src/autoplex/data/rss/jobs.py @@ -75,8 +75,8 @@ class RandomizedStructure(Maker): @requires( which("buildcell"), "RSS flows requires the executable 'buildcell' to be in PATH. " - "Please follow the instructions in the README to install AIRSS library " - "and add it to PATH here:" + "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 diff --git a/src/autoplex/data/rss/utils.py b/src/autoplex/data/rss/utils.py index f05fe8fd0..6bde3d7bc 100644 --- a/src/autoplex/data/rss/utils.py +++ b/src/autoplex/data/rss/utils.py @@ -415,15 +415,16 @@ def process_rss( 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 here:" + "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 here:" + "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 diff --git a/src/autoplex/fitting/common/utils.py b/src/autoplex/fitting/common/utils.py index 9df5cc984..95dd4b5bf 100644 --- a/src/autoplex/fitting/common/utils.py +++ b/src/autoplex/fitting/common/utils.py @@ -251,9 +251,27 @@ def gap_fitting( @requires( which("julia"), - "J-ACE fitting requires the executable 'julia' and ACEPotentials.jl library to be in PATH. " - "Please follow the instructions in the README (https://autoatml.github.io/autoplex/user/index.html) to install " - "required dependencies and add them to PATH.", + "J-ACE fitting requires '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", +) +@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, From 773a1991453f9b4483d3e22977e5b959f31fef15 Mon Sep 17 00:00:00 2001 From: naik-aakash Date: Thu, 28 Nov 2024 12:20:58 +0100 Subject: [PATCH 12/12] remove redundant requires --- src/autoplex/fitting/common/utils.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/autoplex/fitting/common/utils.py b/src/autoplex/fitting/common/utils.py index 95dd4b5bf..fd3b4188d 100644 --- a/src/autoplex/fitting/common/utils.py +++ b/src/autoplex/fitting/common/utils.py @@ -12,7 +12,6 @@ import xml.etree.ElementTree as ET from functools import partial from pathlib import Path -from shutil import which from typing import TYPE_CHECKING from monty.dev import requires @@ -249,13 +248,6 @@ def gap_fitting( } -@requires( - which("julia"), - "J-ACE fitting requires '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", -) @requires( ( subprocess.run(