Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all backends together in CI #118

Merged
merged 17 commits into from
Apr 8, 2024
15 changes: 8 additions & 7 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ jobs:
os: [macOS-latest, ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
chemlib: [obabel, rdkit]
graphlib: [nx, gt, rx, all]
graphlib: [nogt, all]
exclude:
# graph-tools does not work on Windows
- {os: "windows-latest", graphlib: "gt"}
- {os: "windows-latest", graphlib: "all"}
- {graphlib: "all", chemlib: "obabel"}
# graph-tools does not work on Windows
RMeli marked this conversation as resolved.
Show resolved Hide resolved
- {os: "windows-latest", graphlib: "all"}
# Don't run without graph-tool on Ubuntu and macOS
- {os: "ubuntu-latest", graphlib: "nogt"}
- {os: "macOS-latest", graphlib: "nogt"}
include:
- {os: "macOS-14", graphlib: "gt", chemlib: "obabel", python-version: "3.12"}
- {os: "macOS-14", graphlib: "nx", chemlib: "rdkit", python-version: "3.12"}
- {os: "macOS-14", graphlib: "all", chemlib: "obabel", python-version: "3.12"}
- {os: "macOS-14", graphlib: "all", chemlib: "rdkit", python-version: "3.12"}

steps:
- uses: actions/checkout@v3
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@
Date: XX/YY/ZZZZ
Contributors: @RMeli

### Added

* Warnings filter for tests of multiple backends [PR #118 | @RMeli]
* Parametrized session fixture to run tests with all available backends [PR #118 | @RMeli]
RMeli marked this conversation as resolved.
Show resolved Hide resolved

### Improved

* Test IDs [PR #117 | @RMeli]

### Changed

* Location of backend tests to standalone file [PR #118 | @RMeli]

### Removed

* Many CI configurations in favour of running tests for all available backends [PR #118 | @RMeli]
* `tests/molecule.py` in favour of fixtures [PR #118 | @RMeli]

## Version 0.7.0

Date: 05/04/2024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ channels:
dependencies:
# Base
- python
- pip
- setuptools

# Maths
- numpy
- scipy
- graph-tool
- networkx>=2
- rustworkx

# Chemistry
- openbabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ channels:
dependencies:
# Base
- python
- pip
- setuptools

# Maths
- numpy
- scipy
- networkx>=2
- rustworkx

# Chemistry
- openbabel
Expand Down
26 changes: 0 additions & 26 deletions devtools/conda-envs/spyrmsd-test-obabel-rx.yaml

This file was deleted.

1 change: 1 addition & 0 deletions devtools/conda-envs/spyrmsd-test-rdkit-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
dependencies:
# Base
- python
- pip
- setuptools

# Maths
Expand Down
27 changes: 0 additions & 27 deletions devtools/conda-envs/spyrmsd-test-rdkit-gt.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ channels:
dependencies:
# Base
- python
- pip
- setuptools

# Maths
- numpy
- scipy
- networkx>=2
- rustworkx

# Chemistry
- rdkit
Expand Down
27 changes: 0 additions & 27 deletions devtools/conda-envs/spyrmsd-test-rdkit-rx.yaml

This file was deleted.

84 changes: 84 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
https://docs.pytest.org/en/latest/example/simple.html
"""

import os
from collections import namedtuple

import numpy as np
import pytest

import spyrmsd
from spyrmsd import io

Mol = namedtuple("Mol", ["mol", "name", "n_atoms", "n_bonds", "n_h"])


def pytest_addoption(parser):
parser.addoption(
Expand Down Expand Up @@ -69,3 +77,79 @@ def pytest_generate_tests(metafunc):
n = metafunc.config.getoption("--n-tests")

metafunc.parametrize("idx", np.random.randint(0, pytest.n_systems, size=n))


@pytest.fixture(autouse=True, scope="session", params=spyrmsd.available_backends)
def set_backend(request):
spyrmsd.set_backend(request.param)
RMeli marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope="session")
def molpath():
fdir = os.path.dirname(os.path.abspath(__file__))
return os.path.join(fdir, f"data{os.sep}molecules")


@pytest.fixture
def benzene(molpath):
mol = io.loadmol(os.path.join(molpath, "benzene.sdf"))
return Mol(mol, "benzene", 12, 12, 6)


@pytest.fixture
def pyridine(molpath):
mol = io.loadmol(os.path.join(molpath, "pyridine.sdf"))
return Mol(mol, "pyridine", 11, 11, 5)


@pytest.fixture(
params=[
("benzene", 12, 12, 6),
RMeli marked this conversation as resolved.
Show resolved Hide resolved
("ethanol", 9, 8, 6),
("pyridine", 11, 11, 5),
("dialanine", 23, 22, 12),
]
)
def mol(request, molpath):
name, n_atoms, n_bonds, n_h = request.param
RMeli marked this conversation as resolved.
Show resolved Hide resolved

mol = io.loadmol(os.path.join(molpath, f"{name}.sdf"))

return Mol(mol, name, n_atoms, n_bonds, n_h)


@pytest.fixture
def rawmol(mol, molpath):
RawMol = namedtuple(
RMeli marked this conversation as resolved.
Show resolved Hide resolved
"RawMol", ["mol", "rawmol", "name", "n_atoms", "n_bonds", "n_h"]
)

rawmol = io.load(os.path.join(molpath, f"{mol.name}.sdf"))

return RawMol(mol.mol, rawmol, mol.name, mol.n_atoms, mol.n_bonds, mol.n_h)


@pytest.fixture
def trps(molpath):
trp_list = []
for i in range(6):
trp_list.append(io.loadmol(os.path.join(molpath, f"trp{i}.pdb")))

return trp_list


@pytest.fixture
def docking_2viz(molpath):
mols = {} # Dictionary (pose, molecule)
for i in [1, 2, 3]:
mols[i] = io.loadmol(os.path.join(molpath, f"2viz_{i}.sdf"))

return mols


@pytest.fixture
def docking_1cbr(molpath):
return [
io.loadmol(os.path.join(molpath, "1cbr_ligand.mol2")),
*io.loadallmols(os.path.join(molpath, "1cbr_docking.sdf")),
]
80 changes: 0 additions & 80 deletions tests/molecules.py

This file was deleted.

Loading
Loading