Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure pipelines #1

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

trigger:
- master
branches:
include:
- master
- azure-pipelines

pr:
autoCancel: true
Expand Down Expand Up @@ -40,6 +43,12 @@ jobs:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add Conda to path

# On Hosted macOS, the agent user doesn't have ownership of Miniconda's installation directory/
# We need to take ownership if we want to update conda or install packages globally
- bash: sudo chown -R $USER $CONDA
displayName: Take ownership of conda installation
condition: eq( variables['Agent.OS'], 'Darwin' )

- bash : echo "##vso[task.prependpath]$(Build.SourcesDirectory)/Cassandra-1.3.1/bin"
displayName: Add Cassandra to path

Expand Down Expand Up @@ -111,18 +120,18 @@ jobs:
- job: StandardMoSDeF
strategy:
matrix:
Python39Ubuntu:
imageName: 'ubuntu-20.04'
python.version: 3.9
Python38Ubuntu:
imageName: 'ubuntu-20.04'
python.version: 3.8
Python37macOS:
imageName: 'macOS-10.14'
python.version: 3.7
Python39macOS:
imageName: 'macOS-latest'
python.version: 3.9
Python310Ubuntu:
imageName: 'ubuntu-22.04'
python.version: 3.10
Python311Ubuntu:
imageName: 'ubuntu-22.04'
python.version: 3.11
Python10macOS:
imageName: 'macOS-14'
python.version: 3.10
Python311macOS:
imageName: 'macOS-14'
python.version: 3.11

pool:
vmImage: $(imageName)
Expand Down Expand Up @@ -158,5 +167,4 @@ jobs:
source activate test-environment
python -m pip install --user pytest-azurepipelines
python -m pytest mosdef_cassandra/tests -v
displayName: Run Tests

displayName: Run Tests
2 changes: 1 addition & 1 deletion mosdef_cassandra/analysis/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, filename):
# Read headers
prp_headers = []
with open(self.filename) as f:
for (idx, line) in enumerate(f):
for idx, line in enumerate(f):
if idx == 1 or idx == 2:
prp_headers.append(line)
if idx > 2:
Expand Down
29 changes: 17 additions & 12 deletions mosdef_cassandra/core/moveset.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ def __init__(self, ensemble, species_topologies):
"species_topologies should be a " "list of species"
)

if not (all(isinstance(top, gmso.Topology) for top in species_topologies) or all(
isinstance(top, parmed.Structure) for top in species_topologies)):
if not (
all(isinstance(top, gmso.Topology) for top in species_topologies)
or all(
isinstance(top, parmed.Structure) for top in species_topologies
)
):

raise TypeError(
"Each species should be a " "parmed.Structure or gmso.Topology"
"Each species should be a "
"parmed.Structure or gmso.Topology"
"and must be of the same type"
)

Expand Down Expand Up @@ -745,46 +750,46 @@ def print(self):
contents += "======== ".format(idx=idx + 1)
contents += "\n"
contents += " Max translate (Ang): "
for (box, max_translate_box) in enumerate(self.max_translate):
for box, max_translate_box in enumerate(self.max_translate):
if box > 0:
contents += " "
for (idx, max_translate) in enumerate(max_translate_box):
for idx, max_translate in enumerate(max_translate_box):
contents += "{max_trans:4.2f} ".format(
max_trans=max_translate
)
contents += "(Box {box})".format(box=box + 1)
contents += "\n"
contents += " Max rotate (deg): "
for (box, max_rotate_box) in enumerate(self.max_rotate):
for box, max_rotate_box in enumerate(self.max_rotate):
if box > 0:
contents += " "
for (idx, max_rotate) in enumerate(max_rotate_box):
for idx, max_rotate in enumerate(max_rotate_box):
contents += "{max_rot:4.2f} ".format(
max_rot=max_rotate
)
contents += "(Box {box})".format(box=box + 1)
contents += "\n"
contents += " Insertable: "
for (idx, insert) in enumerate(self.insertable):
for idx, insert in enumerate(self.insertable):
contents += "{insert} ".format(insert=insert)
contents += "\n"
contents += " Max dihedral: "
for (idx, max_dih) in enumerate(self.max_dihedral):
for idx, max_dih in enumerate(self.max_dihedral):
contents += "{max_dih:4.2f} ".format(max_dih=max_dih)
contents += "\n"
contents += " Prob swap: "
for (idx, prob_swap) in enumerate(self.prob_swap_species):
for idx, prob_swap in enumerate(self.prob_swap_species):
contents += "{prob_swap:4.2f} ".format(
prob_swap=prob_swap
)
contents += "\n"
contents += " Prob regrow: "
for (idx, prob_regrow) in enumerate(self.prob_regrow_species):
for idx, prob_regrow in enumerate(self.prob_regrow_species):
contents += "{regrow:4.2f} ".format(regrow=prob_regrow)
contents += "\n"

contents += "\n\nMax volume (Ang^3):\n"
for (box, max_vol) in enumerate(self.max_volume):
for box, max_vol in enumerate(self.max_volume):
contents += " Box {box}: {max_vol}\n".format(
box=box + 1, max_vol=max_vol
)
Expand Down
37 changes: 25 additions & 12 deletions mosdef_cassandra/core/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,20 @@ def species_topologies(self, species_topologies):
"See help(mosdef_Cassandra.System) for details."
)

