Skip to content

Commit 4835053

Browse files
authored
Merge pull request #27 from michellab/cleanup
Packaging, optional dependencies and clean-up
2 parents 1e81ffb + 3b4f97b commit 4835053

51 files changed

Lines changed: 615 additions & 279 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/main.yaml‎

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
types: [published]
1212

1313
jobs:
14-
pre-commit:
14+
lint:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest]
@@ -23,15 +23,37 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
26+
uses: actions/setup-python@v5
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929

3030
- name: Pre-commit hooks
3131
uses: pre-commit/action@v3.0.1
3232

33-
build:
34-
needs: pre-commit
33+
core:
34+
# A core install (OpenMM, NumPy, networkx from PyPI): fes_ml must import and the unit tests
35+
# must pass without Sire, OpenFF, EMLE or the ML packages.
36+
needs: lint
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.12"
46+
47+
- name: Install fes-ml (core only)
48+
run: |
49+
python3 -m pip install --upgrade pip
50+
python3 -m pip install ".[tests]"
51+
52+
- name: Unit tests
53+
run: python3 -m pytest tests/unit -m "not slow"
54+
55+
tests:
56+
needs: lint
3557

3658
strategy:
3759
matrix:
@@ -71,12 +93,13 @@ jobs:
7193
7294
- name: Pytest coverage comment
7395
id: coverage-comment
74-
uses: MishaKav/pytest-coverage-comment@main
96+
uses: MishaKav/pytest-coverage-comment@v1.13.1
7597
with:
7698
pytest-coverage-path: ./pytest-coverage.txt
7799
junitxml-path: ./pytest.xml
78100

79101
- name: Create the Badge
102+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
80103
uses: schneegans/dynamic-badges-action@v1.7.0
81104
with:
82105
auth: ${{ secrets.GIST_SECRET }}
@@ -87,40 +110,28 @@ jobs:
87110
color: ${{ steps.coverage-comment.outputs.color }}
88111
namedLogo: python
89112

90-
# release:
91-
# needs: build
92-
# if: startsWith(github.ref, 'refs/tags')
93-
94-
# strategy:
95-
# matrix:
96-
# os: [ubuntu-latest]
97-
# python-version: ["3.12"]
98-
99-
# runs-on: ${{ matrix.os }}
100-
# steps:
101-
# - name: Checkout repository
102-
# uses: actions/checkout@v4
103-
104-
# - name: Set up Python ${{ matrix.python-version }}
105-
# uses: actions/setup-python@v4
106-
# with:
107-
# python-version: ${{ matrix.python-version }}
108-
109-
# - name: Install release dependencies
110-
# run: |
111-
# python3 -m pip install --upgrade pip
112-
# python3 -m pip install build --user
113-
114-
# - name: Generate distribution archives
115-
# run: python3 -m build --sdist --wheel --outdir dist/
116-
117-
# - name: Publish distrbution to TestPyPI
118-
# uses: pypa/gh-action-pypi-publish@release/v1
119-
# with:
120-
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
121-
# repository_url: https://test.pypi.org/legacy/
122-
123-
# - name: Publish distribution to PyPI
124-
# uses: pypa/gh-action-pypi-publish@release/v1
125-
# with:
126-
# password: ${{ secrets.PYPI_API_TOKEN }}
113+
release:
114+
# Publishes to PyPI with trusted publishing (no API token). Needs a trusted publisher
115+
# for this repository and the "pypi" environment configured on PyPI and GitHub.
116+
needs: tests
117+
if: github.event_name == 'release'
118+
runs-on: ubuntu-latest
119+
environment: pypi
120+
permissions:
121+
id-token: write
122+
steps:
123+
- name: Checkout repository
124+
uses: actions/checkout@v4
125+
126+
- name: Set up Python
127+
uses: actions/setup-python@v5
128+
with:
129+
python-version: "3.12"
130+
131+
- name: Build distributions
132+
run: |
133+
python3 -m pip install --upgrade pip build
134+
python3 -m build --sdist --wheel --outdir dist/
135+
136+
- name: Publish to PyPI
137+
uses: pypa/gh-action-pypi-publish@release/v1

‎.pre-commit-config.yaml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.12.8
3+
rev: v0.12.8
44
hooks:
55
- id: ruff
6-
args: ["--fix"]
6+
args: ["--fix"]
7+
- id: ruff-format
78

