Skip to content

Commit

Permalink
Merge pull request #210 from hmcezar/main
Browse files Browse the repository at this point in the history
Fix CI tests
  • Loading branch information
hmcezar authored Apr 5, 2023
2 parents aeacd7b + 9d4a74f commit 20ac689
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 26 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ jobs:
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions docs/docs_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ sphinxcontrib.bibtex
matplotlib
numpy
numpydoc
jinja2<3.1
5 changes: 3 additions & 2 deletions hymd/configure_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cProfile
import logging
import pstats
import tomli
from .logger import Logger, print_header
from .input_parser import read_config_toml, parse_config_toml

Expand Down Expand Up @@ -188,14 +189,14 @@ def profile_atexit():
)

if args.topol is not None:
topol = read_config_toml(args.topol)
topol = tomli.loads(read_config_toml(args.topol))
# Check if we have single "itp" files and add their keys to topol
if os.path.dirname(args.topol) == "":
args.topol = "./" + args.topol
if "include" in topol["system"]:
for file in topol["system"]["include"]:
path = f"{os.path.dirname(args.topol)}/{file}"
itps = read_config_toml(path)
itps = tomli.loads(read_config_toml(path))
for mol, itp in itps.items():
topol[mol] = itp
else:
Expand Down
10 changes: 6 additions & 4 deletions hymd/input_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,9 @@ def __str__(self):


def read_config_toml(file_path):
with open(file_path, "rb") as in_file:
toml_content = tomli.load(in_file)
return toml_content

with open(file_path, "r") as in_file:
file_content = in_file.read()
return file_content

def propensity_potential_coeffs(x: float, comm):
alpha_coeffs = np.array(
Expand Down Expand Up @@ -369,6 +368,9 @@ def propensity_potential_coeffs(x: float, comm):
def parse_config_toml(toml_content, file_path=None, comm=MPI.COMM_WORLD):
config_dict = {}

# read toml to a dictionary
toml_content = tomli.loads(toml_content)

# Defaults = None
for n in (
"box_size",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[build-system]
requires = ["setuptools<60", "wheel", "numpy", "cython", "mpi4py"]
requires = ["setuptools<60", "wheel", "numpy<1.24", "cython", "mpi4py"]
[tool.black]
exclude = "\\(./)"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ h5py
mpi4py
mpsort
networkx
numpy
numpy<1.24
pfft-python
pmesh
sympy
Expand Down
32 changes: 16 additions & 16 deletions test/test_configure_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,54 @@ def test_configure_runtime(h5py_molecules_file, config_toml,

basearg = [config_toml_file, h5py_molecules_file]

parsed, config, prng = configure_runtime(basearg, comm)
parsed, config, prng, topol = configure_runtime(basearg, comm)
assert isinstance(parsed, Namespace)
assert isinstance(config, Config)
assert isinstance(prng, np.random.Generator)
assert parsed.destdir == "."
assert parsed.logfile == "sim.log"

parsed, _, _ = configure_runtime(["-v", "2"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["-v", "2"]+basearg, comm)
assert parsed.verbose == 2

parsed, _, _ = configure_runtime(["--disable-field"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--disable-field"]+basearg, comm)
assert parsed.disable_field

parsed, _, _ = configure_runtime(["--disable-bonds"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--disable-bonds"]+basearg, comm)
assert parsed.disable_bonds

parsed, _, _ = configure_runtime(["--disable-angle-bonds"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--disable-angle-bonds"]+basearg, comm)
assert parsed.disable_angle_bonds

parsed, _, _ = configure_runtime(["--disable-dihedrals"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--disable-dihedrals"]+basearg, comm)
assert parsed.disable_dihedrals

parsed, _, _ = configure_runtime(["--disable-dipole"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--disable-dipole"]+basearg, comm)
assert parsed.disable_dipole

parsed, _, _ = configure_runtime(["--double-precision"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--double-precision"]+basearg, comm)
assert parsed.double_precision

parsed, _, _ = configure_runtime(["--double-output"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--double-output"]+basearg, comm)
assert parsed.double_output

parsed, _, _ = configure_runtime(["--dump-per-particle"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--dump-per-particle"]+basearg, comm)
assert parsed.dump_per_particle

parsed, _, _ = configure_runtime(["--force-output"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--force-output"]+basearg, comm)
assert parsed.force_output

parsed, _, _ = configure_runtime(["--velocity-output"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--velocity-output"]+basearg, comm)
assert parsed.velocity_output

parsed, _, _ = configure_runtime(["--disable-mpio"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--disable-mpio"]+basearg, comm)
assert parsed.disable_mpio

parsed, _, _ = configure_runtime(["--destdir", "testdir"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--destdir", "testdir"]+basearg, comm)
assert parsed.destdir == "testdir"

parsed, _, _ = configure_runtime(["--seed", "54321"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--seed", "54321"]+basearg, comm)
assert parsed.seed == 54321

parsed, _, _ = configure_runtime(["--logfile", "test.log"]+basearg, comm)
parsed, _, _, _ = configure_runtime(["--logfile", "test.log"]+basearg, comm)
assert parsed.logfile == "test.log"
3 changes: 2 additions & 1 deletion test/test_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ def test_setup_time_dependent_element(config_toml, tmp_path):

assert isinstance(group, h5py.Group)
assert group.name == "/test/position"
assert group.attrs["units"] == "nm"

assert isinstance(step, h5py.Dataset)
assert isinstance(time, h5py.Dataset)
assert time.attrs["unit"] == "ps"
assert isinstance(value, h5py.Dataset)
assert value.attrs["unit"] == "nm"

out.close_file()

Expand Down

0 comments on commit 20ac689

Please sign in to comment.