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

Fix inclusion of tests in source dist #188

Merged
merged 7 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 108 additions & 88 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,106 +23,126 @@ jobs:
# only run once if internal PR
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
matrix:
include:
matrix:
include:
- label: earliest
os: ubuntu-latest
python-version: 3.8
rdkit-version: "rdkit=2021.03.1"
coverage: false
- label: baseline
os: ubuntu-latest
python-version: 3.9
python-version: "3.10"
rdkit-version: "rdkit~=2022.09"
coverage: true
- label: latest
os: ubuntu-latest
python-version: "3.10"
python-version: "3.12"
rdkit-version: "rdkit"
coverage: false

steps:
- uses: actions/checkout@v4

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
auto-update-conda: true
channel-priority: flexible
channels: conda-forge, defaults
add-pip-as-python-dependency: true
architecture: x64
use-mamba: true
miniforge-variant: Mambaforge

- name: Check conda and pip
run: |
which python
python --version
pip --version
conda --version
mamba --version

- name: Install conda dependencies
run: |
mamba install ${{ matrix.rdkit-version }}
mamba list

- name: Install package through pip
run: |
pip install .[dev]
pip list

- name: Run tests
run: |
pytest --color=yes --disable-pytest-warnings --cov=prolif --cov-report=xml tests/

- name: Measure tests coverage
if: matrix.coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build
run: |
python -m build

- name: Remove previous ProLIF install
run: |
pip uninstall -y prolif

- name: Install from tar.gz
run: |
pip install dist/prolif-*.tar.gz

- name: Test tar.gz install
run: |
python <<EOF
import prolif
import os
print(prolif.__version__)
from prolif.plotting.network import LigNetwork
assert os.path.isfile(prolif.datafiles.TOP)
EOF

- name: Remove previous ProLIF install
run: |
pip uninstall -y prolif

- name: Install from wheel
run: |
pip install dist/prolif-*.whl

- name: Test wheel install
run: |
python <<EOF
import prolif
import os
print(prolif.__version__)
from prolif.plotting.network import LigNetwork
assert os.path.isfile(prolif.datafiles.TOP)
EOF
- uses: actions/checkout@v4

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
auto-update-conda: true
channel-priority: flexible
channels: conda-forge, defaults
add-pip-as-python-dependency: true
architecture: x64
use-mamba: true
miniforge-variant: Mambaforge

- name: Check conda and pip
run: |
which python
python --version
pip --version
conda --version
mamba --version

- name: Install conda dependencies
run: |
mamba install ${{ matrix.rdkit-version }}
mamba list

- name: Install package through pip
run: |
pip install .[dev]
pip list

- name: Build
run: |
python -m build

- name: Ensure tests and data included in source dist
run: |
tar -ztvf dist/prolif-*.tar.gz | grep -E 'prolif-.+/tests/.+' || exit 1
tar -ztvf dist/prolif-*.tar.gz | grep -E 'prolif-.+/data/.+' || exit 1
tar -ztvf dist/prolif-*.tar.gz | grep -E 'prolif-.+/data/vina/.+' || exit 1

- name: Run tests
run: |
pytest --color=yes --disable-pytest-warnings --cov=prolif --cov-report=xml tests/

- name: Measure tests coverage
if: matrix.coverage
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Build
run: |
python -m build

- name: Remove previous ProLIF install
run: |
pip uninstall -y prolif

- name: Install from tar.gz
run: |
pip install dist/prolif-*.tar.gz

- name: Test tar.gz install
working-directory: /
run: |
python <<EOF
from pathlib import Path
from contextlib import suppress
import prolif
print(prolif.__version__)
from prolif.plotting.network import LigNetwork
assert Path(prolif.datafiles.TOP).is_file()
with suppress(ImportError, ModuleNotFoundError):
import tests
assert next(Path(tests.__file__).parent.glob("test_fingerprint.py"), None) is None
EOF

- name: Remove previous ProLIF install
run: |
pip uninstall -y prolif

- name: Install from wheel
run: |
pip install dist/prolif-*.whl

- name: Test wheel install
working-directory: /
run: |
python <<EOF
from pathlib import Path
from contextlib import suppress
import prolif
print(prolif.__version__)
from prolif.plotting.network import LigNetwork
assert Path(prolif.datafiles.TOP).is_file()
with suppress(ImportError, ModuleNotFoundError):
import tests
assert next(Path(tests.__file__).parent.glob("test_fingerprint.py"), None) is None
EOF
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]


## [2.0.2] - 2024-03-01

Maintenance update:

### Added

- `PROLIF_N_JOBS` environment variable to control multiprocessing during the
documentation build.

### Changed

- Updated CI pipelines to test on Python 3.8, 3.10 and 3.12.

### Fixed

- Packaging maintenance to fix the `tests/` directory being included as a module rather
than as plain data files. This could interfere with `pytest` during test collection
in other packages.


## [2.0.1] - 2023-10-11

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
]
nb_execution_allow_errors = False
nb_execution_raise_on_error = True
nb_execution_timeout = 180
nb_execution_timeout = 300

mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
autosectionlabel_prefix_document = True
Expand Down
2 changes: 1 addition & 1 deletion prolif/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.1"
__version__ = "2.0.2-rc1"
4 changes: 4 additions & 0 deletions prolif/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
fp = prolif.Fingerprint.from_pickle("fingerprint.pkl")

"""

import os
import warnings
from collections.abc import Sized
from functools import wraps
Expand Down Expand Up @@ -462,6 +464,8 @@ def run(
raise ValueError("converter_kwargs must be a list of 2 dicts")

converter_kwargs = converter_kwargs or ({}, {})
if n_jobs is None:
n_jobs = int(os.environ.get("PROLIF_N_JOBS", 0)) or None
if residues == "all":
residues = list(Molecule.from_mda(prot, **converter_kwargs[1]).residues)
if n_jobs != 1:
Expand Down
1 change: 1 addition & 0 deletions prolif/ifp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Storing interactions --- :mod:`prolif.ifp`
==========================================
"""

from collections import UserDict

from prolif.residue import ResidueId
Expand Down
1 change: 1 addition & 0 deletions prolif/interactions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

This module contains the base classes used to build most of the interactions.
"""

import warnings
from itertools import product
from math import degrees, radians
Expand Down
10 changes: 2 additions & 8 deletions prolif/interactions/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ class Hydrophobic(Distance):

def __init__(
self,
hydrophobic=(
"[c,s,Br,I,S&H0&v2," "$([D3,D4;#6])&!$([#6]~[#7,#8,#9])&!$([#6X4H0]);+0]"
),
hydrophobic="[c,s,Br,I,S&H0&v2,$([D3,D4;#6])&!$([#6]~[#7,#8,#9])&!$([#6X4H0]);+0]",
distance=4.5,
):
super().__init__(
Expand Down Expand Up @@ -99,11 +97,7 @@ class HBAcceptor(SingleAngle):

def __init__(
self,
acceptor=(
"[#7&!$([nX3])&!$([NX3]-*=[O,N,P,S])&!$([NX3]-[a])&!$([Nv4&+1]),"
"O&!$([OX2](C)C=O)&!$(O(~a)~a)&!$(O=N-*)&!$([O-]-N=O),o+0,"
"F&$(F-[#6])&!$(F-[#6][F,Cl,Br,I])]"
),
acceptor="[#7&!$([nX3])&!$([NX3]-*=[O,N,P,S])&!$([NX3]-[a])&!$([Nv4&+1]),O&!$([OX2](C)C=O)&!$(O(~a)~a)&!$(O=N-*)&!$([O-]-N=O),o+0,F&$(F-[#6])&!$(F-[#6][F,Cl,Br,I])]",
donor="[$([O,S;+0]),$([N;v3,v4&+1]),n+0]-[H]",
distance=3.5,
DHA_angle=(130, 180),
Expand Down
3 changes: 2 additions & 1 deletion prolif/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Reading proteins and ligands --- :mod:`prolif.molecule`
=======================================================
"""

import copy
from collections import defaultdict
from collections.abc import Sequence
Expand Down Expand Up @@ -116,7 +117,7 @@ def from_mda(cls, obj, selection=None, **kwargs):
"""
ag = obj.select_atoms(selection) if selection else obj.atoms
if ag.n_atoms == 0:
raise mda.SelectionError(f"AtomGroup is empty, please check your selection")
raise mda.SelectionError("AtomGroup is empty, please check your selection")
mol = ag.convert_to.rdkit(**kwargs)
return cls(mol)

Expand Down
1 change: 1 addition & 0 deletions prolif/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
in :meth:`~prolif.fingerprint.Fingerprint.run` and
:meth:`~prolif.fingerprint.Fingerprint.run_from_iterable` respectively.
"""

from ctypes import c_uint32
from threading import Event, Thread
from time import sleep
Expand Down
1 change: 1 addition & 0 deletions prolif/pickling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
behavior upon importing the `prolif` package to ensure that the parallelization code
works as on other platforms.
"""

import sys
from typing import Optional

Expand Down
10 changes: 6 additions & 4 deletions prolif/plotting/barcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:members:

"""

from __future__ import annotations

from typing import TYPE_CHECKING, ClassVar, Dict, List, Literal, Optional, Tuple
Expand Down Expand Up @@ -73,9 +74,9 @@ def _bit_to_color_value(s: pd.Series) -> pd.Series:
"""Replaces a bit value with it's corresponding color value"""
interaction = s.name[-1]
return s.apply(
lambda v: self.color_mapper[interaction]
if v
else self.color_mapper[None]
lambda v: (
self.color_mapper[interaction] if v else self.color_mapper[None]
)
)

self.df = df.astype(np.uint8).T.apply(_bit_to_color_value, axis=1)
Expand All @@ -85,7 +86,8 @@ def from_fingerprint(cls, fp: Fingerprint) -> Barcode:
"""Creates a barcode object from a fingerprint."""
if not hasattr(fp, "ifp"):
raise RunRequiredError(
"Please run the fingerprint analysis before attempting to display results."
"Please run the fingerprint analysis before attempting to display"
" results."
)
return cls(fp.to_dataframe())

Expand Down
Loading
Loading