89
- repo: https://github.com/pre-commit/mirrors-mypy
9-
rev: v1.17.1
10+
rev: v2.4.1
1011
hooks:
1112
- id: mypy
12-
verbose: true
13-
entry: bash -c 'mypy "$@" || true' --
13+
# Checks src/fes_ml with the settings in pyproject.toml (lenient to start; see [tool.mypy])
14+
pass_filenames: false
15+
args: []
16+
additional_dependencies: ["numpy"]

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ All notable changes to fes-ml are listed here.
66

77
### Changed
88

9+
- **Importing fes-ml no longer configures logging** or prints the banner. Call
10+
`fes_ml.config_logger()` in scripts to print progress messages; it no longer hides other
11+
packages' messages unless `FES_ML_FILTER_LOGGERS=1`.
12+
- Invalid arguments raise `TypeError`, `ValueError` or `RuntimeError` instead of `AssertionError`
13+
(asserts are removed under `python -O`).
14+
- The λ schedule is checked before any state is built: empty schedules, rows of different lengths,
15+
non-numeric or non-finite values and windows with only `None` raise `ValueError`; values outside
16+
[0, 1] warn.
17+
- **Sire, OpenFF, EMLE and the ML packages are optional.** `import fes_ml` needs only OpenMM, NumPy
18+
and networkx; each strategy or modification imports its packages when used and says what to
19+
install if they are missing. A missing package now raises when the feature is used, not on import.
20+
- `pyproject.toml` declares the core dependencies and extras (`sire`, `openff`, `ml`, `emle`, `viz`,
21+
`analysis`, `tests`, `dev`). `environment.yaml` drops unused packages and pins `emle-engine`.
922
- **Each alchemical state writes its files to its own directory** (`tmp_fes_ml_sire_*` or
1023
`tmp_fes_ml_openff_*` in the current directory), or to `work_dir=` if given. Before, all states
1124
shared `tmp_fes_ml_sire` / `tmp_fes_ml_openmm`, so parallel windows overwrote or deleted each

