From 4dfd9cf02dae4d953d80991852ed6ae139d4a5f2 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Fri, 6 Oct 2023 10:33:49 -0500 Subject: [PATCH 1/2] Do not use 'old' OpenFF Toolkit API --- .github/workflows/CI.yaml | 4 +-- environment-dev.yml | 1 + foyer/topology_graph.py | 56 +++++++++++---------------------------- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 269fd7dd..56291faa 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -50,7 +50,7 @@ jobs: run: python -m pip install -e . - name: Test (OS -> ${{ matrix.os }} / Python -> ${{ matrix.python-version }}) - run: python -m pytest -v --cov=foyer --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs foyer + run: python -m pytest -v -nauto --cov=foyer --cov-report=xml --cov-append --cov-config=setup.cfg --color yes --pyargs foyer - name: Upload Coverage Report uses: codecov/codecov-action@v2 @@ -95,7 +95,7 @@ jobs: - name: Run Bleeding Edge Tests run: | - python -m pytest -v --color yes --pyargs foyer + python -m pytest -v -nauto --color yes --pyargs foyer docker: runs-on: ubuntu-latest diff --git a/environment-dev.yml b/environment-dev.yml index e6f42b5b..f565e5e2 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -21,6 +21,7 @@ dependencies: - pytest-azurepipelines - pytest-cov - pytest-timeout + - pytest-xdist - python>=3.8 - requests - requests-mock diff --git a/foyer/topology_graph.py b/foyer/topology_graph.py index e187e774..2fef4776 100644 --- a/foyer/topology_graph.py +++ b/foyer/topology_graph.py @@ -190,51 +190,27 @@ def from_openff_topology(cls, openff_topology: "OpenFFTopology"): f"Got {type(openff_topology).__name__} instead" ) - uses_old_api = hasattr(Topology(), "_topology_molecules") - top_graph = cls() - if uses_old_api: - from parmed import periodic_table as pt - - for top_atom in openff_topology.atoms: - atom = top_atom.atom - element_symbol = pt.Element[atom.atomic_number] - top_graph.add_atom( - name=atom.name, - index=top_atom.topology_atom_index, - atomic_number=atom.atomic_number, - symbol=element_symbol, - ) + from openff.units.elements import SYMBOLS - for top_bond in openff_topology.topology_bonds: - atoms_indices = [ - atom.topology_atom_index for atom in top_bond.atoms - ] - top_graph.add_bond(atoms_indices[0], atoms_indices[1]) + for atom in openff_topology.atoms: + atom_index = openff_topology.atom_index(atom) + element_symbol = SYMBOLS[atom.atomic_number] + top_graph.add_atom( + name=atom.name, + index=atom_index, + atomic_number=atom.atomic_number, + symbol=element_symbol, + ) - return top_graph + for bond in openff_topology.bonds: + atoms_indices = [ + openff_topology.atom_index(atom) for atom in bond.atoms + ] + top_graph.add_bond(*atoms_indices) - else: - from openff.units.elements import SYMBOLS - - for atom in openff_topology.atoms: - atom_index = openff_topology.atom_index(atom) - element_symbol = SYMBOLS[atom.atomic_number] - top_graph.add_atom( - name=atom.name, - index=atom_index, - atomic_number=atom.atomic_number, - symbol=element_symbol, - ) - - for bond in openff_topology.bonds: - atoms_indices = [ - openff_topology.atom_index(atom) for atom in bond.atoms - ] - top_graph.add_bond(*atoms_indices) - - return top_graph + return top_graph @classmethod def from_gmso_topology(cls, gmso_topology: "gmso.Topology"): From 81085c5e591f1db9be7a5058415655ee93391741 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Fri, 6 Oct 2023 10:45:34 -0500 Subject: [PATCH 2/2] Update environments --- environment-dev-win.yml | 1 + environment-win.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/environment-dev-win.yml b/environment-dev-win.yml index 6304798b..a5143168 100644 --- a/environment-dev-win.yml +++ b/environment-dev-win.yml @@ -18,6 +18,7 @@ dependencies: - pytest-azurepipelines - pytest-cov - pytest-timeout + - pytest-xdist - python>=3.8 - requests - requests-mock diff --git a/environment-win.yml b/environment-win.yml index d47d9136..f7ba8545 100644 --- a/environment-win.yml +++ b/environment-win.yml @@ -15,4 +15,5 @@ dependencies: - pytest-azurepipelines - pytest-cov - pytest-timeout + - pytest-xdist - python<=3.8