Skip to content

Commit

Permalink
Merge pull request #37 from rsdefever/update/cassandra-source
Browse files Browse the repository at this point in the history
Switch to github release and conda release for AZP testing
  • Loading branch information
rsdefever authored Mar 26, 2020
2 parents b23f228 + 5aef853 commit c0b23dc
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 106 deletions.
89 changes: 11 additions & 78 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add Conda to path

- bash : echo "##vso[task.prependpath]$(Build.SourcesDirectory)/mosdef_cassandra/tests/files/Cassandra_V1.2/bin"
- bash : echo "##vso[task.prependpath]$(Build.SourcesDirectory)/Cassandra-1.2.2/bin"
displayName: Add Cassandra to path

# On Hosted macOS, the agent user doesn't have ownership of Miniconda's installation directory/
Expand All @@ -56,35 +56,22 @@ jobs:
condition: eq( variables['Agent.OS'], 'Linux' )
- bash: |
brew install gcc@8
brew upgrade gcc@8
gfortran-8 --version
brew install gcc
brew upgrade gcc
gfortran --version
displayName: Install gfortran macOS
condition: eq( variables['Agent.OS'], 'Darwin' )
- bash: |
cd mosdef_cassandra/tests/files/
tar -xzvf Cassandra_V1.2.tar.gz
cd Cassandra_V1.2/Src
wget https://github.com/MaginnGroup/Cassandra/archive/v1.2.2.tar.gz
tar -xzvf v1.2.2.tar.gz
cd Cassandra-1.2.2/Src
make -f Makefile.gfortran
mkdir ../bin
cp cassandra_gfortran.exe ../bin/.
cp ../Scripts/Frag_Library_Setup/library_setup.py ../bin/.
cd ../../../../../
cd ../../
displayName: Build Cassandra Linux
condition: eq( variables['Agent.OS'], 'Linux' )
- bash: |
cd mosdef_cassandra/tests/files/
tar -xzvf Cassandra_V1.2.tar.gz
cd Cassandra_V1.2/Src
make -f Makefile.gfortran FC=gfortran-8
mkdir ../bin
cp cassandra_gfortran.exe ../bin/.
cp ../Scripts/Frag_Library_Setup/library_setup.py ../bin/.
cd ../../../../../
displayName: Build Cassandra macOS
condition: eq( variables['Agent.OS'], 'Darwin' )
- bash: |
echo Working directory:
Expand Down Expand Up @@ -154,7 +141,7 @@ jobs:
imageName: 'macOS-10.14'
python.version: 3.7
Python36macOS:
imageName: 'macOS-10.14'
imageName: 'macOS-latest'
python.version: 3.6

pool:
Expand All @@ -164,68 +151,12 @@ jobs:
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add Conda to path

- bash : echo "##vso[task.prependpath]$(Build.SourcesDirectory)/mosdef_cassandra/tests/files/Cassandra_V1.2/bin"
displayName: Add Cassandra 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: |
sudo apt-get update
sudo apt-get install gfortran
gfortran --version
displayName: Install gfortran Linux
condition: eq( variables['Agent.OS'], 'Linux' )
- bash: |
brew install gcc@8
brew upgrade gcc@8
gfortran-8 --version
displayName: Install gfortran macOS
condition: eq( variables['Agent.OS'], 'Darwin' )
- bash: |
cd mosdef_cassandra/tests/files/
tar -xzvf Cassandra_V1.2.tar.gz
cd Cassandra_V1.2/Src
make -f Makefile.gfortran
mkdir ../bin
cp cassandra_gfortran.exe ../bin/.
cp ../Scripts/Frag_Library_Setup/library_setup.py ../bin/.
cd ../../../../../
displayName: Build Cassandra Linux
condition: eq( variables['Agent.OS'], 'Linux' )
- bash: |
cd mosdef_cassandra/tests/files/
tar -xzvf Cassandra_V1.2.tar.gz
cd Cassandra_V1.2/Src
make -f Makefile.gfortran FC=gfortran-8
mkdir ../bin
cp cassandra_gfortran.exe ../bin/.
cp ../Scripts/Frag_Library_Setup/library_setup.py ../bin/.
cd ../../../../../
displayName: Build Cassandra macOS
condition: eq( variables['Agent.OS'], 'Darwin' )
- bash: |
echo Working directory:
pwd
echo ls:
ls
echo PATH:
echo "$PATH"
echo CASSANDRA:
which cassandra_gfortran.exe
echo PYTHON2
which python2
echo LIBRARY_SETUP:
which library_setup.py
displayName: Check cassandra install
- bash: |
conda config --set always_yes yes --set changeps1 no
conda config --add channels omnia
Expand All @@ -241,6 +172,8 @@ jobs:
source activate test-environment
echo "PYTHON VERSION:"
python --version
echo "CASSANDRA EXEC:"
which cassandra.exe
python -m pip install --user .
displayName: clone,install foyer,mbuild; install mosdef_cassandra
Expand Down
2 changes: 1 addition & 1 deletion mosdef_cassandra/examples/gemc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run_gemc():

