Skip to content

Commit

Permalink
Merge branch 'main' into KonnektorIntegration
Browse files Browse the repository at this point in the history
  • Loading branch information
atravitz authored Dec 9, 2024
2 parents 6d3e59a + 5e198a1 commit 96de81b
Show file tree
Hide file tree
Showing 26 changed files with 609 additions and 74 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE/release_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Make the PR:
* [ ] Verify that`docs/CHANGELOG.md` looks correct.
* [ ] Make the PR and verify that CI/CD passes.
* [ ] Merge the PR into `main`.
* [ ] Make a PR into the [example notebooks repository](https://github.com/OpenFreeEnergy/ExampleNotebooks) to update the version used in `showcase/openfe_showcase.ipynb` and `.binder/environment.yml`

After Merging the PR [follow this guide](https://github.com/OpenFreeEnergy/openfe/wiki/How-to-create-a-new-release)

41 changes: 41 additions & 0 deletions .github/workflows/change.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check for API breaks

on:
pull_request_target:
branches:
- main

jobs:
check:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Check for API breaks
continue-on-error: true
id: check
run: |
pip install griffe
griffe check "openfe" --verbose
- name: Post Comment on Failure
if: steps.check.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: '🚨 API breaking changes detected! 🚨'
});
21 changes: 17 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defaults:
jobs:
tests:
runs-on: ${{ matrix.os }}
name: "💻-${{matrix.os }} 🐍-${{ matrix.python-version }} 🗃️${{ matrix.pydantic-version }} oechem: ${{ matrix.openeye }}"
name: "💻-${{matrix.os }} 🐍-${{ matrix.python-version }} 🗃️${{ matrix.pydantic-version }} oechem-${{ matrix.openeye }} gufe-${{ matrix.gufe-version }}"
strategy:
fail-fast: false
matrix:
Expand All @@ -41,22 +41,34 @@ jobs:
- "3.11"
- "3.12"
openeye: ["no"]
gufe-version: ['a9b5982471eb3644ca8c4423c7001e6309a3f544']
include:
- os: "macos-12"
- os: "macos-latest"
python-version: "3.12"
pydantic-version: ">1"
gufe-version: 'a9b5982471eb3644ca8c4423c7001e6309a3f544'
- os: "ubuntu-latest"
python-version: "3.11"
pydantic-version: "<2"
gufe-version: 'a9b5982471eb3644ca8c4423c7001e6309a3f544'
- os: "ubuntu-latest"
python-version: "3.11"
pydantic-version: ">1"
openeye: "yes"
gufe-version: 'a9b5982471eb3644ca8c4423c7001e6309a3f544'
- os: "macos-latest"
python-version: "3.12"
pydantic-version: ">1"
omff-version: ">0.13"
openeye: ["no"]
gufe-version: 'a9b5982471eb3644ca8c4423c7001e6309a3f544'

# temporary test against gufe main while we're pinned to a9b5
- os: "ubuntu-latest"
python-version: "3.11"
pydantic-version: ">1"
openeye: "yes"
gufe-version: 'main'

env:
OE_LICENSE: ${{ github.workspace }}/oe_license.txt
Expand Down Expand Up @@ -96,8 +108,9 @@ jobs:
micromamba install -c openeye openeye-toolkits
python -c "import openeye; assert openeye.oechem.OEChemIsLicensed(), 'oechem license check failed!'"
- name: "Install GUFE from main@HEAD"
run: python -m pip install --no-deps git+https://github.com/OpenFreeEnergy/gufe@main
- name: "Install GUFE at {{ matrix.gufe-version }}"
if: ${{ matrix.gufe-version != 'main' }}
run: python -m pip install --no-deps git+https://github.com/OpenFreeEnergy/gufe@${{ matrix.gufe-version }}

- name: "Install"
run: python -m pip install --no-deps -e .
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/conda_cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'macos-12']
os: ['ubuntu-latest', 'macos-latest']
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
exclude:
- os: 'macos-latest'
python-version: '3.9'

steps:
- name: Setup Micromamba
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-14, macos-12, ubuntu-latest]
os: [macos-latest, ubuntu-latest]

steps:
- name: Checkout Code
Expand Down
23 changes: 23 additions & 0 deletions news/986_input_validation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* ``openfe quickrun`` now fails up-front when the user-supplied output file (``-o``) already exists or has a non-existent parent directory.

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
26 changes: 26 additions & 0 deletions news/compute_selection_fixes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**Added:**

* OpenMMEngineSettings now has a `gpu_device_index` attribute
allowing users to pass through a list of ints to select the
GPU devices to run their simulations on.

**Changed:**

* `openfe.protocols.openmm_rfe._rfe_utils.compute` has been moved
to `openfe.protocols.openmm_utils.omm_compute`.

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* OpenMM CPU vacuum calculations now enforce the use of a single CPU to avoid large performance losses.

**Security:**

* <news item>
23 changes: 23 additions & 0 deletions news/no_more_macos12.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* openfe is no longer tested against macos-12. macos support is, for now, limited to osx-arm64 (macos-14+).

**Fixed:**

* <news item>

**Security:**

