From 6d97097e4a5b87ff1f59542db4a44cd8892cd215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Pulido?= <2949729+ijpulidos@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:27:47 -0400 Subject: [PATCH 1/2] Initial quick support for pydantic 2 (>=1.10.17) (#58) --- .github/workflows/ci.yaml | 6 ++++-- devtools/conda-envs/test_env.yaml | 2 +- feflow/settings/integrators.py | 5 +---- feflow/settings/nonequilibrium_cycling.py | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6caaecc..42b083c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,11 +23,12 @@ defaults: jobs: tests: runs-on: ${{ matrix.os }}-latest - name: "💻-${{matrix.os }} 🐍-${{ matrix.python-version }}" + name: "💻-${{matrix.os }} 🐍-${{ matrix.python-version }} - pydantic ${{matrix.pydantic}}" strategy: fail-fast: false matrix: os: ["ubuntu"] + pydantic: ["1", "2"] python-version: - "3.10" - "3.11" @@ -52,6 +53,7 @@ jobs: cache-downloads: true create-args: >- python=${{ matrix.python-version }} + pydantic=${{ matrix.pydantic }} init-shell: bash - name: "Install" @@ -80,7 +82,7 @@ jobs: # Set the OFE_SLOW_TESTS to True if running a Cron job OFE_SLOW_TESTS: ${{ fromJSON('{"false":"false","true":"true"}')[github.event_name != 'pull_request'] }} run: | - pytest -n auto -v --cov=feflow --cov-report=xml --durations=10 + pytest -n auto -v --cov=feflow --cov-report=xml --durations=10 - name: codecov if: ${{ github.repository == 'choderalab/feflow' diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 473d80a..7868626 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -11,7 +11,7 @@ dependencies: - openmm - openmmforcefields >=0.14.1 # TODO: remove when upstream deps fix this - pymbar <4 - - pydantic=1 # TODO: Modify when we support pydantic 2 + - pydantic >=1.10.17 - python # Testing (optional deps) diff --git a/feflow/settings/integrators.py b/feflow/settings/integrators.py index 227ca51..91cb1b7 100644 --- a/feflow/settings/integrators.py +++ b/feflow/settings/integrators.py @@ -6,10 +6,7 @@ for the specific integrator settings. """ -try: - from pydantic.v1 import validator -except ImportError: - from pydantic import validator # type: ignore[assignment] +from pydantic.v1 import validator from openff.units import unit from openff.models.types import FloatQuantity diff --git a/feflow/settings/nonequilibrium_cycling.py b/feflow/settings/nonequilibrium_cycling.py index 1a49adf..a3eb46f 100644 --- a/feflow/settings/nonequilibrium_cycling.py +++ b/feflow/settings/nonequilibrium_cycling.py @@ -10,7 +10,7 @@ ) from gufe.settings import Settings -from pydantic import root_validator +from pydantic.v1 import root_validator from openfe.protocols.openmm_utils.omm_settings import ( OpenMMSolvationSettings, OpenMMEngineSettings, From 842f1ae260a08c45e55a9edd6730dc0239241455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Pulido?= <2949729+ijpulidos@users.noreply.github.com> Date: Thu, 8 Aug 2024 12:48:01 -0400 Subject: [PATCH 2/2] Remove perses references in docs. (#59) --- feflow/protocols/nonequilibrium_cycling.py | 4 ++-- feflow/utils/hybrid_topology.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/feflow/protocols/nonequilibrium_cycling.py b/feflow/protocols/nonequilibrium_cycling.py index 23cfd90..bc52fcb 100644 --- a/feflow/protocols/nonequilibrium_cycling.py +++ b/feflow/protocols/nonequilibrium_cycling.py @@ -450,7 +450,7 @@ def extract_positions(context, initial_atom_indices, final_atom_indices): ---------- context: openmm.Context Current simulation context where from extract positions. - hybrid_topology_factory: perses.annihilation.relative.HybridTopologyFactory + hybrid_topology_factory: HybridTopologyFactory Hybrid topology factory where to extract positions and mapping information Returns @@ -508,7 +508,7 @@ def _execute(self, ctx, *, protocol, setup, **inputs): # Setting up logging to file in shared filesystem file_logger = logging.getLogger("neq-cycling") - output_log_path = ctx.shared / "perses-neq-cycling.log" + output_log_path = ctx.shared / "feflow-neq-cycling.log" file_handler = logging.FileHandler(output_log_path, mode="w") file_handler.setLevel(logging.DEBUG) # TODO: Set to INFO in production log_formatter = logging.Formatter( diff --git a/feflow/utils/hybrid_topology.py b/feflow/utils/hybrid_topology.py index 9708594..6696e01 100644 --- a/feflow/utils/hybrid_topology.py +++ b/feflow/utils/hybrid_topology.py @@ -2551,8 +2551,7 @@ def _compute_hybrid_positions(self): The positions are assigned by first copying all the mapped positions from the old system in, then copying the mapped positions from the new system. This means that there is an - assumption that the positions common to old and new are the same - (which is the case for perses as-is). + assumption that the positions common to old and new are the same. Returns -------