thermo_props = [
"energy_total",
"energy_lj",
"energy_intervdw",
"pressure",
"volume",
"nmols",
Expand Down
14 changes: 7 additions & 7 deletions mosdef_cassandra/runners/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run(system, moves, run_type, run_length, temperature, **kwargs):

# Check that the user has the Cassandra binary on their PATH
# Also need library_setup.py on the PATH and python2
py2, fraglib_setup, cassandra = detect_cassandra_binaries()
py, fraglib_setup, cassandra = detect_cassandra_binaries()

# Sanity checks
# TODO: Write more of these
Expand Down Expand Up @@ -49,7 +49,7 @@ def run(system, moves, run_type, run_length, temperature, **kwargs):
# Run fragment generation (again, will be removed...)
print("Generating fragment libraries...")
successful_fraglib = _run_fraglib_setup(
py2,
py,
fraglib_setup,
cassandra,
inp_file,
Expand All @@ -71,7 +71,7 @@ def restart(system, moves, run_type, run_length, temperature, **kwargs):

# Check that the user has the Cassandra binary on their PATH
# Also need library_setup.py on the PATH and python2
py2, fraglib_setup, cassandra = detect_cassandra_binaries()
py, fraglib_setup, cassandra = detect_cassandra_binaries()

kwargs["restart"] = True

Expand All @@ -98,21 +98,21 @@ def restart(system, moves, run_type, run_length, temperature, **kwargs):


def _run_fraglib_setup(
py2, fraglib_setup, cassandra, inp_file, log_file, nspecies
py, fraglib_setup, cassandra, inp_file, log_file, nspecies
):
"""Builds the fragment libraries required to run Cassandra.
Requires python2.
Requires python.
"""

species_pdb_files = ""
for isp in range(nspecies):
species_pdb_files += "species{}.pdb ".format(isp + 1)

fraglib_cmd = (
"{py2} {fraglib_setup} {cassandra} {inp_file} "
"{py} {fraglib_setup} {cassandra} {inp_file} "
"{species_pdb_files}".format(
py2=py2,
py=py,
fraglib_setup=fraglib_setup,
cassandra=cassandra,
inp_file=inp_file,
Expand Down
Binary file removed mosdef_cassandra/tests/files/Cassandra_V1.2.tar.gz
Binary file not shown.
12 changes: 6 additions & 6 deletions mosdef_cassandra/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_run_nvt(self):

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

Expand All @@ -51,7 +51,7 @@ def test_run_npt(self):

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

Expand All @@ -74,7 +74,7 @@ def test_run_gcmc(self):

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

Expand All @@ -97,7 +97,7 @@ def test_run_gemc(self):

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

Expand All @@ -120,7 +120,7 @@ def test_run_nvt_mixture(self):

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

Expand All @@ -143,6 +143,6 @@ def test_run_gcmc_adsorption(self):

completed = False
for line in log_data:
if "Energy of final" in line:
if "Cassandra simulation complete" in line:
completed = True
assert completed
4 changes: 2 additions & 2 deletions mosdef_cassandra/tests/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ def test_property_info(self, onecomp_system, twobox_system):
)

assert (
"# Property_Info 1\nenergy_total\nenergy_lj\nenergy_elec\nenergy_intra\nenthalpy\npressure\nvolume\nnmols\nmass_density\n"
"# Property_Info 1\nenergy_total\nenergy_intra\nenergy_inter\nenthalpy\npressure\nvolume\nnmols\nmass_density\n"
in inp_data
)

Expand All @@ -1413,7 +1413,7 @@ def test_property_info(self, onecomp_system, twobox_system):
)

assert (
"# Property_Info 1\nenergy_total\nenergy_lj\nenergy_elec\nenergy_intra\nenthalpy\npressure\nvolume\nnmols\nmass_density\n\n# Property_Info 2\nenergy_total\nenergy_lj\nenergy_elec\nenergy_intra\nenthalpy\npressure\nvolume\nnmols\nmass_density\n"
"# Property_Info 1\nenergy_total\nenergy_intra\nenergy_inter\nenthalpy\npressure\nvolume\nnmols\nmass_density\n\n# Property_Info 2\nenergy_total\nenergy_intra\nenergy_inter\nenthalpy\npressure\nvolume\nnmols\nmass_density\n"
in inp_data
)

Expand Down
16 changes: 8 additions & 8 deletions mosdef_cassandra/utils/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def detect_cassandra_binaries():
"cassandra_pgfortran.exe",
]

py2_exec_names = ["python2", "python2.7"]
py_exec_names = ["python"]

for name in cassandra_exec_names:
cassandra = shutil.which(name)
Expand All @@ -27,18 +27,18 @@ def detect_cassandra_binaries():
"'library_setup.py' must be in your PATH"
)