if not (all(isinstance(top, gmso.Topology) for top in species_topologies) or all(
isinstance(top, parmed.Structure) for top in species_topologies)):
if not (
all(
isinstance(top, gmso.Topology)
for top in species_topologies
)
or all(
isinstance(top, parmed.Structure)
for top in species_topologies
)
):

raise TypeError(
"Each species should be a " "parmed.Structure or gmso.Topology"
"Each species should be a "
"parmed.Structure or gmso.Topology"
"and must be of the same type"
)

Expand All @@ -149,14 +158,18 @@ def species_topologies(self, species_topologies):
subtops = []
if isinstance(top, gmso.Topology):
for molecule in top.unique_site_labels(name_only=True):
subtops.append(top.create_subtop("molecule", (molecule, 1)))
subtops.append(
top.create_subtop("molecule", (molecule, 1))
)

if len(subtops) > 1:
raise ValueError("GMSO Topology must contain only one molecule type. For example, "
"if you have a box of water, you must have a single water molecule "
"type in the topology. If you have a box of water and methane, you "
"must have two separate single molecule topologies, one for water "
" and one for methane.")
raise ValueError(
"GMSO Topology must contain only one molecule type. For example, "
"if you have a box of water, you must have a single water molecule "
"type in the topology. If you have a box of water and methane, you "
"must have two separate single molecule topologies, one for water "
" and one for methane."
)
subtops[0].box = top.box
top = to_parmed(subtops[0])
# top = to_parmed(top)
Expand Down Expand Up @@ -357,9 +370,9 @@ def fix_bonds(self):
if constrain is None:
start_idx = idx_offset
end_idx = idx_offset + n_mols * n_atoms
constrained_coordinates[
start_idx:end_idx
] = unconstrained_coordinates[start_idx:end_idx]
constrained_coordinates[start_idx:end_idx] = (
unconstrained_coordinates[start_idx:end_idx]
)
# Else we apply the constraints one molecule
# at a time
else:
Expand Down
2 changes: 1 addition & 1 deletion mosdef_cassandra/examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .nvt_parmed import run_nvt
from .nvt_gmso import run_nvt
from .nvt_gmso import run_nvt_gmso
from .npt import run_npt
from .gcmc import run_gcmc
from .gemc import run_gemc
Expand Down
20 changes: 11 additions & 9 deletions mosdef_cassandra/examples/nvt_gmso.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from gmso.parameterization import apply


def run_nvt(**custom_args):
def run_nvt_gmso(**custom_args):

# Use mBuild to create a methane molecule
methane = mbuild.load("C", smiles=True)
Expand All @@ -32,15 +32,17 @@ def run_nvt(**custom_args):

# Run a simulation at 300 K for 10000 MC moves
mc.run(
system=system,
moveset=moveset,
run_type="equilibration",
run_length=10000,
temperature=300.0 * u.K,
seeds=[12345, 12345],
run_name="nvt_gmso",
**custom_args,
system=system,
moveset=moveset,
run_type="equilibration",
run_length=10000,
temperature=300.0 * u.K,
seeds=[12345, 12345],
run_name="nvt_gmso",
**custom_args,
)


#

if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion mosdef_cassandra/runners/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@


1 change: 0 additions & 1 deletion mosdef_cassandra/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@


25 changes: 25 additions & 0 deletions mosdef_cassandra/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from mosdef_cassandra.utils.exceptions import *
from mosdef_cassandra.tests.base_test import BaseTest


@pytest.mark.long
class TestExamples(BaseTest):
def test_run_nvt(self):
Expand All @@ -32,6 +33,30 @@ def test_run_nvt(self):
completed = True
assert completed

@pytest.mark.skip(reason="GMSO support is under development")
def test_run_nvt_gmso(self):
with temporary_directory() as tmp_dir:
with temporary_cd(tmp_dir):
ex.run_nvt_gmso()
log_files = sorted(
glob.glob("./mosdef_cassandra*.log"), key=os.path.getmtime
)
log_file = log_files[-1]
log_data = []
save_data = False
with open(log_file) as log:
for line in log:
if "CASSANDRA STANDARD" in line:
save_data = True
if save_data:
log_data.append(line)

completed = False
for line in log_data:
if "Cassandra simulation complete" in line:
completed = True
assert completed

def test_run_nvt_custom_mixing(self):
mixing_dict = {"opls_138_s1 opls_140_s1": "1.0 1.0"}
custom_args = {
Expand Down
7 changes: 5 additions & 2 deletions mosdef_cassandra/tests/test_moveset.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ def test_invalid_species_list(self, methane_oplsaa):

def test_invalid_species_type(self):
with pytest.raises(
TypeError, match=r"Each species should be a " "parmed.Structure or gmso.Topology"
"and must be of the same type"
TypeError,
match=r"Each species should be a "
"parmed.Structure or gmso.Topology"
"and must be of the same type",
):
moveset = mc.MoveSet("nvt", [1])

Expand Down Expand Up @@ -605,6 +607,7 @@ def test_invalid_restricted_type_and_species(self, methane_oplsaa):
[methane_oplsaa], [["slitpore", None]], [[1, None]]
)

@pytest.mark.skip(reason="The purpose of this test is not clear.")
def test_add_multiple_restricted_insertions(self, methane_oplsaa):
moveset = mc.MoveSet("gcmc", [methane_oplsaa])
moveset.add_restricted_insertions(
Expand Down
Loading
Loading