Skip to content

Commit

Permalink
Merge pull request #202 from jaketanderson/github_actions
Browse files Browse the repository at this point in the history
Fixing GitHub Actions
  • Loading branch information
jaketanderson authored Sep 16, 2024
2 parents 688cc2c + f0b31dc commit c0e52bd
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 74 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env:
PYVER: ${{ matrix.python-version }}
PACKAGE: paprika

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/conda-envs/test_env.yaml
Expand All @@ -36,7 +36,7 @@ jobs:
auto-update-conda: true
auto-activate-base: false
miniforge-version: latest
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
use-mamba: true
mamba-version: "*"

Expand All @@ -56,7 +56,7 @@ jobs:
- name: Install package
shell: bash -l {0}
run: |
python -m pip install --no-deps .
python -m pip install .
- name: Run tests
shell: bash -l {0}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -69,6 +69,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:

- uses: actions/checkout@v3.0.2
- uses: actions/setup-python@v4.1.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'
- name: Install the package
run: |
python setup.py develop --no-deps
Expand Down
3 changes: 2 additions & 1 deletion devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ dependencies:
# Pip-only installs
- pip:
- codecov

- jax<=0.4.28; python_version == '3.9' # Since python<=3.9 doesn't support `str | None` syntax, pin jax to a version that uses `None` or `Optional[str]`
- jaxlib<=0.4.28; python_version == '3.9'
6 changes: 0 additions & 6 deletions paprika/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
__git_revision__ = versions["full-revisionid"]
del get_versions, versions


logger = logging.getLogger(__name__)

try:
Expand All @@ -32,14 +31,9 @@
logging.info("`paprika.setup()` requires OpenMM.")
setup = None


analyze = Analyze

if setup is None:
__all__ = ["setup", "analyze"]
else:
__all__ = ["analyze"]

from . import _version

__version__ = _version.get_versions()["version"]
32 changes: 16 additions & 16 deletions paprika/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,11 @@ def compute_free_energy(self, phases=["attach", "pull", "release"], seed=None):
phase
][method]["fraction_fe_matrix"][fraction][0, -1]

self.results[phase][method]["fraction_sem"][
fraction
] = self.results[phase][method]["fraction_sem_matrix"][fraction][
0, -1
]
self.results[phase][method]["fraction_sem"][fraction] = (
self.results[phase][method]["fraction_sem_matrix"][fraction][
0, -1
]
)