* <news item>
2 changes: 1 addition & 1 deletion openfe/analysis/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def plot_lambda_transition_matrix(matrix: npt.NDArray) -> Axes:
Notes
-----
Borrowed from `alchemlyb <https://github.com/alchemistry/alchemlyb/blob/master/src/alchemlyb/visualisation/mbar_matrix.py>`_
which itself borrows from `alchemical-analysis <https://github.com/MobleyLab/alchemical-analysis>`_.
which itself borrows from `alchemical-analysis <https://github.com/MobleyLab/alchemical-analysis>`_.
"""
num_states = len(matrix)

Expand Down
28 changes: 21 additions & 7 deletions openfe/protocols/openmm_afe/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@
MultiStateSimulationSettings, OpenMMEngineSettings,
IntegratorSettings, LambdaSettings, MultiStateOutputSettings,
ThermoSettings, OpenFFPartialChargeSettings,
OpenMMSystemGeneratorFFSettings,
)
from openfe.protocols.openmm_rfe._rfe_utils import compute
from openfe.protocols.openmm_md.plain_md_methods import PlainMDProtocolUnit
from ..openmm_utils import (
settings_validation, system_creation,
multistate_analysis, charge_generation
multistate_analysis, charge_generation,
omm_compute,
)
from openfe.utils import without_oechem_backend

Expand Down Expand Up @@ -175,6 +176,7 @@ def _pre_equilibrate(
settings : dict[str, SettingsBaseModel]
A dictionary of settings objects. Expects the
following entries:
* `forcefield_settings`
* `engine_settings`
* `thermo_settings`
* `integrator_settings`
Expand All @@ -189,8 +191,12 @@ def _pre_equilibrate(
Equilibrated system positions
"""
# Prep the simulation object
platform = compute.get_openmm_platform(
settings['engine_settings'].compute_platform
# Restrict CPU count if running vacuum simulation
restrict_cpu = settings['forcefield_settings'].nonbonded_method.lower() == 'nocutoff'
platform = omm_compute.get_openmm_platform(
platform_name=settings['engine_settings'].compute_platform,
gpu_device_index=settings['engine_settings'].gpu_device_index,
restrict_cpu_count=restrict_cpu
)

integrator = openmm.LangevinMiddleIntegrator(
Expand Down Expand Up @@ -710,14 +716,16 @@ def _get_reporter(

def _get_ctx_caches(
self,
forcefield_settings: OpenMMSystemGeneratorFFSettings,
engine_settings: OpenMMEngineSettings
) -> tuple[openmmtools.cache.ContextCache, openmmtools.cache.ContextCache]:
"""
Set the context caches based on the chosen platform
Parameters
----------
engine_settings : OpenMMEngineSettings,
forcefield_settings: OpenMMSystemGeneratorFFSettings
engine_settings : OpenMMEngineSettings
Returns
-------
Expand All @@ -726,8 +734,13 @@ def _get_ctx_caches(
sampler_context_cache : openmmtools.cache.ContextCache
The sampler state context cache.
"""
platform = compute.get_openmm_platform(
engine_settings.compute_platform,
# Get the compute platform
# Set the number of CPUs to 1 if running a vacuum simulation
restrict_cpu = forcefield_settings.nonbonded_method.lower() == 'nocutoff'
platform = omm_compute.get_openmm_platform(
platform_name=engine_settings.compute_platform,
gpu_device_index=engine_settings.gpu_device_index,
restrict_cpu_count=restrict_cpu
)

energy_context_cache = openmmtools.cache.ContextCache(
Expand Down Expand Up @@ -1026,6 +1039,7 @@ def run(self, dry=False, verbose=True,
try:
# 12. Get context caches
energy_ctx_cache, sampler_ctx_cache = self._get_ctx_caches(
settings['forcefield_settings'],
settings['engine_settings']
)

Expand Down
10 changes: 6 additions & 4 deletions openfe/protocols/openmm_md/plain_md_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@
)
from openff.toolkit.topology import Molecule as OFFMolecule

from openfe.protocols.openmm_rfe._rfe_utils import compute
from openfe.protocols.openmm_utils import (
system_validation, settings_validation, system_creation,
charge_generation,
charge_generation, omm_compute
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -623,8 +622,11 @@ def run(self, *, dry=False, verbose=True,
)

# 10. Get platform
platform = compute.get_openmm_platform(
protocol_settings.engine_settings.compute_platform
restrict_cpu = forcefield_settings.nonbonded_method.lower() == 'nocutoff'
platform = omm_compute.get_openmm_platform(
platform_name=protocol_settings.engine_settings.compute_platform,
gpu_device_index=protocol_settings.engine_settings.gpu_device_index,
restrict_cpu_count=restrict_cpu
)

# 11. Set the integrator
Expand Down
1 change: 0 additions & 1 deletion openfe/protocols/openmm_rfe/_rfe_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from . import (
compute,
lambdaprotocol,
multistate,
relative,
Expand Down
12 changes: 8 additions & 4 deletions openfe/protocols/openmm_rfe/equil_rfe_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
)
from ..openmm_utils import (
system_validation, settings_validation, system_creation,
multistate_analysis, charge_generation
multistate_analysis, charge_generation, omm_compute,
)
from . import _rfe_utils
from ...utils import without_oechem_backend, log_system_probe
Expand Down Expand Up @@ -933,9 +933,13 @@ def run(self, *, dry=False, verbose=True,
bfactors=bfactors,
)

# 10. Get platform
platform = _rfe_utils.compute.get_openmm_platform(
protocol_settings.engine_settings.compute_platform
# 10. Get compute platform
# restrict to a single CPU if running vacuum
restrict_cpu = forcefield_settings.nonbonded_method.lower() == 'nocutoff'
platform = omm_compute.get_openmm_platform(
platform_name=protocol_settings.engine_settings.compute_platform,
gpu_device_index=protocol_settings.engine_settings.gpu_device_index,
restrict_cpu_count=restrict_cpu
)

# 11. Set the integrator
Expand Down
Loading

0 comments on commit 96de81b

Please sign in to comment.