waterEntropy 1.2.2__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {waterentropy-1.2.2 → waterentropy-2.0.0}/.github/workflows/ci.yml +16 -3
- {waterentropy-1.2.2 → waterentropy-2.0.0}/.github/workflows/release.yml +6 -6
- {waterentropy-1.2.2 → waterentropy-2.0.0}/PKG-INFO +4 -2
- {waterentropy-1.2.2 → waterentropy-2.0.0}/docs/source/index.rst +3 -1
- waterentropy-2.0.0/docs/source/user_guide/hpc.rst +69 -0
- waterentropy-2.0.0/docs/source/user_guide/parallel.rst +51 -0
- waterentropy-1.2.2/docs/source/user_guide/index.rst → waterentropy-2.0.0/docs/source/user_guide/serial.rst +5 -4
- {waterentropy-1.2.2 → waterentropy-2.0.0}/pyproject.toml +3 -1
- waterentropy-2.0.0/tests/utils/test_dask_clusters.py +385 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/__init__.py +1 -1
- waterentropy-2.0.0/waterEntropy/cli/runWaterEntropy.py +264 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/recipes/interfacial_solvent.py +43 -130
- waterentropy-2.0.0/waterEntropy/utils/dask_clusters.py +134 -0
- waterentropy-1.2.2/waterEntropy/cli/runWaterEntropy.py +0 -137
- {waterentropy-1.2.2 → waterentropy-2.0.0}/.github/dependabot.yml +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/.gitignore +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/.pre-commit-config.yaml +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/.readthedocs.yml +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/LICENSE +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/README.md +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/docs/.gitignore +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/docs/Makefile +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/docs/source/conf.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/docs/source/images/ccpbiosim-logo-white-background.png +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/docs/source/images/waterentropy_logo_grey.png +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/example_inputs/lysozyme_solution/system.gro +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/example_inputs/lysozyme_solution/system.tpr +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/example_inputs/lysozyme_solution/system.trr +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/notebooks/interfacial_water_entropy.ipynb +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/analysis/test_RAD.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/amber/arginine_solution/README.md +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/amber/arginine_solution/system.nc +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/amber/arginine_solution/system.prmtop +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/gromacs/aspirin_solution/README.md +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/gromacs/aspirin_solution/system.gro +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/gromacs/aspirin_solution/system.prmtop +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/gromacs/aspirin_solution/system.trr +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/input_files/load_inputs.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/maths/test_trig.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/recipes/test_interfacial_solvent.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/utils/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/tests/utils/test_selections.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/analysis/HB.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/analysis/HB_labels.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/analysis/RAD.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/analysis/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/analysis/shell_labels.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/analysis/shells.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/cli/run_find_Nc.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/entropy/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/entropy/convariances.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/entropy/orientations.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/entropy/vibrations.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/maths/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/maths/transformations.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/maths/trig.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/recipes/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/recipes/bulk_water.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/recipes/forces_torques.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/utils/__init__.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/utils/helpers.py +0 -0
- {waterentropy-1.2.2 → waterentropy-2.0.0}/waterEntropy/utils/selections.py +0 -0
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
16
16
|
timeout-minutes: 30
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
19
|
- name: Set up Python ${{ matrix.python-version }}
|
|
20
20
|
uses: actions/setup-python@v6
|
|
21
21
|
with:
|
|
@@ -31,12 +31,25 @@ jobs:
|
|
|
31
31
|
|
|
32
32
|
- name: Report Coverage
|
|
33
33
|
uses: coverallsapp/github-action@v2
|
|
34
|
+
with:
|
|
35
|
+
flag-name: run-${{ join(matrix.*, '-') }}
|
|
36
|
+
parallel: true
|
|
37
|
+
|
|
38
|
+
finish:
|
|
39
|
+
needs: tests
|
|
40
|
+
if: ${{ always() }}
|
|
41
|
+
runs-on: ubuntu-24.04
|
|
42
|
+
steps:
|
|
43
|
+
- name: Coveralls Finished
|
|
44
|
+
uses: coverallsapp/github-action@v2.3.7
|
|
45
|
+
with:
|
|
46
|
+
parallel-finished: true
|
|
34
47
|
|
|
35
48
|
docs:
|
|
36
49
|
runs-on: ubuntu-latest
|
|
37
50
|
timeout-minutes: 15
|
|
38
51
|
steps:
|
|
39
|
-
- uses: actions/checkout@
|
|
52
|
+
- uses: actions/checkout@v6
|
|
40
53
|
- name: Set up Python 3.11
|
|
41
54
|
uses: actions/setup-python@v6
|
|
42
55
|
with:
|
|
@@ -52,7 +65,7 @@ jobs:
|
|
|
52
65
|
runs-on: ubuntu-latest
|
|
53
66
|
timeout-minutes: 15
|
|
54
67
|
steps:
|
|
55
|
-
- uses: actions/checkout@
|
|
68
|
+
- uses: actions/checkout@v6
|
|
56
69
|
- name: Set up Python 3.11
|
|
57
70
|
uses: actions/setup-python@v6
|
|
58
71
|
with:
|
|
@@ -19,7 +19,7 @@ jobs:
|
|
|
19
19
|
steps:
|
|
20
20
|
- name: checkout repository
|
|
21
21
|
id: repo
|
|
22
|
-
uses: actions/checkout@
|
|
22
|
+
uses: actions/checkout@v6
|
|
23
23
|
|
|
24
24
|
- name: get python 3.11.6
|
|
25
25
|
uses: actions/setup-python@v6
|
|
@@ -47,14 +47,14 @@ jobs:
|
|
|
47
47
|
steps:
|
|
48
48
|
|
|
49
49
|
- name: checkout
|
|
50
|
-
uses: actions/checkout@
|
|
50
|
+
uses: actions/checkout@v6
|
|
51
51
|
|
|
52
52
|
- name: Change version in repo
|
|
53
53
|
run: sed -i "s/__version__ =.*/__version__ = \"${{ github.event.inputs.version }}\"/g" waterEntropy/__init__.py
|
|
54
54
|
|
|
55
55
|
- name: send PR
|
|
56
56
|
id: pr_id
|
|
57
|
-
uses: peter-evans/create-pull-request@
|
|
57
|
+
uses: peter-evans/create-pull-request@v8.0.0
|
|
58
58
|
with:
|
|
59
59
|
commit-message: Update version to ${{ github.event.inputs.version }}
|
|
60
60
|
branch: version-update
|
|
@@ -78,7 +78,7 @@ jobs:
|
|
|
78
78
|
runs-on: ubuntu-24.04
|
|
79
79
|
steps:
|
|
80
80
|
- name: Checkout repository
|
|
81
|
-
uses: actions/checkout@
|
|
81
|
+
uses: actions/checkout@v6
|
|
82
82
|
with:
|
|
83
83
|
ref: main
|
|
84
84
|
|
|
@@ -96,7 +96,7 @@ jobs:
|
|
|
96
96
|
steps:
|
|
97
97
|
|
|
98
98
|
- name: create release
|
|
99
|
-
uses: softprops/action-gh-release@v2.
|
|
99
|
+
uses: softprops/action-gh-release@v2.5.0
|
|
100
100
|
with:
|
|
101
101
|
name: v${{ github.event.inputs.version }}
|
|
102
102
|
generate_release_notes: true
|
|
@@ -109,7 +109,7 @@ jobs:
|
|
|
109
109
|
steps:
|
|
110
110
|
|
|
111
111
|
- name: checkout
|
|
112
|
-
uses: actions/checkout@
|
|
112
|
+
uses: actions/checkout@v6
|
|
113
113
|
with:
|
|
114
114
|
ref: main
|
|
115
115
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: waterEntropy
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Python package for calculating interfacial water entropy from molecular dynamics simulations.
|
|
5
5
|
Keywords: water,entropy,molecular dynamics,forces
|
|
6
6
|
Author-email: Jas Kalayan <jas.kalayan@stfc.ac.uk>
|
|
@@ -13,9 +13,11 @@ Classifier: Natural Language :: English
|
|
|
13
13
|
Classifier: Development Status :: 3 - Alpha
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: mdanalysis>=2.10.0
|
|
16
|
-
Requires-Dist: numpy==2.3.
|
|
16
|
+
Requires-Dist: numpy==2.3.5
|
|
17
17
|
Requires-Dist: dask==2025.7.0
|
|
18
|
+
Requires-Dist: dask-jobqueue==0.9.0
|
|
18
19
|
Requires-Dist: distributed==2025.7.0
|
|
20
|
+
Requires-Dist: psutil==7.1.3
|
|
19
21
|
Requires-Dist: sphinx ; extra == "docs"
|
|
20
22
|
Requires-Dist: sphinx_rtd_theme ; extra == "docs"
|
|
21
23
|
Requires-Dist: sphinxcontrib-contentui ; extra == "docs"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
============
|
|
2
|
+
HPC Parallel
|
|
3
|
+
============
|
|
4
|
+
|
|
5
|
+
Running on HPC machines is slightly more complex that the simple dask distributed parallelism gained by using dask-distributed alone. The LocalCluster implementation gained by setting the "--parallel" flag often will not launch on HPC platforms because of how they are configured. So we have implemented a HPC friendly option that uses both dask-distributed and dask-jobqueue. Due to the complexity of how HPC machines operate, it is possible to submit these workloads in several different ways, and there are several options for manual configuration of parameters. The below table shows the HPC specific CLI flags, what they do and their default values.
|
|
6
|
+
|
|
7
|
+
================ ============================================================================ ============
|
|
8
|
+
Flag Description Default
|
|
9
|
+
================ ============================================================================ ============
|
|
10
|
+
--conda-exec conda/mamba executable override, use if having issues. autodetect
|
|
11
|
+
--conda-env Override for name of environment to load. autodetect
|
|
12
|
+
--conda-path Override for conda install. autodetect
|
|
13
|
+
--hpc Turn on HPC parallelism. False
|
|
14
|
+
--hpc-account Set HPC project/account to use for submissions. empty string
|
|
15
|
+
--hpc-constraint Constraints to apply to job allocation, such as hardware generation. empty string
|
|
16
|
+
--hpc-cores Override for number of cores on requested per node. autodetect
|
|
17
|
+
--hpc-memory Override for memory request. autodetect
|
|
18
|
+
--hpc-nodes How many nodes should the job run on. 1
|
|
19
|
+
--hpc-processes Override How many dask processes per node. This should usually match cores. autodetect
|
|
20
|
+
--hpc-queue Override for queue name to submit to. standard
|
|
21
|
+
--hpc-qos Override for QoS. empty string
|
|
22
|
+
--hpc-walltime Override for wall time job should request 24:00:00
|
|
23
|
+
--submit Have WaterEntropy submit itself to a HPC cluster False
|
|
24
|
+
================ ============================================================================ ============
|
|
25
|
+
|
|
26
|
+
The easiest option for users to launch this version of WaterEntropy, is from the commandline using our advanced auto-detection features to lookup and detect various hardware features and submit WaterEntropy to the scheduler. This is likely to be the most compliant with HPC policies of the pure CLI ways to launch. To do this you simply run:
|
|
27
|
+
|
|
28
|
+
.. code-block:: bash
|
|
29
|
+
|
|
30
|
+
waterEntropy --file-topology example_inputs/BTN_longer_sims/BTN_solvated_box.prmtop \\
|
|
31
|
+
--file-coords example_inputs/BTN_longer_sims/BTN_5000frames.nc \\
|
|
32
|
+
--start 0 --end 512 --step 1 --hpc --hpc-nodes 4 --hpc-account c01-bio \\
|
|
33
|
+
--hpc-qos standard --submit
|
|
34
|
+
|
|
35
|
+
This will submit a master job to the scheduler system which will run the WaterEntropy master process, a separate dask cluster will then be orchestrated to run the work, so you will see a single master job plus the number of nodes requested as dask-workers in the HPC queue.
|
|
36
|
+
|
|
37
|
+
It is possible to run the same command, without the "--submit" and this will run the master python process on the HPC head node, with only the dask-worker cluster being sent to the scheduler. You should note, that this will cause resources to be blocked for other users on the head node, which may be seen as bad practice or against policies on some facilities:
|
|
38
|
+
|
|
39
|
+
.. code-block:: bash
|
|
40
|
+
|
|
41
|
+
waterEntropy --file-topology example_inputs/BTN_longer_sims/BTN_solvated_box.prmtop \\
|
|
42
|
+
--file-coords example_inputs/BTN_longer_sims/BTN_5000frames.nc \\
|
|
43
|
+
--start 0 --end 128 --step 1 --hpc --hpc-account c01-bio --hpc-qos standard
|
|
44
|
+
|
|
45
|
+
If you want more control over how the WaterEntropy master process is submitted then you can submit your own script like this:
|
|
46
|
+
|
|
47
|
+
.. code-block:: bash
|
|
48
|
+
|
|
49
|
+
#!/bin/bash --login
|
|
50
|
+
|
|
51
|
+
#SBATCH --job-name=waterentropy-test
|
|
52
|
+
#SBATCH --nodes=1
|
|
53
|
+
#SBATCH --ntasks=1
|
|
54
|
+
#SBATCH --cpus-per-task=1
|
|
55
|
+
#SBATCH --time=24:00:00
|
|
56
|
+
#SBATCH --account=c01-bio
|
|
57
|
+
#SBATCH --partition=standard
|
|
58
|
+
#SBATCH --qos=standard
|
|
59
|
+
|
|
60
|
+
eval "$(/mnt/lustre/a2fs-nvme/work/c01/c01/jtg2/miniforge3/bin/conda shell.bash hook)"
|
|
61
|
+
eval "$(mamba shell hook --shell bash)"
|
|
62
|
+
mamba activate waterentropy
|
|
63
|
+
|
|
64
|
+
srun waterEntropy --file-topology example_inputs/BTN_longer_sims/BTN_solvated_box.prmtop \\
|
|
65
|
+
--file-coords example_inputs/BTN_longer_sims/BTN_5000frames.nc --start 0 --end 512 \\
|
|
66
|
+
--step 1 --hpc --hpc-nodes 4 --hpc-account c01-bio --hpc-qos standard
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Topology and trajectory files are available in the ``tests/input_files`` directory.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
============
|
|
2
|
+
Run Parallel
|
|
3
|
+
============
|
|
4
|
+
|
|
5
|
+
We have implemented a parallel computing strategy utilising the dask-distributed software package. Specifically we have implemented the LocalCluster for running parallel analyses with WaterEntropy. The parallel implementation runs the whole calculation by frames, so multiple frames of MD simulation are processed at the same time, and these are allocated 1 frame for every physical CPU core you have access to on your machine.
|
|
6
|
+
|
|
7
|
+
Here's how to use run the parallel waterEntropy from the command-line using the ``runWaterEntropy.py`` script.
|
|
8
|
+
|
|
9
|
+
.. code-block:: bash
|
|
10
|
+
|
|
11
|
+
waterEntropy -t tests/input_files/amber/arginine_solution/system.prmtop \\
|
|
12
|
+
-c tests/input_files/amber/arginine_solution/system.nc --parallel
|
|
13
|
+
|
|
14
|
+
Topology and trajectory files are available in the ``tests/input_files`` directory.
|
|
15
|
+
|
|
16
|
+
It is also possible to launch the parallel version via the API:
|
|
17
|
+
|
|
18
|
+
.. code-block:: Python
|
|
19
|
+
|
|
20
|
+
# load modules
|
|
21
|
+
from MDAnalysis import Universe
|
|
22
|
+
import waterEntropy.recipes.interfacial_solvent as GetSolvent
|
|
23
|
+
import waterEntropy.entropy.vibrations as VIB
|
|
24
|
+
import waterEntropy.entropy.orientations as OR
|
|
25
|
+
import waterEntropy.maths.trig as TRIG
|
|
26
|
+
|
|
27
|
+
# set paths for topology and trajectory files
|
|
28
|
+
topology_path = "tests/input_files/amber/arginine_solution/system.prmtop"
|
|
29
|
+
trajectory_path = "tests/input_files/amber/arginine_solution/system.nc"
|
|
30
|
+
|
|
31
|
+
# load topology and trajectory
|
|
32
|
+
u = Universe(topology_path, trajectory_path)
|
|
33
|
+
|
|
34
|
+
# set the frames to be analysed
|
|
35
|
+
start, end, step = 0, 10, 1
|
|
36
|
+
|
|
37
|
+
# Calculate the entropy
|
|
38
|
+
Sorient_dict, covariances, vibrations, frame_solvent_indices, n_frames = \
|
|
39
|
+
GetSolvent.get_interfacial_water_orient_entropy(
|
|
40
|
+
u, start, end, step,
|
|
41
|
+
parallel=True, # set True for parallel calculation
|
|
42
|
+
temperature=298, # default simulated system temperate is set to 298 Kelvin, change accordingly
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
print(f"Number of frames analysed: {n_frames}")
|
|
46
|
+
|
|
47
|
+
# Print Sorient
|
|
48
|
+
OR.print_Sorient_dicts(Sorient_dict)
|
|
49
|
+
|
|
50
|
+
# Print Svib
|
|
51
|
+
VIB.print_Svib_data(vibrations, covariances)
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
==========
|
|
2
|
-
|
|
2
|
+
Run Serial
|
|
3
3
|
==========
|
|
4
4
|
|
|
5
5
|
Here's how to use waterEntropy on the command-line using the ``runWaterEntropy.py`` script.
|
|
6
6
|
|
|
7
7
|
.. code-block:: bash
|
|
8
8
|
|
|
9
|
-
waterEntropy -t tests/input_files/amber/arginine_solution/system.prmtop
|
|
9
|
+
waterEntropy -t tests/input_files/amber/arginine_solution/system.prmtop \\
|
|
10
|
+
-c tests/input_files/amber/arginine_solution/system.nc
|
|
10
11
|
|
|
11
12
|
Topology and trajectory files are available in the ``tests/input_files`` directory.
|
|
12
13
|
|
|
@@ -32,9 +33,9 @@ Here's how to use waterEntropy via the API:
|
|
|
32
33
|
start, end, step = 0, 4, 2
|
|
33
34
|
|
|
34
35
|
# Calculate the entropy
|
|
35
|
-
Sorient_dict, covariances, vibrations, frame_solvent_indices, n_frames =
|
|
36
|
+
Sorient_dict, covariances, vibrations, frame_solvent_indices, n_frames = \
|
|
37
|
+
GetSolvent.get_interfacial_water_orient_entropy(
|
|
36
38
|
u, start, end, step,
|
|
37
|
-
parallel=False, # option to parallelise the calculate is set to False by default, set True for parallel calculation
|
|
38
39
|
temperature=298, # default simulated system temperate is set to 298 Kelvin, change accordingly
|
|
39
40
|
)
|
|
40
41
|
|
|
@@ -22,9 +22,11 @@ keywords = ["water", "entropy", "molecular dynamics", "forces"]
|
|
|
22
22
|
requires-python = ">=3.11"
|
|
23
23
|
dependencies = [
|
|
24
24
|
"mdanalysis>=2.10.0",
|
|
25
|
-
"numpy==2.3.
|
|
25
|
+
"numpy==2.3.5",
|
|
26
26
|
"dask==2025.7.0",
|
|
27
|
+
"dask-jobqueue==0.9.0",
|
|
27
28
|
"distributed==2025.7.0",
|
|
29
|
+
"psutil==7.1.3",
|
|
28
30
|
]
|
|
29
31
|
|
|
30
32
|
[project.urls]
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
""" Tests for waterEntropy dask_clusters functions in utils."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
from unittest import mock
|
|
7
|
+
|
|
8
|
+
import psutil
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
import waterEntropy.utils.dask_clusters as dc
|
|
12
|
+
|
|
13
|
+
SUBMITFILE_TESTCASE1 = """#!/bin/bash --login
|
|
14
|
+
|
|
15
|
+
#SBATCH --job-name=waterentropy-master
|
|
16
|
+
#SBATCH --nodes=1
|
|
17
|
+
#SBATCH --ntasks=1
|
|
18
|
+
#SBATCH --cpus-per-task=2
|
|
19
|
+
#SBATCH --time=24:00:00
|
|
20
|
+
#SBATCH --account=c01-bio
|
|
21
|
+
#SBATCH --partition=standard
|
|
22
|
+
#SBATCH --qos=standard
|
|
23
|
+
|
|
24
|
+
eval "$(/path/to/conda shell.bash hook)"
|
|
25
|
+
conda activate waterentropy
|
|
26
|
+
|
|
27
|
+
srun waterEntropy --file-topology box.prmtop --file-coords frames.nc --start 0 --end 512 --step 1 --hpc --hpc-nodes 4 --hpc-account c01-bio --hpc-qos standard""" # pylint: disable=line-too-long
|
|
28
|
+
|
|
29
|
+
SUBMITFILE_TESTCASE2 = """#!/bin/bash --login
|
|
30
|
+
|
|
31
|
+
#SBATCH --job-name=waterentropy-master
|
|
32
|
+
#SBATCH --nodes=1
|
|
33
|
+
#SBATCH --ntasks=1
|
|
34
|
+
#SBATCH --cpus-per-task=2
|
|
35
|
+
#SBATCH --time=24:00:00
|
|
36
|
+
#SBATCH --account=c01-bio
|
|
37
|
+
#SBATCH --partition=standard
|
|
38
|
+
#SBATCH --qos=standard
|
|
39
|
+
|
|
40
|
+
eval "$(/path/to/conda shell.bash hook)"
|
|
41
|
+
eval "$(mamba shell hook --shell bash)"
|
|
42
|
+
mamba activate waterentropy
|
|
43
|
+
|
|
44
|
+
srun waterEntropy --file-topology box.prmtop --file-coords frames.nc --start 0 --end 512 --step 1 --hpc --hpc-nodes 4 --hpc-account c01-bio --hpc-qos standard""" # pylint: disable=line-too-long
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def args_helper_directives(args):
|
|
48
|
+
"""helper to setup the CLI args."""
|
|
49
|
+
parser = argparse.ArgumentParser()
|
|
50
|
+
parser.add_argument("--hpc-account", type=str, default="")
|
|
51
|
+
parser.add_argument("--hpc-constraint", type=str, default="")
|
|
52
|
+
parser.add_argument("--hpc-qos", type=str, default="")
|
|
53
|
+
args = parser.parse_args(args)
|
|
54
|
+
return args
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def args_helper_prologues(args):
|
|
58
|
+
"""helper to setup the CLI args."""
|
|
59
|
+
parser = argparse.ArgumentParser()
|
|
60
|
+
parser.add_argument("--conda-env", type=str, default="")
|
|
61
|
+
parser.add_argument("--conda-exec", type=str, default="")
|
|
62
|
+
parser.add_argument("--conda-path", type=str, default="")
|
|
63
|
+
args = parser.parse_args(args)
|
|
64
|
+
return args
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def args_helper_submitfile(args):
|
|
68
|
+
"""helper to setup the CLI args."""
|
|
69
|
+
parser = argparse.ArgumentParser()
|
|
70
|
+
parser.add_argument("--conda-env", type=str, default="")
|
|
71
|
+
parser.add_argument("--conda-exec", type=str, default="")
|
|
72
|
+
parser.add_argument("--conda-path", type=str, default="")
|
|
73
|
+
parser.add_argument("--file-topology", type=str, default="")
|
|
74
|
+
parser.add_argument("--file-coords", type=str, default="")
|
|
75
|
+
parser.add_argument("--start", type=int, default=0)
|
|
76
|
+
parser.add_argument("--end", type=int, default=1)
|
|
77
|
+
parser.add_argument("--step", type=int, default=1)
|
|
78
|
+
parser.add_argument("--hpc", action="store_true")
|
|
79
|
+
parser.add_argument("--hpc-nodes", default="")
|
|
80
|
+
parser.add_argument("--hpc-account", type=str, default="")
|
|
81
|
+
parser.add_argument("--hpc-qos", type=str, default="")
|
|
82
|
+
parser.add_argument("--hpc-queue", type=str, default="standard")
|
|
83
|
+
parser.add_argument("--hpc-walltime", type=str, default="24:00:00")
|
|
84
|
+
parser.add_argument("--submit", action="store_true")
|
|
85
|
+
args = parser.parse_args(args)
|
|
86
|
+
return args
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def args_helper_cluster(args):
|
|
90
|
+
"""helper to setup the CLI args."""
|
|
91
|
+
parser = argparse.ArgumentParser()
|
|
92
|
+
parser.add_argument("--conda-env", type=str, default="")
|
|
93
|
+
parser.add_argument("--conda-exec", type=str, default="")
|
|
94
|
+
parser.add_argument("--conda-path", type=str, default="")
|
|
95
|
+
parser.add_argument("--file-topology", type=str, default="")
|
|
96
|
+
parser.add_argument("--file-coords", type=str, default="")
|
|
97
|
+
parser.add_argument("--start", type=int, default=0)
|
|
98
|
+
parser.add_argument("--end", type=int, default=1)
|
|
99
|
+
parser.add_argument("--step", type=int, default=1)
|
|
100
|
+
parser.add_argument("--hpc", action="store_true")
|
|
101
|
+
parser.add_argument("--hpc-account", type=str, default="")
|
|
102
|
+
parser.add_argument("--hpc-constraint", type=str, default="")
|
|
103
|
+
parser.add_argument("--hpc-cores", type=int, default=20)
|
|
104
|
+
parser.add_argument("--hpc-memory", type=str, default="16GB")
|
|
105
|
+
parser.add_argument("--hpc-nodes", type=int, default="")
|
|
106
|
+
parser.add_argument("--hpc-processes", type=int, default=20)
|
|
107
|
+
parser.add_argument("--hpc-qos", type=str, default="")
|
|
108
|
+
parser.add_argument("--hpc-queue", type=str, default="standard")
|
|
109
|
+
parser.add_argument("--hpc-walltime", type=str, default="24:00:00")
|
|
110
|
+
parser.add_argument("--submit", action="store_true")
|
|
111
|
+
args = parser.parse_args(args)
|
|
112
|
+
return args
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_slurm_envfix1():
|
|
116
|
+
"""Test that calling function at all executes ok"""
|
|
117
|
+
dc.check_slurm_env()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_slurm_envfix2():
|
|
121
|
+
"""Create target env var and see if it gets deleted."""
|
|
122
|
+
# Set the environment variable to some value and check it is set.
|
|
123
|
+
os.environ["SLURM_CPU_BIND"] = "1"
|
|
124
|
+
assert os.environ["SLURM_CPU_BIND"] == "1"
|
|
125
|
+
dc.check_slurm_env()
|
|
126
|
+
# Check we now get a keyerror exception.
|
|
127
|
+
with pytest.raises(KeyError):
|
|
128
|
+
assert os.environ["SLURM_CPU_BIND"] == "1"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_slurm_directives_account():
|
|
132
|
+
"""Test that account gets set"""
|
|
133
|
+
args = args_helper_directives(["--hpc-account", "c01"])
|
|
134
|
+
directives = dc.slurm_directives(args)[0]
|
|
135
|
+
assert directives == ['--account="c01"']
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def test_slurm_directives_constraint():
|
|
139
|
+
"""Test that constraints get set"""
|
|
140
|
+
args = args_helper_directives(["--hpc-constraint", "intel25"])
|
|
141
|
+
directives = dc.slurm_directives(args)[0]
|
|
142
|
+
assert directives == ['--constraint="intel25"']
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_slurm_directives_qos():
|
|
146
|
+
"""Test that qos gets set"""
|
|
147
|
+
args = args_helper_directives(["--hpc-qos", "standard"])
|
|
148
|
+
directives = dc.slurm_directives(args)[0]
|
|
149
|
+
assert directives == ['--qos="standard"']
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_slurm_directives_all():
|
|
153
|
+
"""Test multiple values get set."""
|
|
154
|
+
args = args_helper_directives(
|
|
155
|
+
["--hpc-account", "c01", "--hpc-constraint", "intel25", "--hpc-qos", "standard"]
|
|
156
|
+
)
|
|
157
|
+
directives = dc.slurm_directives(args)[0]
|
|
158
|
+
assert directives == [
|
|
159
|
+
'--account="c01"',
|
|
160
|
+
'--qos="standard"',
|
|
161
|
+
'--constraint="intel25"',
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_slurm_directives_skip():
|
|
166
|
+
"""Test that skipped values work."""
|
|
167
|
+
args = args_helper_directives(["--hpc-account", "c01"])
|
|
168
|
+
skip = dc.slurm_directives(args)[1]
|
|
169
|
+
assert skip == ["--mem"]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def test_slurm_prologues_conda():
|
|
173
|
+
"""Test that given plausable values that the prologue for conda is correctly assembled"""
|
|
174
|
+
args = args_helper_prologues(
|
|
175
|
+
[
|
|
176
|
+
"--conda-env",
|
|
177
|
+
"waterentropy",
|
|
178
|
+
"--conda-exec",
|
|
179
|
+
"conda",
|
|
180
|
+
"--conda-path",
|
|
181
|
+
"/path/to/conda",
|
|
182
|
+
]
|
|
183
|
+
)
|
|
184
|
+
prologue = dc.slurm_prologues(args)
|
|
185
|
+
assert prologue == [
|
|
186
|
+
'eval "$(/path/to/conda shell.bash hook)"',
|
|
187
|
+
"conda activate waterentropy",
|
|
188
|
+
"export SLURM_CPU_FREQ_REQ=2250000",
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def test_slurm_prologues_mamba():
|
|
193
|
+
"""Test that given plausable values that the prologue for mamba is correctly assembled"""
|
|
194
|
+
args = args_helper_prologues(
|
|
195
|
+
[
|
|
196
|
+
"--conda-env",
|
|
197
|
+
"waterentropy",
|
|
198
|
+
"--conda-exec",
|
|
199
|
+
"mamba",
|
|
200
|
+
"--conda-path",
|
|
201
|
+
"/path/to/conda",
|
|
202
|
+
]
|
|
203
|
+
)
|
|
204
|
+
prologue = dc.slurm_prologues(args)
|
|
205
|
+
assert prologue == [
|
|
206
|
+
'eval "$(/path/to/conda shell.bash hook)"',
|
|
207
|
+
'eval "$(mamba shell hook --shell bash)"',
|
|
208
|
+
"mamba activate waterentropy",
|
|
209
|
+
"export SLURM_CPU_FREQ_REQ=2250000",
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
@mock.patch("psutil.net_if_addrs")
|
|
214
|
+
def test_interface_selection(net_if_addrs):
|
|
215
|
+
"""Test interface selection"""
|
|
216
|
+
net_if_addrs.return_value = {"ib0": "", "eth0": ""}
|
|
217
|
+
iface = dc.system_network_interface()
|
|
218
|
+
assert iface == "ib0"
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@mock.patch("subprocess.check_output")
|
|
222
|
+
def test_submit_master(checkoutput):
|
|
223
|
+
"""Test master submit file creation"""
|
|
224
|
+
mock_stdout = mock.MagicMock()
|
|
225
|
+
mock_stdout.configure_mock(
|
|
226
|
+
**{"stdout.decode.return_value": "test job submitted id xxxxxx"}
|
|
227
|
+
)
|
|
228
|
+
checkoutput.return_value = mock_stdout
|
|
229
|
+
cli = [
|
|
230
|
+
"waterEntropy",
|
|
231
|
+
"--file-topology",
|
|
232
|
+
"box.prmtop",
|
|
233
|
+
"--file-coords",
|
|
234
|
+
"frames.nc",
|
|
235
|
+
"--start",
|
|
236
|
+
"0",
|
|
237
|
+
"--end",
|
|
238
|
+
"512",
|
|
239
|
+
"--step",
|
|
240
|
+
"1",
|
|
241
|
+
"--hpc",
|
|
242
|
+
"--hpc-nodes",
|
|
243
|
+
"4",
|
|
244
|
+
"--hpc-account",
|
|
245
|
+
"c01-bio",
|
|
246
|
+
"--hpc-qos",
|
|
247
|
+
"standard",
|
|
248
|
+
"--submit",
|
|
249
|
+
]
|
|
250
|
+
args = args_helper_submitfile(
|
|
251
|
+
[
|
|
252
|
+
"--conda-env",
|
|
253
|
+
"waterentropy",
|
|
254
|
+
"--conda-exec",
|
|
255
|
+
"conda",
|
|
256
|
+
"--conda-path",
|
|
257
|
+
"/path/to/conda",
|
|
258
|
+
"--file-topology",
|
|
259
|
+
"box.prmtop",
|
|
260
|
+
"--file-coords",
|
|
261
|
+
"frames.nc",
|
|
262
|
+
"--start",
|
|
263
|
+
"0",
|
|
264
|
+
"--end",
|
|
265
|
+
"512",
|
|
266
|
+
"--step",
|
|
267
|
+
"1",
|
|
268
|
+
"--hpc",
|
|
269
|
+
"--hpc-nodes",
|
|
270
|
+
"4",
|
|
271
|
+
"--hpc-account",
|
|
272
|
+
"c01-bio",
|
|
273
|
+
"--hpc-qos",
|
|
274
|
+
"standard",
|
|
275
|
+
"--submit",
|
|
276
|
+
]
|
|
277
|
+
)
|
|
278
|
+
with mock.patch.object(sys, "argv", cli):
|
|
279
|
+
dc.slurm_submit_master(args)
|
|
280
|
+
with open("WE-master-submit.sh", encoding="utf-8") as file:
|
|
281
|
+
submitfile = file.read()
|
|
282
|
+
assert submitfile == SUBMITFILE_TESTCASE1
|
|
283
|
+
os.remove("WE-master-submit.sh")
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@mock.patch("subprocess.check_output")
|
|
287
|
+
def test_submit_master_mamba(checkoutput):
|
|
288
|
+
"""Test master submit file creation"""
|
|
289
|
+
mock_stdout = mock.MagicMock()
|
|
290
|
+
mock_stdout.configure_mock(
|
|
291
|
+
**{"stdout.decode.return_value": "test job submitted id xxxxxx"}
|
|
292
|
+
)
|
|
293
|
+
checkoutput.return_value = mock_stdout
|
|
294
|
+
cli = [
|
|
295
|
+
"waterEntropy",
|
|
296
|
+
"--file-topology",
|
|
297
|
+
"box.prmtop",
|
|
298
|
+
"--file-coords",
|
|
299
|
+
"frames.nc",
|
|
300
|
+
"--start",
|
|
301
|
+
"0",
|
|
302
|
+
"--end",
|
|
303
|
+
"512",
|
|
304
|
+
"--step",
|
|
305
|
+
"1",
|
|
306
|
+
"--hpc",
|
|
307
|
+
"--hpc-nodes",
|
|
308
|
+
"4",
|
|
309
|
+
"--hpc-account",
|
|
310
|
+
"c01-bio",
|
|
311
|
+
"--hpc-qos",
|
|
312
|
+
"standard",
|
|
313
|
+
"--submit",
|
|
314
|
+
]
|
|
315
|
+
args = args_helper_submitfile(
|
|
316
|
+
[
|
|
317
|
+
"--conda-env",
|
|
318
|
+
"waterentropy",
|
|
319
|
+
"--conda-exec",
|
|
320
|
+
"mamba",
|
|
321
|
+
"--conda-path",
|
|
322
|
+
"/path/to/conda",
|
|
323
|
+
"--file-topology",
|
|
324
|
+
"box.prmtop",
|
|
325
|
+
"--file-coords",
|
|
326
|
+
"frames.nc",
|
|
327
|
+
"--start",
|
|
328
|
+
"0",
|
|
329
|
+
"--end",
|
|
330
|
+
"512",
|
|
331
|
+
"--step",
|
|
332
|
+
"1",
|
|
333
|
+
"--hpc",
|
|
334
|
+
"--hpc-nodes",
|
|
335
|
+
"4",
|
|
336
|
+
"--hpc-account",
|
|
337
|
+
"c01-bio",
|
|
338
|
+
"--hpc-qos",
|
|
339
|
+
"standard",
|
|
340
|
+
"--submit",
|
|
341
|
+
]
|
|
342
|
+
)
|
|
343
|
+
with mock.patch.object(sys, "argv", cli):
|
|
344
|
+
dc.slurm_submit_master(args)
|
|
345
|
+
with open("WE-master-submit.sh", encoding="utf-8") as file:
|
|
346
|
+
submitfile = file.read()
|
|
347
|
+
assert submitfile == SUBMITFILE_TESTCASE2
|
|
348
|
+
os.remove("WE-master-submit.sh")
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
@mock.patch("waterEntropy.utils.dask_clusters.system_network_interface")
|
|
352
|
+
def test_configure_cluster(interface):
|
|
353
|
+
"""Test master submit file creation"""
|
|
354
|
+
interface.return_value = list(psutil.net_if_addrs().keys())[0]
|
|
355
|
+
args = args_helper_cluster(
|
|
356
|
+
[
|
|
357
|
+
"--conda-env",
|
|
358
|
+
"waterentropy",
|
|
359
|
+
"--conda-exec",
|
|
360
|
+
"mamba",
|
|
361
|
+
"--conda-path",
|
|
362
|
+
"/path/to/conda",
|
|
363
|
+
"--file-topology",
|
|
364
|
+
"box.prmtop",
|
|
365
|
+
"--file-coords",
|
|
366
|
+
"frames.nc",
|
|
367
|
+
"--start",
|
|
368
|
+
"0",
|
|
369
|
+
"--end",
|
|
370
|
+
"512",
|
|
371
|
+
"--step",
|
|
372
|
+
"1",
|
|
373
|
+
"--hpc",
|
|
374
|
+
"--hpc-nodes",
|
|
375
|
+
"4",
|
|
376
|
+
"--hpc-account",
|
|
377
|
+
"c01-bio",
|
|
378
|
+
"--hpc-qos",
|
|
379
|
+
"standard",
|
|
380
|
+
"--submit",
|
|
381
|
+
]
|
|
382
|
+
)
|
|
383
|
+
dc.slurm_configure_cluster(args)
|
|
384
|
+
os.path.exists("dask-cluster-submit.sh")
|
|
385
|
+
os.remove("dask-cluster-submit.sh")
|