Skip to content

Commit

Permalink
Merge branch 'enhancement/pypi_integration' into 'dev'
Browse files Browse the repository at this point in the history
Use only PyPI dependencies and make QSPRpred installable from it

Closes #42

See merge request cdd/QSPRpred!185
  • Loading branch information
martin-sicho committed Mar 27, 2024
2 parents a98097f + 2fa2852 commit db81567
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docs_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches:
- dev
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

env:
CI_COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/pypi-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish Python 🐍 distribution 📦 to TestPyPI

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+.alpha[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.beta[0-9]+'

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi-test:
name: >-
Publish Python 🐍 distribution 📦 to TestPyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi-test # IMPORTANT: mandatory for trusted publishing
url: https://test.pypi.org/p/qsprpred # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
52 changes: 52 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi # IMPORTANT: mandatory for trusted publishing
url: https://pypi.org/p/qsprpred # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
10 changes: 6 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ stages:
- export MAFFT_BINARIES=$PWD/mafft-linux64/mafftdir/libexec/
- clustalo --version # For debugging clustalo version
- mafft --version # For debugging mafft version
- pip install ".[full]" --no-cache-dir
# - pip config set global.index-url https://pypi.org/simple/
# - pip config set global.extra-index-url https://test.pypi.org/simple/
- python -m pip install ".[full]" --no-cache-dir
- python -c "import qsprpred; print(qsprpred.__version__)" # For debugging package version
- pip install pytest
- pip install jupyterlab
- pip freeze # For debugging environment
- python -m pip install pytest
- python -m pip install jupyterlab
- python -m pip freeze # For debugging environment
script:
- cd testing && QSPPRED_TEST_SPLIT_UNITS=true QSPRPRED_VERBOSE_LOGGING=true ./run.sh

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ From v3.0.1 to v3.0.2

## Changes


- Restrictions on `numpy` versions were removed to allow for more flexibility in
package installations. However, the `BorutaFilter` feature selection method does not
function with `numpy` versions 1.24.0 and above. Therefore, this functionality now
requires a downgrade to `numpy` version 1.23.0 or lower. This was reflected in the
documentation and `numpy` itself outputs a reasonable error message if the version is
incompatible.
- Data type in `MlChemADWrapper` is now set to `float64` by default, instead of `float32`.

## New Features
Expand All @@ -25,6 +32,7 @@ From v3.0.1 to v3.0.2
custom descriptor sets.
- Added the `prepMols` method to `DescriptorSet` to allow separated customization of
molecule preparation before descriptor calculation.
- The package can now be installed from the PyPI repository 🐍📦.

## Removed Features

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[**Main**](https://github.com/CDDLeiden/QSPRpred/) [![Build and Deploy Documentation](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml/badge.svg?branch=main)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml)[![Multi-OS Complete Test](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml/badge.svg?branch=main)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml)
[**Main
**](https://github.com/CDDLeiden/QSPRpred/) [![Build and Deploy Documentation](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml/badge.svg?branch=main)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml)[![Multi-OS Complete Test](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml/badge.svg?branch=main)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml)

[**Dev**](https://github.com/CDDLeiden/QSPRpred/tree/dev) [![Build and Deploy Documentation](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml/badge.svg?branch=dev)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml)[![Multi-OS Complete Test](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml/badge.svg?branch=dev)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml)
[**Dev
**](https://github.com/CDDLeiden/QSPRpred/tree/dev) [![Build and Deploy Documentation](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml/badge.svg?branch=dev)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/docs_ci.yml)[![Multi-OS Complete Test](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml/badge.svg?branch=dev)](https://github.com/CDDLeiden/QSPRpred/actions/workflows/dev_ci.yml)

QSPRpred
====================
Expand Down Expand Up @@ -42,15 +44,15 @@ Quick Start
QSPRpred can be installed with pip like so (with python >= 3.10):

```bash
pip install git+https://github.com/CDDLeiden/QSPRpred.git@main
pip install qsprpred
```

Note that this will install the basic dependencies, but not the optional dependencies.
If you want to use the optional dependencies, you can install the package with an
option:

```bash
pip install git+https://github.com/CDDLeiden/QSPRpred.git@main#egg=qsprpred[<option>]
pip install qsprpred[<option>]
```

The following options are available:
Expand All @@ -66,7 +68,7 @@ The following options are available:

### Note on PCM Modelling

If you plan to optionally use QSPRPred to calculate protein descriptors for PCM, make
If you plan to optionally use QSPRpred to calculate protein descriptors for PCM, make
sure to also install Clustal Omega. You can get it via `conda` (**for Linux and MacOS
only**):

Expand Down
2 changes: 1 addition & 1 deletion docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Overview of available features

* :class:`~qsprpred.data.processing.feature_filters.HighCorrelationFilter`: HighCorrelationFilter
* :class:`~qsprpred.data.processing.feature_filters.LowVarianceFilter`: LowVarianceFilter
* :class:`~qsprpred.data.processing.feature_filters.BorutaFilter`: BorutaFilter
* :class:`~qsprpred.data.processing.feature_filters.BorutaFilter`: BorutaFilter (:code:`numpy` version restricted to :code:`numpy<1.24.0`)

.. dropdown:: Models

Expand Down
15 changes: 11 additions & 4 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You do not need anything special to install the package . Just run the following

.. code-block::
pip install git+https://github.com/CDDLeiden/QSPRpred.git@main
pip install qsprpred
You can also get tags and development snapshots by varying the :code:`@main` part (i.e. :code:`@1.0.0`). After that you can start building models (see :ref:`cli-usage`).

Expand All @@ -17,7 +17,7 @@ option:

.. code-block::
pip install git+https://github.com/CDDLeiden/QSPRpred.git@main#egg=qsprpred[<option>]
pip install qsprpred[<option>]
The following options are available:

Expand All @@ -32,6 +32,13 @@ The following options are available:

You can test the installation by running the unit test suite:

.. code-block::
.. code-block:: bash
python -m unittest discover qsprpred
Note that this can potentially take a long time and some tests may require you to have
additional dependencies installed. However, you can also test each module separately:

.. code-block:: bash
python -m unittest discover qsprpred
python -m unittest qsprpred.data.tables.tests
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ classifiers = [
dependencies = [
"parameterized",
"pebble",
"numpy >= 1.19, <1.24.0",
"numpy",
"scikit-learn >= 1.0.2",
"pandas >= 1.2.2",
"matplotlib >= 2.0",
Expand All @@ -51,18 +51,18 @@ dependencies = [
"xgboost",
"boruta",
"tqdm",
"ml2json @ git+https://github.com/HellevdM/ml2json.git",
"ml2json",
"jsonpickle",
"papyrus_scripts @ git+https://github.com/OlivierBeq/Papyrus-scripts.git",
"gbmt-splits @ git+https://github.com/sohviluukkonen/gbmt-splits@0.0.4",
"papyrus_scripts",
"gbmtsplits",
"mlchemad",
"mols2grid"
]

[project.optional-dependencies]

extra = [
"mold2-pywrapper @ git+https://github.com/OlivierBeq/Mold2_pywrapper.git@master",
"mold2-pywrapper",
"padel-pywrapper >= 1.0.2.post1", "Mordred", "biopython", "prodec", "Signature-pywrapper",
]
pyboost = ["py-boost"]
Expand All @@ -74,9 +74,9 @@ dev = ["qsprpred[full]", "pre-commit", "isort", "yapf", "ruff", "pytest"]
where = ["."]

[project.urls]
homepage = "https://github.com/CDDLeiden/QSPRPred"
repository = "https://github.com/CDDLeiden/QSPRPred"
documentation = "https://cddleiden.github.io/QSPRPred/docs/"
homepage = "https://github.com/CDDLeiden/QSPRpred"
repository = "https://github.com/CDDLeiden/QSPRpred"
documentation = "https://cddleiden.github.io/QSPRpred/docs/"

[tool.setuptools]
include-package-data = true
Expand Down
4 changes: 3 additions & 1 deletion qsprpred/data/processing/feature_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def __call__(self, df: pd.DataFrame, y_col: pd.DataFrame = None) -> pd.DataFrame
class BorutaFilter(FeatureFilter, Randomized):
"""Boruta filter from BorutaPy: Boruta all-relevant feature selection.
Uses BorutaPy implementation from https://github.com/scikit-learn-contrib/boruta_py
Uses BorutaPy implementation from https://github.com/scikit-learn-contrib/boruta_py.
Note that the `boruta` package is not compatible with numpy 1.24.0 and above.
Therefore, make sure to downgrade numpy to 1.23.0 or older before using this filter.
Attributes:
featSelector (BorutaPy): BorutaPy feature selector
Expand Down
5 changes: 5 additions & 0 deletions qsprpred/data/processing/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import itertools
from unittest import skipIf

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -224,6 +225,10 @@ def testHighCorrelationFilter(self, use_index_cols):
(False,),
]
)
@skipIf(
int(np.__version__.split(".")[1]) >= 24,
"numpy 1.24.0 not compatible with boruta",
)
def testBorutaFilter(self, use_index_cols):
"""Test the Boruta filter, which removes the features which are statistically as
relevant as random features."""
Expand Down
Loading

0 comments on commit db81567

Please sign in to comment.