-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Split workflows * Add Codecov * Add unit tests
- Loading branch information
Showing
9 changed files
with
196 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
codecov: | ||
branch: main | ||
notify: | ||
require_ci_to_pass: yes | ||
|
||
coverage: | ||
precision: 0 | ||
round: down | ||
range: "70...100" | ||
status: | ||
project: | ||
default: | ||
enabled: yes | ||
threshold: 5 | ||
patch: | ||
default: | ||
enabled: yes | ||
threshold: 5% | ||
changes: no | ||
|
||
comment: false | ||
|
||
ignore: | ||
- "samples" | ||
- "maintainer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: 'dependencies' | ||
description: 'Install pyMBE dependencies' | ||
inputs: | ||
extra-python-packages: | ||
description: Newline-separated list of arguments for pip. | ||
required: false | ||
modules: | ||
description: Newline-separated list of arguments for module load. | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- run: | | ||
module load ${{ inputs.modules }} | ||
module save pymbe | ||
python3 -m venv --system-site-packages venv | ||
source venv/bin/activate | ||
python3 maintainer/configure_venv.py | ||
echo -e "\n" >> requirements.txt | ||
echo "${{ inputs.extra-python-packages }}" >> requirements.txt | ||
python3 -m pip install -r requirements.txt | ||
git checkout requirements.txt | ||
deactivate | ||
module purge | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: samples | ||
|
||
on: | ||
schedule: | ||
- cron: '20 6 5,20 * *' # biweekly at 06:20 AM UTC+00 (on the 5th and 20th of the month) | ||
workflow_dispatch: # manual trigger | ||
|
||
permissions: | ||
contents: read # to fetch code (actions/checkout) | ||
|
||
jobs: | ||
samples: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'schedule' && github.repository == 'pyMBE-dev/pyMBE' || github.event_name != 'schedule' }} | ||
env: | ||
FI_PROVIDER: "^psm3,psm3;ofi_rxd" | ||
OMPI_MCA_mtl_ofi_provider_exclude: psm3 | ||
steps: | ||
- name: Setup EESSI | ||
uses: eessi/github-action-eessi@v3 | ||
with: | ||
eessi_stack_version: "2023.06" | ||
- name: Checkout repository | ||
uses: actions/checkout@main | ||
- name: Install dependencies | ||
uses: ./.github/actions/dependencies | ||
with: | ||
modules: |- | ||
ESPResSo/4.2.1-foss-2023a | ||
- name: Run testsuite | ||
run: | | ||
module restore pymbe | ||
source venv/bin/activate | ||
make functional_tests | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# pyMBE: the Python-based Molecule Builder for ESPResSo | ||
|
||
![GitHub Actions](https://github.com/pyMBE-dev/pyMBE/actions/workflows/testsuite.yml/badge.svg) | ||
[![codecov](https://codecov.io/gh/pyMBE-dev/pyMBE/branch/codecov/graph/badge.svg)](https://codecov.io/gh/pyMBE-dev/pyMBE) | ||
|
||
pyMBE provides tools to facilitate building up molecules with complex architectures in the Molecular Dynamics software [ESPResSo](https://espressomd.org/wordpress/). Some examples of molecules that can be set up with pyMBE are polyelectrolytes, peptides and proteins. pyMBE bookkeeps all the information about the molecule topology, permitting to link each particle to its corresponding residue and molecule. pyMBE uses the [Pint](https://pint.readthedocs.io/en/stable/) library to enable input parameters in any arbitrary unit system, which is later transformed in the reduced unit system used in ESPResSo. | ||
|
||
## Dependencies | ||
|
@@ -47,8 +50,8 @@ git clone [email protected]:pyMBE-dev/pyMBE.git | |
Please, be aware that pyMBE is intended to be a supporting tool to setup simulations with ESPResSo. | ||
Thus, for most of its functionalities ESPResSo must also be available. Following the NEP29 guidelines, we recommend the users of pyMBE to use Python3.10+ when using our module. | ||
|
||
The pyMBE module uses its own Python virtual enviroment to avoid incompatibility issues when loading its requierements from other libraries. | ||
The Python module (`venv`)[https://docs.python.org/3/library/venv.html#module-venv] from the Python Standard Library (starting with Python 3.3) is needed to set up pyMBE. | ||
The pyMBE module uses its own Python virtual enviroment to avoid incompatibility issues when loading its requirements from other libraries. | ||
The Python module [`venv`](https://docs.python.org/3/library/venv.html) is needed to set up pyMBE. | ||
If `venv` is not in the Python distribution of the user, the user will need to first install 'venv' before setting up pyMBE. | ||
For Ubuntu users, this can be done as follows: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import io | ||
import json | ||
import contextlib | ||
import unittest as ut | ||
import numpy as np | ||
import pandas as pd | ||
import pyMBE | ||
import lib.analysis | ||
|
||
|
||
class Serialization(ut.TestCase): | ||
|
||
def test_json_encoder(self): | ||
encoder = pyMBE.pymbe_library.NumpyEncoder | ||
# Python types | ||
self.assertEqual(json.dumps(1, cls=encoder), "1") | ||
self.assertEqual(json.dumps([1, 2], cls=encoder), "[1, 2]") | ||
self.assertEqual(json.dumps((1, 2), cls=encoder), "[1, 2]") | ||
self.assertEqual(json.dumps({1: 2}, cls=encoder), """{"1": 2}""") | ||
# NumPy types | ||
self.assertEqual(json.dumps(np.array([1, 2]), cls=encoder), "[1, 2]") | ||
self.assertEqual(json.dumps(np.array(1), cls=encoder), "1") | ||
self.assertEqual(json.dumps(np.int32(1), cls=encoder), "1") | ||
# Pandas types | ||
with self.assertRaisesRegex(TypeError, "Object of type Series is not JSON serializable"): | ||
json.dumps(pd.Series([1, 2]), cls=encoder) | ||
|
||
def test_parameters_to_path(self): | ||
params = {"kT": 2., "phi": -np.pi, "n": 3, "fene": True, "name": "pep"} | ||
name = lib.analysis.built_output_name(params) | ||
self.assertEqual(name, "kT-2_phi--3.14_n-3_fene-True_name-pep") | ||
params_out = lib.analysis.get_params_from_dir_name(name) | ||
params_ref = {"kT": "2", "phi": "-3.14", "n": "3", | ||
"fene": "True", "name": "pep"} | ||
self.assertEqual(params_out, params_ref) | ||
|
||
def test_pint_units(self): | ||
ref_output = [ | ||
"Current set of reduced units:", | ||
"0.355 nanometer = 1 reduced_length", | ||
"4.1164e-21 joule = 1 reduced_energy", | ||
"1.6022e-19 coulomb = 1 reduced_charge", | ||
"Temperature: 298.15 kelvin", | ||
] | ||
pmb = pyMBE.pymbe_library(SEED=42) | ||
with contextlib.redirect_stdout(io.StringIO()) as f: | ||
pmb.print_reduced_units() | ||
self.assertEqual(f.getvalue().strip("\n").split("\n"), ref_output) | ||
|
||
|
||
if __name__ == "__main__": | ||
ut.main() |