From 99603abe8c9d6298a167e4abc1c9d6bf2787f4e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 11:33:15 +0000 Subject: [PATCH 1/5] Bump requests from 2.32.3 to 2.32.4 Bumps [requests](https://github.com/psf/requests) from 2.32.3 to 2.32.4. - [Release notes](https://github.com/psf/requests/releases) - [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md) - [Commits](https://github.com/psf/requests/compare/v2.32.3...v2.32.4) --- updated-dependencies: - dependency-name: requests dependency-version: 2.32.4 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6436af2..565908f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,7 +43,7 @@ pytest==8.3.4 python-dateutil==2.9.0.post0 pytz==2025.1 PyYAML==6.0.2 -requests==2.32.3 +requests==2.32.4 ruamel.yaml==0.18.10 ruamel.yaml.clib==0.2.12 scikit-learn==1.6.1 From 59055e847d5798db43e4d5fc8b31ef0d12f7b30c Mon Sep 17 00:00:00 2001 From: Fraser Birks <119904972+Fraser-Birks@users.noreply.github.com> Date: Thu, 12 Jun 2025 16:03:16 +0100 Subject: [PATCH 2/5] Update requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 565908f..b438013 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,7 +43,7 @@ pytest==8.3.4 python-dateutil==2.9.0.post0 pytz==2025.1 PyYAML==6.0.2 -requests==2.32.4 +requests==2.32.3 ruamel.yaml==0.18.10 ruamel.yaml.clib==0.2.12 scikit-learn==1.6.1 @@ -59,4 +59,4 @@ tqdm==4.67.1 typing_extensions==4.12.2 tzdata==2025.1 uncertainties==3.2.2 -urllib3==2.3.0 \ No newline at end of file +urllib3==2.3.0 From cc08567a892e2f33200fe65338d8d4b722c75df3 Mon Sep 17 00:00:00 2001 From: Fraser Birks Date: Tue, 24 Mar 2026 19:39:06 +0000 Subject: [PATCH 3/5] made dump deterministic --- tests/test_hysteresis_lammps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_hysteresis_lammps.py b/tests/test_hysteresis_lammps.py index 62e5394..7ebd454 100644 --- a/tests/test_hysteresis_lammps.py +++ b/tests/test_hysteresis_lammps.py @@ -124,6 +124,7 @@ def hysteresis_test(verbose=False, lmps.command(f'dump decaydump all custom 1 {data_path}/dump_{pick_seed_with}.lammpstrj id type x y z fx fy fz i2_potential[1] i2_potential[2] d2_eval[1] d2_eval[2]') + lmps.command('dump_modify decaydump sort id') lmps.command('run 20') if rank == 0: @@ -210,7 +211,7 @@ def hysteresis_test(verbose=False, def test_hysteresis_group(): - hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.01, nevery=1) + hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.01, nevery=1,verbose=True) hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.002, nevery=1) hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.001, nevery=5) hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.05, nevery=10) From fa0135c37a8c683c6a6eb5973a4f1bdade8d7a4e Mon Sep 17 00:00:00 2001 From: Fraser Birks Date: Tue, 24 Mar 2026 20:18:34 +0000 Subject: [PATCH 4/5] sort arrays properly --- tests/shared/build_regions.py | 1 + tests/test_hysteresis_lammps.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/shared/build_regions.py b/tests/shared/build_regions.py index 063c86e..9041525 100644 --- a/tests/shared/build_regions.py +++ b/tests/shared/build_regions.py @@ -45,6 +45,7 @@ def build_regions_lammps(lmps, seed_atoms = get_seed_atoms(struct) # set up dump lmps.command(f'dump dump1 all custom 1 {path}/dump.lammpstrj id type x y z fx fy fz {dump_string}') + lmps.command('dump_modify dump1 sort id') lmps.command(f'dump_modify dump1 format float %20.15g') lmps.command(f'group seed_atoms id {" ".join([str(i+1) for i in seed_atoms])}') command = f'fix mlml_fix all mlml {nevery} {r_core} {r_buff} {r_blend}' diff --git a/tests/test_hysteresis_lammps.py b/tests/test_hysteresis_lammps.py index 7ebd454..e3450d1 100644 --- a/tests/test_hysteresis_lammps.py +++ b/tests/test_hysteresis_lammps.py @@ -106,6 +106,7 @@ def hysteresis_test(verbose=False, if pick_seed_with == 'group': lmps.command('delete_atoms group seed_atoms compress no') seed_atoms = get_seed_atoms(struct) + print(seed_atoms) d2_eval_lammps = np.delete(d2_eval_lammps, seed_atoms, axis=0) @@ -134,15 +135,16 @@ def hysteresis_test(verbose=False, # first check the initial step matches if pick_seed_with == 'group': d2_eval_prev = d2_eval_lammps[:,0] + print(d2_eval_prev) d2_eval_target = np.zeros_like(d2_eval_prev) d2_eval_predicted = predict_d2_eval(d2_eval_prev, d2_eval_target, nevery, dt, hysteresis_time_in, hysteresis_time_out) + print(d2_eval_predicted) next_d2_eval = dump[0].arrays['d2_eval[1]'] + print(next_d2_eval) assert np.allclose(d2_eval_predicted, next_d2_eval), f"Prediction failed at step 0" elif pick_seed_with == 'fix': assert np.allclose(dump[0].arrays['d2_eval[1]'], np.ones_like(d2_eval_lammps[:,0])), f"Prediction failed at step 0" - - for i in range(len(dump)-1): if pick_seed_with != 'group': if i < fix_nevery: @@ -211,7 +213,7 @@ def hysteresis_test(verbose=False, def test_hysteresis_group(): - hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.01, nevery=1,verbose=True) + hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.01, nevery=1) hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.002, nevery=1) hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.001, nevery=5) hysteresis_test(pick_seed_with='group', hysteresis_time_out=0.05, nevery=10) From 49168c7a3956bf94ad540cdb49d2bb44711c1260 Mon Sep 17 00:00:00 2001 From: Fraser Birks Date: Wed, 25 Mar 2026 09:05:44 +0000 Subject: [PATCH 5/5] update ci --- .github/workflows/ci.yml | 319 +++++++++++++++++++++------------------ 1 file changed, 176 insertions(+), 143 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79f57a8..da8e8cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,152 +5,185 @@ on: [push, pull_request] jobs: build-python-lammps: runs-on: ubuntu-latest + steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get install -y build-essential cmake git libfftw3-dev libopenmpi-dev mpi-default-bin mpi-default-dev - - - name: Get LAMMPS stable branch commit hash - run: | - LAMMPS_VERSION=$(git ls-remote https://github.com/lammps/lammps.git refs/heads/stable | awk '{print $1}') - echo "LAMMPS_VERSION=$LAMMPS_VERSION" >> $GITHUB_ENV - - - name: Set up python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name: Cache LAMMPS - id: lammps-cache - uses: actions/cache@v4 - with: - path: lammps - key: ${{ runner.os }}-lammps-${{ env.LAMMPS_VERSION }}-new_venv - - - name: Restore cached virtual environment - id: venv-cache - uses: actions/cache@v4 - with: - path: venv - key: venv-${{ runner.os }}-${{ hashFiles('requirements.txt') }} - restore-keys: venv-${{ runner.os }}- - - - name: Create python venv (if venv cache misses) - if: ${{ steps.venv-cache.outputs.cache-hit != 'true' }} - run: | - python -m venv test_venv - source test_venv/bin/activate - pip install -r requirements.txt - deactivate - - - - name: Clone and build LAMMPS (if lammps cache misses) - if: ${{ steps.lammps-cache.outputs.cache-hit != 'true' }} - run: | - source test_venv/bin/activate - git clone -b stable https://github.com/lammps/lammps.git - cd lammps - mkdir build - cd build - wget -O libpace.tar.gz https://github.com/wcwitt/lammps-user-pace/archive/main.tar.gz - cmake ../cmake -D PKG_PLUGIN=on\ - -D BUILD_SHARED_LIBS=on\ - -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV \ - -D PKG_ML-PACE=yes \ - -D PACELIB_MD5=$(md5sum libpace.tar.gz | awk '{print $1}') \ - -D PKG_ML-UF3=yes \ - -D PKG_EXTRA-PAIR=yes \ - -D PKG_MOLECULE=yes \ - -D PKG_MANYBODY=yes \ - ../cmake - - cmake --build . -j 20 - - cmake --install . - - make install-python - - cd ../.. - - - name: add LAMMPS to venv (if lammps cache hits, but venv misses) - if: ${{ steps.lammps-cache.outputs.cache-hit == 'true' && steps.venv-cache.outputs.cache-hit != 'true' }} - run: | - source test_venv/bin/activate - cd lammps/build - make install-python - cd ../.. - - - name: Update LAMMPS cache after build (if cache miss) - if: ${{ steps.lammps-cache.outputs.cache-hit != 'true' }} - uses: actions/cache@v4 - with: - path: lammps - key: ${{ runner.os }}-lammps-${{ env.LAMMPS_VERSION }}-new_venv - - - name: Upload venv cache after build (if cache miss or venv rebuilt) - if: ${{ steps.venv-cache.outputs.cache-hit != 'true' }} - uses: actions/cache@v4 - with: - path: test_venv - key: venv-${{ runner.os }}-${{ hashFiles('requirements.txt') }} - - - # - name: Upload LAMMPS as an artifact for other tests - # uses: actions/upload-artifact@v4 - # with: - # name: lammps - # path: lammps + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential cmake git wget \ + libfftw3-dev libopenmpi-dev mpi-default-bin mpi-default-dev + + - name: Get LAMMPS stable branch commit hash + run: | + LAMMPS_VERSION=$(git ls-remote https://github.com/lammps/lammps.git refs/heads/stable | awk '{print $1}') + echo "LAMMPS_VERSION=$LAMMPS_VERSION" >> "$GITHUB_ENV" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Restore venv cache + id: venv-cache + uses: actions/cache/restore@v4 + with: + path: test_venv + key: ${{ runner.os }}-py310-venv-${{ hashFiles('requirements.txt') }} + + - name: Create venv + if: steps.venv-cache.outputs.cache-hit != 'true' + run: | + python -m venv test_venv + source test_venv/bin/activate + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Restore LAMMPS source/build cache + id: lammps-src-cache + uses: actions/cache/restore@v4 + with: + path: lammps + key: ${{ runner.os }}-lammps-src-${{ env.LAMMPS_VERSION }} + + - name: Restore LAMMPS install cache + id: lammps-install-cache + uses: actions/cache/restore@v4 + with: + path: .cache/lammps-install + key: ${{ runner.os }}-lammps-install-${{ env.LAMMPS_VERSION }} + + - name: Clone LAMMPS + if: steps.lammps-src-cache.outputs.cache-hit != 'true' + run: | + git clone -b stable https://github.com/lammps/lammps.git + + - name: Build and install LAMMPS + if: steps.lammps-install-cache.outputs.cache-hit != 'true' + run: | + source test_venv/bin/activate + mkdir -p .cache/lammps-install + cd lammps + mkdir -p build + cd build + + wget -O libpace.tar.gz https://github.com/wcwitt/lammps-user-pace/archive/main.tar.gz + + cmake ../cmake \ + -D PKG_PLUGIN=on \ + -D BUILD_SHARED_LIBS=on \ + -D CMAKE_INSTALL_PREFIX="$GITHUB_WORKSPACE/.cache/lammps-install" \ + -D PKG_ML-PACE=yes \ + -D PACELIB_MD5=$(md5sum libpace.tar.gz | awk '{print $1}') \ + -D PKG_ML-UF3=yes \ + -D PKG_EXTRA-PAIR=yes \ + -D PKG_MOLECULE=yes \ + -D PKG_MANYBODY=yes + + cmake --build . -j"$(nproc)" + cmake --install . + + # install Python wrapper into the venv + make install-python + + - name: Reinstall Python wrapper into venv from cached LAMMPS build + if: steps.lammps-install-cache.outputs.cache-hit == 'true' + run: | + source test_venv/bin/activate + cd lammps/build + make install-python + + - name: Expose cached LAMMPS install to runtime + run: | + echo "$GITHUB_WORKSPACE/.cache/lammps-install/bin" >> "$GITHUB_PATH" + echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/.cache/lammps-install/lib:${LD_LIBRARY_PATH}" >> "$GITHUB_ENV" + + - name: Save venv cache + if: steps.venv-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: test_venv + key: ${{ runner.os }}-py310-venv-${{ hashFiles('requirements.txt') }} + + - name: Save LAMMPS source/build cache + if: steps.lammps-src-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: lammps + key: ${{ runner.os }}-lammps-src-${{ env.LAMMPS_VERSION }} + + - name: Save LAMMPS install cache + if: steps.lammps-install-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: .cache/lammps-install + key: ${{ runner.os }}-lammps-install-${{ env.LAMMPS_VERSION }} run-tests: runs-on: ubuntu-latest - needs: build-python-lammps + needs: build-python-lammps steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Install dependencies - run: | - sudo apt-get install -y build-essential cmake git libfftw3-dev libopenmpi-dev mpi-default-bin mpi-default-dev - - - name: Get LAMMPS stable branch commit hash - run: | - LAMMPS_VERSION=$(git ls-remote https://github.com/lammps/lammps.git refs/heads/stable | awk '{print $1}') - echo "LAMMPS_VERSION=$LAMMPS_VERSION" >> $GITHUB_ENV - - - name: Download LAMMPS cache - uses: actions/cache@v4 - with: - path: lammps - key: ${{ runner.os }}-lammps-${{ env.LAMMPS_VERSION }}-new_venv - - - - name: Build Plugin - run: | - cd lammps/src - LAMMPS_SRC_DIR=$(pwd) - cd ../../LAMMPS_plugin - mkdir build - cd build - cmake ../cmake \ - -D LAMMPS_SOURCE_DIR=$LAMMPS_SRC_DIR \ - -D BUILD_SHARED_LIBS=on - - cmake --build . -j 1 - - - name: Restore cached virtual environment - uses: actions/cache@v4 - with: - path: test_venv - key: venv-${{ runner.os }}-${{ hashFiles('requirements.txt') }} - restore-keys: venv-${{ runner.os }}- - - - name: Activate virtual environment and run tests - run: | - source test_venv/bin/activate - cd tests/ - pip install pytest - python -m pytest -s -v \ No newline at end of file + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential cmake git wget \ + libfftw3-dev libopenmpi-dev mpi-default-bin mpi-default-dev + + - name: Get LAMMPS stable branch commit hash + run: | + LAMMPS_VERSION=$(git ls-remote https://github.com/lammps/lammps.git refs/heads/stable | awk '{print $1}') + echo "LAMMPS_VERSION=$LAMMPS_VERSION" >> "$GITHUB_ENV" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Restore venv cache + uses: actions/cache/restore@v4 + with: + path: test_venv + key: ${{ runner.os }}-py310-venv-${{ hashFiles('requirements.txt') }} + + - name: Restore LAMMPS source/build cache + uses: actions/cache/restore@v4 + with: + path: lammps + key: ${{ runner.os }}-lammps-src-${{ env.LAMMPS_VERSION }} + + - name: Restore LAMMPS install cache + uses: actions/cache/restore@v4 + with: + path: .cache/lammps-install + key: ${{ runner.os }}-lammps-install-${{ env.LAMMPS_VERSION }} + + - name: Expose cached LAMMPS install to runtime + run: | + echo "$GITHUB_WORKSPACE/.cache/lammps-install/bin" >> "$GITHUB_PATH" + echo "LD_LIBRARY_PATH=$GITHUB_WORKSPACE/.cache/lammps-install/lib:${LD_LIBRARY_PATH}" >> "$GITHUB_ENV" + + - name: Build plugin + run: | + cd lammps/src + LAMMPS_SRC_DIR=$(pwd) + cd ../../LAMMPS_plugin + mkdir -p build + cd build + cmake ../cmake \ + -D LAMMPS_SOURCE_DIR="$LAMMPS_SRC_DIR" \ + -D BUILD_SHARED_LIBS=on + cmake --build . -j1 + + - name: Run tests + run: | + source test_venv/bin/activate + cd tests + python -m pytest -s -v \ No newline at end of file