for name in py2_exec_names:
py2 = shutil.which(name)
if py2 is not None:
for name in py_exec_names:
py = shutil.which(name)
if py is not None:
break
if py2 is None:
if py is None:
raise ValueError(
"Error detecting python2. library_setup.py requires python2"
"Error detecting python. library_setup.py requires python."
)

print("Using the following executables for Cassandra:")
print("Python: {}".format(py2))
print("Python: {}".format(py))
print("library_setup: {}".format(fraglib_setup))
print("Cassandra: {}".format(cassandra))

return py2, fraglib_setup, cassandra
return py, fraglib_setup, cassandra
20 changes: 16 additions & 4 deletions mosdef_cassandra/writers/inp_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,8 @@ def generate_input(system, moves, run_type, run_length, temperature, **kwargs):
else:
properties = [
"energy_total",
"energy_lj",
"energy_elec",
"energy_intra",
"energy_inter",
"enthalpy",
"pressure",
"volume",
Expand Down Expand Up @@ -1588,11 +1587,24 @@ def get_property_info(properties, nbr_boxes):

valid_properties = [
"energy_total",
"energy_lj",
"energy_elec",
"energy_intra",
"energy_bond",
"energy_angle",
"energy_dihedral",
"energy_improper",
"energy_intravdw",
"energy_intraq",
"energy_inter",
"energy_intervdw",
"energy_lrc",
"energy_interq",
"energy_recip",
"energy_self",
"enthalpy",
"pressure",
"pressure_xx",
"pressure_yy",
"pressyre_zz",
"volume",
"nmols",
"density",
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ black
sphinx
sphinx_rtd_theme
pytest
cassandra >= 1.2.2
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ foyer >= 0.7.3
mbuild >= 0.10.5
openbabel
pytest
cassandra >= 1.2.2
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ numpy
parmed
foyer >= 0.7.3
mbuild >= 0.10.5
cassandra >= 1.2.2

0 comments on commit c0b23dc

Please sign in to comment.