‎README.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,21 @@ The customizable options can be found [here](https://github.com/openforcefield/o
225225

226226
## Logging Settings
227227

228-
By default, fes-ml logs messages at the `INFO` level, showing informative messages about overall progress without detailed debugging information. You can control the logging verbosity by setting the `FES_ML_LOG_LEVEL` environment variable:
228+
Importing fes-ml does not configure logging, so it does not change your application's log output. To print fes-ml's progress messages in a script, call `config_logger()` once:
229229

230-
```bash
231-
export FES_ML_LOG_LEVEL="DEBUG"
230+
```python
231+
from fes_ml import config_logger
232+
233+
config_logger()
232234
```
233235

234-
To include log messages from packages other than fes-ml, set the `FES_ML_FILTER_LOGGERS` variable to 0:
236+
You can control the logging verbosity by setting the `FES_ML_LOG_LEVEL` environment variable (default `INFO`):
235237

236238
```bash
237-
export FES_ML_FILTER_LOGGERS=0
239+
export FES_ML_LOG_LEVEL="DEBUG"
238240
```
239241

240-
By default, this variable is set to 1, filtering out log messages from other packages.
242+
To show only fes-ml's messages and hide those of other packages, set `FES_ML_FILTER_LOGGERS=1`.
241243

242244
For debugging purposes, you can report the energy decomposition of each alchemical state before and after the alchemical modification by setting the `FES_ML_LOG_DEVEL` variable to 1:
243245

‎dev-tools/conda-envs/ci_env.yaml‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
1-
name: fes-ml-aev-ci
1+
# CI environment (CPU): everything the test suite needs.
2+
name: fes-ml-ci
23

34
channels:
45
- conda-forge
5-
- openbiosim/label/emle
6+
- openbiosim
67

78
dependencies:
8-
- python=3.12
9-
- ambertools
10-
- compilers
11-
- eigen
12-
- loguru
9+
- python=3.12
10+
- numpy
11+
- networkx
1312
- openmm>=8.1
14-
- openmm-ml
15-
- openmmforcefields
13+
- coloredlogs
14+
- sire
1615
- openff-toolkit
1716
- openff-interchange
18-
- nnpops
19-
- pybind11
20-
- pytorch
21-
- torchvision
22-
- torchaudio
23-
- sire
17+
- ambertools
18+
- openmm-torch
19+
- openmm-ml
20+
- pytorch=*=cpu*
2421
- torchani
25-
- pygit2
26-
- pyyaml
22+
- pytest
23+
- pytest-cov
2724
- pip
2825
- pip:
29-
- git+https://github.com/chemle/emle-engine.git
30-
- coloredlogs
31-
- mace-torch
26+
- git+https://github.com/chemle/emle-engine.git@85bb26207bff651fda4c765b16516a11ae1625db

‎environment.yaml‎

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
name: fes-ml-aev
1+
# Full fes-ml environment (GPU): every strategy and modification.
2+
# conda env create -f environment.yaml && conda activate fes-ml && pip install -e .
3+
# For a CPU-only or smaller install, see dev-tools/conda-envs/ and the extras in pyproject.toml.
4+
name: fes-ml
25

36
channels:
47
- conda-forge
5-
- openbiosim/label/emle
8+
- openbiosim
69

710
dependencies:
11+
- python=3.12
12+
- numpy
13+
- networkx
14+
# OpenMM 8.5 is built against NumPy 2, which mace-torch (pip) installs (#17)
15+
- openmm>=8.5
16+
- coloredlogs
17+
# Sire strategy, EMLE
18+
- sire
19+
# OpenFF strategy, CustomLJ, ChargeTransfer
20+
- openff-toolkit
21+
- openff-interchange
822
- ambertools
9-
- compilers
10-
- cudatoolkit=11.8
11-
- eigen
12-
- loguru
13-
- openmm>=8.1
23+
# packmol-memgen (ambertools) imports pkg_resources, which setuptools 82 removes
24+
- setuptools<82
25+
# ML modifications
1426
- openmm-torch
1527
- openmm-ml
16-
- openmmforcefields
17-
- openff-toolkit
18-
- openff-interchange
19-
- nnpops
20-
- pip
21-
- pybind11
2228
- pytorch=*=*cuda*
23-
- python
24-
- pyyaml
25-
- sire
2629
- torchani
27-
- pygit2
30+
- nnpops
31+
# Analysis (MBAR)
32+
- pymbar
33+
- pip
2834
- pip:
29-
- git+https://github.com/chemle/emle-engine.git
30-
- coloredlogs
35+
# Pinned: the default branch moves (2026-12-03)
36+
- git+https://github.com/chemle/emle-engine.git@85bb26207bff651fda4c765b16516a11ae1625db
3137
- mace-torch

‎examples/additional_scripts/analysis.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import pandas as pd
77
from MDAnalysis.analysis import rdf as RDF
88
from MDAnalysis.analysis.dihedrals import Dihedral
9-
from MDAnalysis.topology.guessers import (guess_angles, guess_bonds,
10-
guess_dihedrals)
9+
from MDAnalysis.topology.guessers import guess_angles, guess_bonds, guess_dihedrals
1110
from scipy.stats import norm
1211

1312

‎examples/openff_strategy/benzene_mm_sol_openff.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
import openff.units as offunit
1717
import openmm.unit as unit
1818

19+
from fes_ml import config_logger
1920
from fes_ml.fes import FES
2021

22+
config_logger() # print fes-ml's progress messages
23+
2124
# Set up the alchemical modifications
2225
n_ChargeScaling = 5
2326
n_LJSoftCore = 11

‎examples/openff_strategy/mts_benchmark/ml/run_fes.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import openmm.app as app
2424
import openmm.unit as unit
2525

26-
from fes_ml import FES, MTS
26+
from fes_ml import FES, MTS, config_logger
27+
28+
config_logger() # print fes-ml's progress messages
2729

2830
if len(sys.argv) != 3:
2931
raise ValueError("must pass script and window as positional arguments")

‎examples/openff_strategy/mts_benchmark/ml_mts/run_fes.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import openmm.app as app
77
import openmm.unit as unit
88

9-
from fes_ml import FES, MTS
9+
from fes_ml import FES, MTS, config_logger
10+
11+
config_logger() # print fes-ml's progress messages
1012

1113
if len(sys.argv) != 3:
1214
raise ValueError("must pass script and window as positional arguments")

0 commit comments

Comments
 (0)