Skip to content

Commit

Permalink
Merge pull request #46 from Becksteinlab/develop
Browse files Browse the repository at this point in the history
NAMD Testing with private image + Docs
  • Loading branch information
ljwoods2 authored Dec 18, 2024
2 parents b49a4b4 + 7801fc1 commit 9b82a06
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 22 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ jobs:
if: github.repository == 'Becksteinlab/imdclient'
runs-on: ubuntu-latest

permissions:
contents: read
packages: read

steps:
- uses: actions/checkout@v4

Expand All @@ -132,6 +136,13 @@ jobs:
df -h
ulimit -a
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.NAMD_DOCKER_TOKEN }}

- name: Install conda dependencies
uses: conda-incubator/setup-miniconda@v2
with:
Expand Down Expand Up @@ -161,9 +172,18 @@ jobs:
python --version
python -m pip install . --no-deps
- name: Pull container
- name: Pull private NAMD container
run: |
docker pull ghcr.io/becksteinlab/streaming-namd-docker:main-common-cpu
# Uses private container
- name: Run NAMD tests
run: |
pytest -v --color=yes imdclient/tests/test_namd.py
- name: Pull GROMACS + LAMMPS container
run: |
docker pull ghcr.io/becksteinlab/streaming-md-docker:main-Common-CPU
docker pull ghcr.io/becksteinlab/streaming-md-docker:main-common-cpu
- name: Run GROMACS tests
run: |
Expand All @@ -172,11 +192,6 @@ jobs:
- name: Run LAMMPS tests
run: |
pytest -v --color=yes imdclient/tests/test_lammps.py
# SUSPEND until NAMD permissions are resolved
# - name: Run NAMD tests
# run: |
# pytest -v --color=yes imdclient/tests/test_namd.py
pylint_check:
if: github.repository == 'Becksteinlab/imdclient'
Expand Down
27 changes: 22 additions & 5 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,36 @@ MDAnalysis IMDReader client when this line is printed to the terminal:
IMD: Will wait until I have a connection and IMD_GO orders.
You are now ready to connect to the simulation engine with a client.

NAMD
----
In NAMD, the simulation will wait for a client connection when the
``IMDon`` option is set to ``yes`` in the NAMD configuration file.
Other options that can be set are detailed
`here <https://github.com/amruthesht/namd-3.0/blob/IMDv3-dev/IMDv3-dev.md>`_.
This will produce a simulation that is ready for a client connection with the
To use IMDv3 with NAMD, add the following lines to your NAMD configuration file:

.. code-block:: none
IMDon yes
IMDport <port, must be the same port used for the client>
IMDwait <yes/no>
IMDfreq <frequency of sending data to the client>
IMDsendPositions <yes/no>
IMDsendEnergies <yes/no>
IMDsendTime <yes/no>
IMDsendBoxDimensions <yes/no>
IMDsendVelocities <yes/no>
IMDsendForces <yes/no>
IMDwrapPositions <yes/no>
Once the simulation is ready for a client connection, it will print
following terminal message:

.. code-block:: none
Info: INTERACTIVE MD AWAITING CONNECTION
You are now ready to connect to the simulation engine with a client.

Using IMDClient with MDAnalysis
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 6 additions & 1 deletion imdclient/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def assert_allclose_with_logging(a, b, rtol=1e-07, atol=0, equal_nan=False):

class IMDv3IntegrationTest:

@pytest.fixture()
def container_name(self):
return "ghcr.io/becksteinlab/streaming-md-docker:main-common-cpu"

@pytest.fixture()
def setup_command(self):
return None
Expand All @@ -80,12 +84,13 @@ def docker_client(
setup_command,
simulation_command,
port,
container_name,
):
# In CI, container process needs access to tmp_path
tmp_path.chmod(0o777)
docker_client = docker.from_env()
img = docker_client.images.pull(
"ghcr.io/becksteinlab/streaming-md-docker:main-Common-CPU"
container_name,
)
# Copy input files into tmp_path
for inp in input_files:
Expand Down
2 changes: 1 addition & 1 deletion imdclient/tests/docker_testing/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Ensure [docker](https://www.docker.com/) and the [NVIDIA container toolkit](http

To run the container:
```bash
docker pull ghcr.io/becksteinlab/streaming-md-docker:main-Common-GPU
docker pull ghcr.io/becksteinlab/streaming-md-docker:main-common-gpu

docker run -v $PWD/imdclient/data:/home/conda:rw -it --runtime=nvidia --gpus=all \
ghcr.io/becksteinlab/streaming-md-docker:main-Common-GPU
Expand Down
17 changes: 9 additions & 8 deletions imdclient/tests/test_namd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

class TestIMDv3NAMD(IMDv3IntegrationTest):

@pytest.fixture()
def container_name(self):
return "ghcr.io/becksteinlab/streaming-namd-docker:main-common-cpu"

@pytest.fixture(params=[NAMD_CONF_NST_1, NAMD_CONF_NST_8])
def inp(self, request):
return request.param
Expand Down Expand Up @@ -87,10 +91,8 @@ def test_compare_imd_to_true_traj(self, imd_u, true_u, first_frame):
imd_u.trajectory[i - first_frame].dt,
atol=1e-03,
)
assert_allclose(
true_u.trajectory[i].data["step"],
imd_u.trajectory[i - first_frame].data["step"],
)
# step in DCDReader is frame index, not integration step
# don't compare step
assert_allclose_with_logging(
true_u.trajectory[i].dimensions,
imd_u.trajectory[i - first_frame].dimensions,
Expand All @@ -103,12 +105,11 @@ def test_compare_imd_to_true_traj(self, imd_u, true_u, first_frame):
)

# Compare velocities
def test_compare_imd_to_true_traj_vel(
self, imd_u, true_u_vel, first_frame
):
def test_compare_imd_to_true_traj_vel(self, imd_u, true_u_vel, first_frame):
for i in range(first_frame, len(true_u_vel.trajectory)):
assert_allclose_with_logging(
true_u_vel.trajectory[i].positions,
# Unit conversion
true_u_vel.trajectory[i].positions * 20.45482706,
imd_u.trajectory[i - first_frame].velocities,
atol=1e-03,
)
Expand Down

0 comments on commit 9b82a06

Please sign in to comment.