diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index da71aeb0e..79ec341da 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -22,13 +22,14 @@ defaults:
jobs:
test:
if: (github.event_name == 'schedule' && github.repository == 'openforcefield/openff-toolkit') || (github.event_name != 'schedule')
- name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}, RDKit=${{ matrix.rdkit }}, OpenEye=${{ matrix.openeye }}
+ name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}, RDKit=${{ matrix.rdkit }}, OpenEye=${{ matrix.openeye }}, Pydantic v${{ matrix.pydantic-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11"]
+ pydantic-version: ["1", "2"]
rdkit: [true, false]
openeye: [true, false]
exclude:
@@ -79,6 +80,7 @@ jobs:
environment-file: devtools/conda-envs/${{ env.ENVFILE }}.yaml
create-args: >-
python=${{ matrix.python-version }}
+ pydantic=${{ matrix.pydantic-version }}
- name: Additional info about the build
run: |
@@ -106,6 +108,10 @@ jobs:
run: |
python -m pip install utilities/test_plugins
+ - name: Install QCPortal
+ if: ${{ matrix.pydantic-version == 1 }}
+ run: micromamba install qcelemental "qcportal ==0.15.8" -c conda-forge
+
- name: Remove undesired toolkits
run: |
if [ ! -z "${{ env.PACKAGES_TO_REMOVE }}" ]; then
@@ -162,12 +168,12 @@ jobs:
pytest -v --no-cov --doctest-glob="docs/*.rst" --doctest-glob="docs/*.md" docs/
- name: Run notebooks in docs
- if: ${{ matrix.rdkit == true && matrix.openeye == true }}
+ if: ${{ matrix.rdkit == true && matrix.openeye == true && matrix.pydantic-version == 1 }}
run: |
pytest -v --no-cov --durations=5 --nbval --ignore docs/_build/ docs/
- name: Run examples in docstrings
- if: ${{ matrix.rdkit == true && matrix.openeye == true }}
+ if: ${{ matrix.rdkit == true && matrix.openeye == true && matrix.pydantic-version == 1 }}
run: |
pytest openff \
-v -x -n logical --no-cov --doctest-modules \
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e2ce037a8..554736012 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,6 +2,11 @@ ci:
autoupdate_schedule: "quarterly"
files: ^openff|(^examples/((?!deprecated).)*$)|^docs
repos:
+- repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.4.0
+ hooks:
+ - id: end-of-file-fixer
+ exclude: '\.(json|pdb)$'
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
diff --git a/devtools/conda-envs/beta_rc_env.yaml b/devtools/conda-envs/beta_rc_env.yaml
index 4336a1fb0..75a5e7b3a 100644
--- a/devtools/conda-envs/beta_rc_env.yaml
+++ b/devtools/conda-envs/beta_rc_env.yaml
@@ -43,8 +43,6 @@ dependencies:
- mdtraj
- nbval
- mypy
- - typing_extensions
- - pydantic =1
- pip:
- types-setuptools
- types-toml
diff --git a/devtools/conda-envs/openeye-examples.yaml b/devtools/conda-envs/openeye-examples.yaml
index 6553f00b3..9d47c6a5e 100644
--- a/devtools/conda-envs/openeye-examples.yaml
+++ b/devtools/conda-envs/openeye-examples.yaml
@@ -5,7 +5,6 @@ channels:
dependencies:
# Base depends
- python
- - pydantic =1
- packaging
- numpy
- networkx
diff --git a/devtools/conda-envs/openeye.yaml b/devtools/conda-envs/openeye.yaml
index 36ff4cd9e..f1c5fc503 100644
--- a/devtools/conda-envs/openeye.yaml
+++ b/devtools/conda-envs/openeye.yaml
@@ -5,7 +5,6 @@ channels:
dependencies:
# Base depends
- python
- - pydantic =1
- packaging
- numpy
- networkx
@@ -39,4 +38,4 @@ dependencies:
- qcengine
- mdtraj
- nglview
- - parmed =3
+ - parmed =3
\ No newline at end of file
diff --git a/devtools/conda-envs/rdkit-examples.yaml b/devtools/conda-envs/rdkit-examples.yaml
index 52ce52d29..5f3461abd 100644
--- a/devtools/conda-envs/rdkit-examples.yaml
+++ b/devtools/conda-envs/rdkit-examples.yaml
@@ -4,7 +4,6 @@ channels:
dependencies:
# Base depends
- python
- - pydantic =1
- packaging
- numpy
- networkx
diff --git a/devtools/conda-envs/rdkit.yaml b/devtools/conda-envs/rdkit.yaml
index c4df2f329..d758368ff 100644
--- a/devtools/conda-envs/rdkit.yaml
+++ b/devtools/conda-envs/rdkit.yaml
@@ -4,7 +4,6 @@ channels:
dependencies:
# Base depends
- python
- - pydantic =1
- packaging
- numpy
- networkx
diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml
index 3f83bb2a0..949575d73 100644
--- a/devtools/conda-envs/test_env.yaml
+++ b/devtools/conda-envs/test_env.yaml
@@ -45,9 +45,8 @@ dependencies:
- nomkl
- mypy
- typing_extensions
- - pydantic =1
- pip:
- types-setuptools
- types-toml
- types-PyYAML
- - mongo-types
+ - mongo-types
\ No newline at end of file
diff --git a/docs/_static/images/favicon.svg b/docs/_static/images/favicon.svg
index 526a13306..4d6ef44d2 100644
--- a/docs/_static/images/favicon.svg
+++ b/docs/_static/images/favicon.svg
@@ -30,4 +30,4 @@
-
\ No newline at end of file
+
diff --git a/docs/_templates/autosummary/base.rst b/docs/_templates/autosummary/base.rst
index 57412ab28..b879b8437 100644
--- a/docs/_templates/autosummary/base.rst
+++ b/docs/_templates/autosummary/base.rst
@@ -17,4 +17,4 @@ but free functions do not.
.. currentmodule:: {{ module }}
-.. auto{{ objtype }}:: {{ objname }}
\ No newline at end of file
+.. auto{{ objtype }}:: {{ objname }}
diff --git a/docs/topology.md b/docs/topology.md
index 9de12f753..2dad15847 100644
--- a/docs/topology.md
+++ b/docs/topology.md
@@ -38,4 +38,3 @@ including offering serialization to a variety of standard formats (including [XM
HierarchyScheme
HierarchyElement
```
-
diff --git a/docs/users/figures/vsite_examples.svg b/docs/users/figures/vsite_examples.svg
index 010ba7791..804a7195d 100644
--- a/docs/users/figures/vsite_examples.svg
+++ b/docs/users/figures/vsite_examples.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/docs/users/figures/vsite_matches.svg b/docs/users/figures/vsite_matches.svg
index 715562045..b75889101 100644
--- a/docs/users/figures/vsite_matches.svg
+++ b/docs/users/figures/vsite_matches.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/docs/users/figures/vsite_matches_name.svg b/docs/users/figures/vsite_matches_name.svg
index fba0b7c80..862491ed6 100644
--- a/docs/users/figures/vsite_matches_name.svg
+++ b/docs/users/figures/vsite_matches_name.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/docs/users/figures/vsite_smirks_to_particle.svg b/docs/users/figures/vsite_smirks_to_particle.svg
index e5111893d..688cc0c8c 100644
--- a/docs/users/figures/vsite_smirks_to_particle.svg
+++ b/docs/users/figures/vsite_smirks_to_particle.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/docs/users/smirnoff.md b/docs/users/smirnoff.md
index ffb9868e5..860f40c20 100644
--- a/docs/users/smirnoff.md
+++ b/docs/users/smirnoff.md
@@ -89,4 +89,4 @@ general or as specific as needed.
:::{hint}
This page is not the SMIRNOFF spec; it has been moved to the
[standards repository].
-:::
\ No newline at end of file
+:::
diff --git a/docs/utils.rst b/docs/utils.rst
index 780e16529..a450719b6 100644
--- a/docs/utils.rst
+++ b/docs/utils.rst
@@ -162,4 +162,3 @@ Exceptions raised by the Toolkit.
:toctree: api/generated/
exceptions
-
diff --git a/examples/conformer_energies/.gitignore b/examples/conformer_energies/.gitignore
index de9960de1..4d155b742 100644
--- a/examples/conformer_energies/.gitignore
+++ b/examples/conformer_energies/.gitignore
@@ -1,2 +1,2 @@
ruxolitinib.csv
-ruxolitinib_conf*_minimized.sdf
\ No newline at end of file
+ruxolitinib_conf*_minimized.sdf
diff --git a/examples/external/swap_amber_parameters/README.md b/examples/external/swap_amber_parameters/README.md
index 6e142e031..6b846876d 100644
--- a/examples/external/swap_amber_parameters/README.md
+++ b/examples/external/swap_amber_parameters/README.md
@@ -5,4 +5,3 @@ This example illustrates how the [ParmEd](http://parmed.github.io/ParmEd/html/in
### BRD4:inhibitor complex
* [`swap_existing_ligand_parameters.ipynb`](swap_existing_ligand_parameters.ipynb) contains an example illustrating taking a fully parameterized BRD4 protein-ligand system, with an AMBER protein force field and GAFF ligand parameters, and replacing the ligand parameters with OpenFF parameters from SMIRNOFF format. The BRD4:inhibitor complex is taken from the [free energy benchmark systems living review](https://www.annualreviews.org/doi/abs/10.1146/annurev-biophys-070816-033654) [GitHub repo](https://github.com/MobleyLab/benchmarksets/tree/master/input_files/BRD4).
-
diff --git a/examples/external/using_smirnoff_with_amber_protein_forcefield/.gitignore b/examples/external/using_smirnoff_with_amber_protein_forcefield/.gitignore
index a60daed75..eaf8f224b 100644
--- a/examples/external/using_smirnoff_with_amber_protein_forcefield/.gitignore
+++ b/examples/external/using_smirnoff_with_amber_protein_forcefield/.gitignore
@@ -1,3 +1,3 @@
complex.*
receptor.*
-ligand.*
\ No newline at end of file
+ligand.*
diff --git a/examples/external/using_smirnoff_with_amber_protein_forcefield/README.md b/examples/external/using_smirnoff_with_amber_protein_forcefield/README.md
index 54d85e96a..cd15f739f 100644
--- a/examples/external/using_smirnoff_with_amber_protein_forcefield/README.md
+++ b/examples/external/using_smirnoff_with_amber_protein_forcefield/README.md
@@ -3,4 +3,3 @@
### BRD4:inhibitor complex
[`BRD4_inhibitor_benchmark.ipynb`](BRD4_inhibitor_benchmark.ipynb) contains an example illustrating applying Sage and ff14SB parameters to a BRD4:inhibitor complex taken from the [free energy benchmark systems living review](https://www.annualreviews.org/doi/abs/10.1146/annurev-biophys-070816-033654) [GitHub repo](https://github.com/MobleyLab/benchmarksets/tree/master/input_files/BRD4).
-
diff --git a/examples/toolkit_showcase/sim.mdp b/examples/toolkit_showcase/sim.mdp
index 230f5c127..52c7b6508 100644
--- a/examples/toolkit_showcase/sim.mdp
+++ b/examples/toolkit_showcase/sim.mdp
@@ -60,4 +60,3 @@ constraint-algorithm = LINCS ; Use fast and stable LINCS constraint algorithm
continuation = no ; Apply constraints to the initial configuration (important since energy minimisation was unconstrained)
lincs-order = 4 ; Increase if you get LINCS errors
lincs-iter = 1 ; Increase if you get LINCS errors
-
diff --git a/openff/toolkit/_tests/test_molecule.py b/openff/toolkit/_tests/test_molecule.py
index 2b2077e69..a54dd591f 100644
--- a/openff/toolkit/_tests/test_molecule.py
+++ b/openff/toolkit/_tests/test_molecule.py
@@ -3417,8 +3417,8 @@ def test_qcschema_molecule_record_round_trip_from_to_from(self):
Molecule.from_qcschema(mol_dict)
+@requires_pkg("IPython")
class TestMoleculeVisualization:
- @requires_pkg("IPython")
@requires_rdkit
def test_visualize_rdkit(self):
"""
@@ -3476,8 +3476,15 @@ def test_visualize_openeye(self):
)
def test_ipython_repr_no_nglview(self):
"""Test that the default Molecule repr does not break when nglview is not installed"""
+ from openff.toolkit.utils.toolkits import OPENEYE_AVAILABLE, RDKIT_AVAILABLE
+
molecule = Molecule().from_smiles("CCO")
- molecule._ipython_display_()
+
+ if RDKIT_AVAILABLE:
+ # the default is `backend="rdkit"`
+ molecule.visualize()
+ elif OPENEYE_AVAILABLE:
+ molecule.visualize(backend="openeye")
def test_get_coordinates(self):
from openff.toolkit.utils._viz import MoleculeNGLViewTrajectory
diff --git a/openff/toolkit/_tests/utils.py b/openff/toolkit/_tests/utils.py
index 865d76db1..210026c68 100644
--- a/openff/toolkit/_tests/utils.py
+++ b/openff/toolkit/_tests/utils.py
@@ -6,7 +6,6 @@
import collections
import copy
import functools
-import importlib
import itertools
import os
import pprint
@@ -17,6 +16,7 @@
import openmm
import pytest
from openff.units.openmm import to_openmm
+from openff.utilities import has_package, skip_if_missing
from openmm import unit as openmm_unit
from openff.toolkit import unit
@@ -45,59 +45,9 @@
)
-def has_pkg(pkg_name):
- """
- Helper function to generically check if a package is installed. Intended
- to be used to check for optional dependencies.
-
- Parameters
- ----------
- pkg_name : str
- The name of the package to check the availability of
-
- Returns
- -------
- pkg_available : bool
- Boolean indicator if the package is available or not
+has_pkg = has_package
- Examples
- --------
- >>> has_numpy = has_pkg('numpy')
- >>> has_numpy
- True
- >>> has_foo = has_pkg('other_non_installed_pkg')
- >>> has_foo
- False
- """
- try:
- importlib.import_module(pkg_name)
- except ModuleNotFoundError:
- return False
- return True
-
-
-def requires_pkg(pkg_name, reason=None):
- """
- Helper function to generate a pytest.mark.skipif decorator
- for any package. This allows tests to be skipped if some
- optional dependency is not found.
-
- Parameters
- ----------
- pkg_name : str
- The name of the package that is required for a test(s)
- reason : str, optional
- Explanation of why the skipped it to be tested
-
- Returns
- -------
- requires_pkg : _pytest.mark.structures.MarkDecorator
- A pytest decorator that will skip tests if the package is not available
- """
- if not reason:
- reason = f"Package {pkg_name} is required, but was not found."
- requires_pkg = pytest.mark.skipif(not has_pkg(pkg_name), reason=reason)
- return requires_pkg
+requires_pkg = skip_if_missing
@contextmanager
diff --git a/openff/toolkit/data/molecules/README.md b/openff/toolkit/data/molecules/README.md
index b876cbf55..ae9a7efbc 100644
--- a/openff/toolkit/data/molecules/README.md
+++ b/openff/toolkit/data/molecules/README.md
@@ -18,4 +18,3 @@ contains all the molecules in `AlkEthOH_tripos.tar.gz/AlkEthOH_test_filt1`.
**For all molecule sets**
- `*` = `ff` for parm@frosst atom types
- `*` = `tripos` for tripos atom types
-
diff --git a/openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf b/openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf
index 772665041..c3280f5be 100644
--- a/openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf
+++ b/openff/toolkit/data/molecules/z_3_hydroxy_propenal.sdf
@@ -20,4 +20,4 @@
3 8 1 0 0 0 0
4 9 1 0 0 0 0
M END
-$$$$
\ No newline at end of file
+$$$$
diff --git a/openff/toolkit/data/reference_energies/README.md b/openff/toolkit/data/reference_energies/README.md
index f6ca27845..7ce406f9c 100644
--- a/openff/toolkit/data/reference_energies/README.md
+++ b/openff/toolkit/data/reference_energies/README.md
@@ -3,4 +3,4 @@
- `reference_after_802.json` - generated by `openff/toolkit/tests/test_energies.py` with conda environment reference_after_802.txt, corresponds to commit 02dba85c51dcff3ee3426d2a407811ac9bac1749 in PR #802, between 0.9.0 and 0.9.1
- `reference_after_1007.json` - generated by `openff/toolkit/tests/test_energies.py` with conda environment reference_after_1007.txt, corresponds to commit 6ac06efb7d0e91a960325cfc45874500af52274c in PR #948, between 0.9.2 and 0.9.3.
This change tracks the effect of partial charge normalization on the reference energies of the test set.
- Note that that PR #948 was superseded by #1007, since it #948 gained an irreconcilably large merge conflict with master during its development.
\ No newline at end of file
+ Note that that PR #948 was superseded by #1007, since it #948 gained an irreconcilably large merge conflict with master during its development.
diff --git a/openff/toolkit/data/reference_energies/reference_after_1007.json.txt b/openff/toolkit/data/reference_energies/reference_after_1007.json.txt
index abef81c91..f963047cb 100644
--- a/openff/toolkit/data/reference_energies/reference_after_1007.json.txt
+++ b/openff/toolkit/data/reference_energies/reference_after_1007.json.txt
@@ -347,4 +347,4 @@ dependencies:
- pytraj==2.0.5
- sander==16.0
- z3-solver==4.8.10.0
-prefix: /Users/jeffreywagner/miniconda3/envs/off-tk-dev
\ No newline at end of file
+prefix: /Users/jeffreywagner/miniconda3/envs/off-tk-dev
diff --git a/openff/toolkit/data/test_forcefields/README.md b/openff/toolkit/data/test_forcefields/README.md
index 062f1fa5c..998d72950 100644
--- a/openff/toolkit/data/test_forcefields/README.md
+++ b/openff/toolkit/data/test_forcefields/README.md
@@ -20,4 +20,3 @@
- `GBSA_HCT-1.0.offxml`: An experimental force field used in validation tests against OpenMM's implementation of the [Hawkins-Cramer-Truhlar](http://docs.openmm.org/latest/userguide/zbibliography.html#hawkins1995) GBSA model (corresponding to igb=1 in AMBER)
- `GBSA_OBC1-1.0.offxml`: An experimental force field used in validation tests against OpenMM's implementation of the [Onufriev-Bashford-Case](http://docs.openmm.org/latest/userguide/zbibliography.html#onufriev2004) using the GB(OBC)I model (corresponding to igb=2 in AMBER)
- `GBSA_OBC2-1.0.offxml`: An experimental force field used in validation tests against OpenMM's implementation of the [Onufriev-Bashford-Case](http://docs.openmm.org/latest/userguide/zbibliography.html#onufriev2004) using the GB(OBC)II model (corresponding to igb=5 in AMBER)
-
diff --git a/openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs b/openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs
index 26814666c..19ed2b7aa 100644
--- a/openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs
+++ b/openff/toolkit/data/test_forcefields/frcmod.Frosst_AlkEthOH_withIDs
@@ -82,4 +82,3 @@ MOD4 RE
CT 1.9080 0.1094 PrmIdVdw008 Spellmeyer
END
-
diff --git a/openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml b/openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml
index 1d21d8b59..9640c1158 100644
--- a/openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml
+++ b/openff/toolkit/data/test_forcefields/old/test_ff_0_0_2_spec_0_3.offxml
@@ -326,4 +326,4 @@
-
\ No newline at end of file
+
diff --git a/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml b/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml
index ed924698d..b5ec0d631 100644
--- a/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml
+++ b/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_fixed_spec_0_3.offxml
@@ -334,4 +334,4 @@
-
\ No newline at end of file
+
diff --git a/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml b/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml
index 02ddbb90e..0bb6438d7 100644
--- a/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml
+++ b/openff/toolkit/data/test_forcefields/old/test_ff_0_0_4_spec_0_3.offxml
@@ -334,4 +334,4 @@
-
\ No newline at end of file
+
diff --git a/openff/toolkit/utils/utils.py b/openff/toolkit/utils/utils.py
index 2438f39a5..a880a2339 100644
--- a/openff/toolkit/utils/utils.py
+++ b/openff/toolkit/utils/utils.py
@@ -101,6 +101,7 @@ def get_data_file_path(relative_path: str) -> str:
_DATA_ROOT = files("openff.toolkit") / "data"
+ # mypy unhappy because this might not return a path, might be fixed with 3.10+
file_path = _DATA_ROOT / relative_path
if not file_path.exists(): # type: ignore[attr-defined]