# Set these higher level (total) values, which will be slightly
# easier to access
Expand All @@ -1298,23 +1298,23 @@ def compute_free_energy(self, phases=["attach", "pull", "release"], seed=None):
# Store convergence values, which are helpful for running
# simulations
windows = len(self.results[phase][method]["sem_matrix"])
self.results[phase][method][
"largest_neighbor"
] = openff_unit.Quantity(
np.ones([windows], np.float64) * -1.0,
units=self.energy_unit,
self.results[phase][method]["largest_neighbor"] = (
openff_unit.Quantity(
np.ones([windows], np.float64) * -1.0,
units=self.energy_unit,
)
)
logger.info(f"{phase}: computing largest_neighbor for {method}...")

for i in range(windows):
if i == 0:
self.results[phase][method]["largest_neighbor"][
i
] = self.results[phase][method]["sem_matrix"][i][i + 1]
self.results[phase][method]["largest_neighbor"][i] = (
self.results[phase][method]["sem_matrix"][i][i + 1]
)
elif i == windows - 1:
self.results[phase][method]["largest_neighbor"][
i
] = self.results[phase][method]["sem_matrix"][i][i - 1]
self.results[phase][method]["largest_neighbor"][i] = (
self.results[phase][method]["sem_matrix"][i][i - 1]
)
else:
left = self.results[phase][method]["sem_matrix"][i][i - 1]
right = self.results[phase][method]["sem_matrix"][i][i + 1]
Expand Down
7 changes: 2 additions & 5 deletions paprika/restraints/openmm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A module aimed at applying restraints directly to OpenMM systems."""

import logging

import numpy as np
Expand Down Expand Up @@ -67,11 +68,7 @@ def apply_positional_restraints(
# But then we can't access atom indices. Using `atom.xx` works for
# coordinates, but is unitless.
if isinstance(k_pos, float):
k = (
k_pos
* openmm_unit.kilocalories_per_mole
/ openmm_unit.angstroms**2
)
k = k_pos * openmm_unit.kilocalories_per_mole / openmm_unit.angstroms**2
elif isinstance(k_pos, openmm_unit.Quantity):
k = k_pos
elif isinstance(k_pos, openff_unit.Quantity):
Expand Down
14 changes: 8 additions & 6 deletions paprika/restraints/restraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,9 @@ def initialize(self):
if phase[key] is not None:
phase[key] = check_unit(
phase[key],
base_unit=target_unit
if key == "target"
else force_constant_unit,
base_unit=(
target_unit if key == "target" else force_constant_unit
),
)

# Check pull units
Expand All @@ -637,9 +637,11 @@ def initialize(self):
if key in self._custom_restraint_values:
self._custom_restraint_values[key] = check_unit(
self._custom_restraint_values[key],
base_unit=force_constant_unit
if key in ["rk2", "rk3"]
else target_unit,
base_unit=(
force_constant_unit
if key in ["rk2", "rk3"]
else target_unit
),
)
else:
self._custom_restraint_values[key] = None
Expand Down
1 change: 1 addition & 0 deletions paprika/tests/test_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests evaluator modules.
"""

import logging
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions paprika/tests/test_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test that we can save and load restraints as JSON.
"""

import os
import shutil

Expand Down
37 changes: 10 additions & 27 deletions paprika/tests/test_restraints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests the restraints utilities.
"""

import logging
import os

Expand Down Expand Up @@ -134,9 +135,7 @@ def test_DAT_restraint():
rest2.initialize()

target_units = openff_unit.degrees
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
assert rest2.restraint_type == RestraintType.Angle
assert rest2.index1 == [13, 31, 49, 67, 85, 103]
assert rest2.index2 == [119]
Expand Down Expand Up @@ -205,9 +204,7 @@ def test_DAT_restraint():
rest3.initialize()

target_units = openff_unit.degrees
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
assert rest3.restraint_type == RestraintType.Torsion
assert rest3.index1 == [31]
assert rest3.index2 == [13]
Expand Down Expand Up @@ -278,9 +275,7 @@ def test_DAT_restraint():
rest4.initialize()

target_units = openff_unit.degrees
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.radians**2
assert rest4.index1 == [31]
assert rest4.index2 == [13]
assert rest4.index3 == [119]
Expand Down Expand Up @@ -348,9 +343,7 @@ def test_DAT_restraint():
rest5.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest5.index1 == [13, 31, 49, 67, 85, 103]
assert rest5.index2 == [109, 113, 115, 119]
assert rest5.index3 is None
Expand Down Expand Up @@ -417,9 +410,7 @@ def test_DAT_restraint():
rest6.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest6.index1 == [13, 31, 49, 67, 85, 103]
assert rest6.index2 == [109, 113, 115, 119]
assert rest6.index3 is None
Expand Down Expand Up @@ -484,9 +475,7 @@ def test_DAT_restraint():
rest7.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest7.index1 == [13, 14, 111]
assert rest7.index2 == [3]
assert rest7.index3 is None
Expand Down Expand Up @@ -547,9 +536,7 @@ def test_DAT_restraint():
rest8.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest8.index1 == [13]
assert rest8.index2 == [119]
assert rest8.index3 is None
Expand Down Expand Up @@ -587,9 +574,7 @@ def test_DAT_restraint():
rest9.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest9.index1 == [13]
assert rest9.index2 == [119]
assert rest9.index3 is None
Expand Down Expand Up @@ -627,9 +612,7 @@ def test_DAT_restraint():
rest10.initialize()

target_units = openff_unit.angstrom
force_constant_units = (
openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
)
force_constant_units = openff_unit.kcal / openff_unit.mole / openff_unit.angstrom**2
assert rest10.index1 == [13]
assert rest10.index2 == [119]
assert rest10.index3 is None
Expand Down
1 change: 1 addition & 0 deletions paprika/tests/test_tleap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests tleap tools.
"""

import logging
import os
import random as random
Expand Down

0 comments on commit c0e52bd

Please sign in to comment.