From 8c48a8bcf83b2792bacefec84363cc816b01a6dc Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 19:58:48 -0700 Subject: [PATCH 01/13] Update action versions in CI --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ee15780..0880b1e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,15 +18,15 @@ jobs: fail-fast: false matrix: os: [macOS-latest, ubuntu-latest] - python-version: ["3.8", "3.9", "3.10"] + 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 From 61f88e55bb3fb5dc494f79e188fbb198415345e3 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 20:07:58 -0700 Subject: [PATCH 02/13] Removed testing on macos because pytraj does not support arm --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0880b1e..b33065b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macOS-latest, ubuntu-latest] + os: [ubuntu-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] env: PYVER: ${{ matrix.python-version }} From 375e240dacd495d316b8aa6e2a248b96defd9522 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 20:14:48 -0700 Subject: [PATCH 03/13] Raised versions for the github action --- .github/workflows/codeql.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index de06a01..e45fd50 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -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. @@ -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 @@ -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}}" From 453f7f7f2423fe48ddb97d2694118ac68071c00c Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 20:22:19 -0700 Subject: [PATCH 04/13] Mambaforge --> Miniforge in ci.yaml Mambaforge is sunset, see https://conda-forge.org/news/2024/07/29/sunsetting-mambaforge/ --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b33065b..d290aae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,7 +36,7 @@ jobs: auto-update-conda: true auto-activate-base: false miniforge-version: latest - miniforge-variant: Mambaforge + miniforge-variant: Miniforge use-mamba: true mamba-version: "*" From bbf8396ffc5de7909983ecec37a64a2c3dfaf79c Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 20:31:24 -0700 Subject: [PATCH 05/13] "Miniforge" doesn't work, "Miniforge3" may be the fix --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d290aae..8085bff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,7 +36,7 @@ jobs: auto-update-conda: true auto-activate-base: false miniforge-version: latest - miniforge-variant: Miniforge + miniforge-variant: Miniforge3 use-mamba: true mamba-version: "*" From 2069f441a7df218df1eafcd84d60090f9a791b13 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 21:11:26 -0700 Subject: [PATCH 06/13] Modified setup.py install-requires s.t. python3.9 needs jax<=0.4.28 This was done to prevent `TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'` being thrown by Jax. It occurs because Python 3.9 and lower doesn't support the `str | None` syntax, but Jax>0.4.28 uses it. See https://stackoverflow.com/questions/76712720/typeerror-unsupported-operand-types-for-type-and-nonetype --- setup.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a11ba1a..5de7889 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,10 @@ # Extend/modify the list to include/exclude other items as need be package_data={"paprika": ["data/*.dat"]}, include_package_data=True, - install_requires=["numpy"], + install_requires=[ + "numpy", + "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]` + ], # Additional entries you may want simply uncomment the lines you want and fill in the data # author_email='me@place.org', # Author email # url='http://www.my_package.com', # Website From d4d1bc6f94544658fde9bb27cb1acbe0f07c76a9 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 21:19:20 -0700 Subject: [PATCH 07/13] Updated python & github actions versions for linting workflow --- .github/workflows/lint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4869ff0..77c8b08 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -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 From 28697151c49e28d575732276939557a1bcccb05a Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 21:33:50 -0700 Subject: [PATCH 08/13] Removed --no-deps flag from pip install inside CI workflow Why wouldn't we want the tests to honor dependencies the same way an average user would during installation? This way the change made in 2069f44 is actually respected and tests can work. --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8085bff..bd1d368 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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} From 9ad2d31328a732d61d4439e2213583ef3ab10af7 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 22:03:25 -0700 Subject: [PATCH 09/13] Moved pinned jax version to test_env.yaml from setup.py The location doesn't functionally matter as far as I can tell, but I like the idea of keeping as many dependencies as possible confined to one file. --- devtools/conda-envs/test_env.yaml | 5 +++-- setup.py | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index ecf44de..af879e1 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -4,7 +4,7 @@ channels: dependencies: # Base depends - - python + - python=3.8 - pip - numpy - scipy @@ -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' diff --git a/setup.py b/setup.py index 5de7889..a11ba1a 100644 --- a/setup.py +++ b/setup.py @@ -34,10 +34,7 @@ # Extend/modify the list to include/exclude other items as need be package_data={"paprika": ["data/*.dat"]}, include_package_data=True, - install_requires=[ - "numpy", - "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]` - ], + install_requires=["numpy"], # Additional entries you may want simply uncomment the lines you want and fill in the data # author_email='me@place.org', # Author email # url='http://www.my_package.com', # Website From 064b07c139637fa23e212ca253a93d4010d61bf3 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 22:05:42 -0700 Subject: [PATCH 10/13] Linted files with black --- paprika/analysis/analysis.py | 32 +++++++++++++-------------- paprika/restraints/openmm.py | 7 ++---- paprika/restraints/restraints.py | 14 ++++++------ paprika/tests/test_evaluator.py | 1 + paprika/tests/test_io.py | 1 + paprika/tests/test_restraints.py | 37 +++++++++----------------------- paprika/tests/test_tleap.py | 1 + 7 files changed, 39 insertions(+), 54 deletions(-) diff --git a/paprika/analysis/analysis.py b/paprika/analysis/analysis.py index 9a0f8c4..ad6a90d 100644 --- a/paprika/analysis/analysis.py +++ b/paprika/analysis/analysis.py @@ -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 @@ -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] diff --git a/paprika/restraints/openmm.py b/paprika/restraints/openmm.py index 8468490..a04593f 100644 --- a/paprika/restraints/openmm.py +++ b/paprika/restraints/openmm.py @@ -1,4 +1,5 @@ """A module aimed at applying restraints directly to OpenMM systems.""" + import logging import numpy as np @@ -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): diff --git a/paprika/restraints/restraints.py b/paprika/restraints/restraints.py index 5b24df0..a5a0fce 100644 --- a/paprika/restraints/restraints.py +++ b/paprika/restraints/restraints.py @@ -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 @@ -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 diff --git a/paprika/tests/test_evaluator.py b/paprika/tests/test_evaluator.py index 11fd4fa..829f16f 100644 --- a/paprika/tests/test_evaluator.py +++ b/paprika/tests/test_evaluator.py @@ -1,6 +1,7 @@ """ Tests evaluator modules. """ + import logging import os import shutil diff --git a/paprika/tests/test_io.py b/paprika/tests/test_io.py index c7343fa..6139947 100644 --- a/paprika/tests/test_io.py +++ b/paprika/tests/test_io.py @@ -1,6 +1,7 @@ """ Test that we can save and load restraints as JSON. """ + import os import shutil diff --git a/paprika/tests/test_restraints.py b/paprika/tests/test_restraints.py index 587a180..d8329ce 100644 --- a/paprika/tests/test_restraints.py +++ b/paprika/tests/test_restraints.py @@ -1,6 +1,7 @@ """ Tests the restraints utilities. """ + import logging import os @@ -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] @@ -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] @@ -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] @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/paprika/tests/test_tleap.py b/paprika/tests/test_tleap.py index d12dcaf..fc3459b 100644 --- a/paprika/tests/test_tleap.py +++ b/paprika/tests/test_tleap.py @@ -1,6 +1,7 @@ """ Tests tleap tools. """ + import logging import os import random as random From b892e44039f66cf54944e824ba639e443616406e Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 22:10:09 -0700 Subject: [PATCH 11/13] Cosmetic change to import order to stop flake8 from complaining during lint checks --- paprika/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/paprika/__init__.py b/paprika/__init__.py index b3d3f87..c125ec7 100644 --- a/paprika/__init__.py +++ b/paprika/__init__.py @@ -11,6 +11,7 @@ from paprika.evaluator import Analyze +from . import _version # Handle versioneer from ._version import get_versions @@ -40,6 +41,4 @@ else: __all__ = ["analyze"] -from . import _version - __version__ = _version.get_versions()["version"] From 1370d319f7dbbf753711289c9e8f905d5460a8b4 Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 22:17:50 -0700 Subject: [PATCH 12/13] Yet another attempt at satisfying the linters --- paprika/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/paprika/__init__.py b/paprika/__init__.py index c125ec7..d2f2d38 100644 --- a/paprika/__init__.py +++ b/paprika/__init__.py @@ -11,7 +11,6 @@ from paprika.evaluator import Analyze -from . import _version # Handle versioneer from ._version import get_versions @@ -21,7 +20,6 @@ __git_revision__ = versions["full-revisionid"] del get_versions, versions - logger = logging.getLogger(__name__) try: @@ -33,12 +31,9 @@ logging.info("`paprika.setup()` requires OpenMM.") setup = None - analyze = Analyze if setup is None: __all__ = ["setup", "analyze"] else: __all__ = ["analyze"] - -__version__ = _version.get_versions()["version"] From f0b31dc5c7740b491cb797b13c47b288eb78bdac Mon Sep 17 00:00:00 2001 From: Jake Anderson Date: Fri, 6 Sep 2024 22:20:08 -0700 Subject: [PATCH 13/13] Undid pin to python 3.8 accidentally given in 9ad2d31 --- devtools/conda-envs/test_env.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index af879e1..876eae9 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -4,7 +4,7 @@ channels: dependencies: # Base depends - - python=3.8 + - python - pip - numpy - scipy