-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from MachineLearningLifeScience/feature-better…
…-testing Test using `docker` & add `RaSP` to testing
- Loading branch information
Showing
25 changed files
with
493 additions
and
408 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
.github/workflows/python-tox-testing-including-conda-on-master.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Test (master, conda, python 3.9) | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
- name: Add conda to system path | ||
run: | | ||
# $CONDA is an environment variable pointing to the root of the miniconda directory | ||
echo $CONDA/bin >> $GITHUB_PATH | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install tox | ||
- name: Test linting with tox | ||
run: | | ||
tox -c tox.master.ini -e lint | ||
- name: Test poli-base with tox | ||
run: | | ||
tox -c tox.master.ini -e poli-base-py39 | ||
- name: Test poli-chem with tox | ||
run: | | ||
tox -c tox.master.ini -e poli-chem-py39 | ||
- name: Test poli-protein with tox | ||
run: | | ||
tox -c tox.master.ini -e poli-protein-py39 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This dockerfile allows us to run the tests in a container | ||
FROM --platform=linux/amd64 continuumio/anaconda3:latest | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copying the files from the host to the container | ||
COPY ./src /app/src | ||
COPY ./pyproject.toml /app/ | ||
COPY ./setup.cfg /app/ | ||
COPY ./requirements.txt /app/ | ||
COPY ./requirements-dev.txt /app/ | ||
COPY ./tox.ini /app/ | ||
|
||
# Installing distutils | ||
RUN apt-get update && \ | ||
apt-get install build-essential -y && \ | ||
apt-get install -y python3.9-distutils | ||
|
||
# Installing python dependencies | ||
RUN conda --version | ||
RUN pip install -r requirements.txt | ||
RUN pip install -r requirements-dev.txt | ||
|
||
# Creating the relevant conda environments | ||
# For chem | ||
RUN conda env create --file src/poli/objective_repository/rdkit_qed/environment.yml | ||
|
||
# For proteins | ||
RUN conda env create --file src/poli/objective_repository/foldx_stability/environment.yml | ||
RUN conda env create --file src/poli/objective_repository/rasp/environment.yml | ||
|
||
# Running the tests | ||
CMD ["tox"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
black | ||
tox | ||
setuptools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
python | ||
numpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/poli/objective_repository/foldx_stability/environment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/poli/objective_repository/foldx_stability_and_sasa/environment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
21 changes: 21 additions & 0 deletions
21
src/poli/tests/registry/basic_objectives/test_basic_objectives.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
|
||
from poli import objective_factory | ||
|
||
THIS_DIR = Path(__file__).parent.resolve() | ||
|
||
|
||
def test_registering_white_noise(): | ||
_, f, _, _, _ = objective_factory.create(name="white_noise") | ||
x = np.array([["A", "B", "C", "D"]]) | ||
f(x) | ||
f.terminate() | ||
|
||
|
||
def test_registering_aloha(): | ||
_, f, _, y0, _ = objective_factory.create(name="aloha") | ||
x = np.array([list("ALOOF")]) | ||
assert f(x) == 3 | ||
f.terminate() |
Empty file.
File renamed without changes.
148 changes: 148 additions & 0 deletions
148
src/poli/tests/registry/chemistry/test_chemistry_objectives.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import pytest | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
|
||
from poli import objective_factory | ||
|
||
THIS_DIR = Path(__file__).parent.resolve() | ||
|
||
|
||
def test_qed_is_available(): | ||
""" | ||
We test whether the qed problem is available | ||
when rdkit and selfies are installed. | ||
""" | ||
_ = pytest.importorskip("rdkit") | ||
_ = pytest.importorskip("selfies") | ||
from poli.objective_repository import AVAILABLE_PROBLEM_FACTORIES | ||
|
||
assert "rdkit_qed" in AVAILABLE_PROBLEM_FACTORIES | ||
|
||
|
||
def test_logp_is_available(): | ||
""" | ||
We test whether the logp problem is available | ||
when rdkit and selfies are installed. | ||
""" | ||
_ = pytest.importorskip("rdkit") | ||
_ = pytest.importorskip("selfies") | ||
from poli.objective_repository import AVAILABLE_PROBLEM_FACTORIES | ||
|
||
assert "rdkit_logp" in AVAILABLE_PROBLEM_FACTORIES | ||
|
||
|
||
def test_force_registering_qed(): | ||
""" | ||
We test whether we can force-register the qed problem | ||
if rdkit and selfies are not installed. | ||
""" | ||
alphabet = ["", "C", "..."] | ||
_, f, _, y0, _ = objective_factory.create( | ||
name="rdkit_qed", | ||
alphabet=alphabet, | ||
force_register=True, | ||
) | ||
|
||
# Asserting that the QED of a single carbon | ||
# is close to 0.35978494 (according to RDKit). | ||
assert np.isclose(y0, 0.35978494).all() | ||
f.terminate() | ||
|
||
|
||
def test_force_registering_qed_with_context_manager(): | ||
""" | ||
Tests the objective_factory.start method on QED. | ||
""" | ||
with objective_factory.start( | ||
name="rdkit_qed", | ||
force_register=True, | ||
force_isolation=True, | ||
path_to_alphabet=THIS_DIR / "alphabet_qed.json", | ||
) as f: | ||
x = np.array([["C"]]) | ||
y = f(x) | ||
assert np.isclose(y, 0.35978494).all() | ||
|
||
|
||
def test_force_registering_logp(): | ||
""" | ||
We test whether we can force-register the logp problem | ||
if rdkit and selfies are not installed. | ||
""" | ||
alphabet = ["", "C", ""] | ||
_, f, _, y0, _ = objective_factory.create( | ||
name="rdkit_logp", | ||
alphabet=alphabet, | ||
# path_to_alphabet=THIS_DIR / "alphabet_qed.json", | ||
force_register=True, | ||
) | ||
|
||
# Asserting that a single carbon atom has logp close | ||
# to 0.6361. (according to RDKit) | ||
assert np.isclose(y0, 0.6361).all() | ||
f.terminate() | ||
|
||
|
||
def test_registering_qed(): | ||
""" | ||
Testing whether we can register the qed problem | ||
if rdkit and selfies are installed. | ||
""" | ||
_ = pytest.importorskip("rdkit") | ||
_ = pytest.importorskip("selfies") | ||
np = pytest.importorskip("numpy") | ||
|
||
_, f, _, y0, _ = objective_factory.create( | ||
name="rdkit_qed", | ||
path_to_alphabet=THIS_DIR / "alphabet_qed.json", | ||
) | ||
x = np.array([["C"]]) | ||
y = f(x) | ||
|
||
# Asserting that the QED of a single carbon | ||
# is close to 0.35978494 (according to RDKit). | ||
assert np.isclose(y, 0.35978494).all() | ||
|
||
f.terminate() | ||
|
||
|
||
def test_registering_logp(): | ||
""" | ||
Testing whether we can register the logp problem | ||
if rdkit and selfies are installed. | ||
""" | ||
rdkit = pytest.importorskip("rdkit") | ||
selfies = pytest.importorskip("selfies") | ||
np = pytest.importorskip("numpy") | ||
|
||
_, f, _, y0, _ = objective_factory.create( | ||
name="rdkit_logp", | ||
path_to_alphabet=THIS_DIR / "alphabet_qed.json", | ||
) | ||
x = np.array([[1]]) | ||
f(x) | ||
|
||
# Asserting that a single carbon atom has logp close | ||
# to 0.6361. (according to RDKit) | ||
assert np.isclose(y0, 0.6361).all() | ||
|
||
f.terminate() | ||
|
||
|
||
def test_penalized_logp_lambo(): | ||
""" | ||
Testing whether we can register the logp problem | ||
from lambo. | ||
""" | ||
from poli import objective_factory | ||
|
||
_ = pytest.importorskip("lambo") | ||
|
||
# Using create | ||
_, f, x0, y0, _ = objective_factory.create( | ||
name="penalized_logp_lambo", force_register=True | ||
) | ||
print(x0) | ||
print(y0) | ||
f.terminate() |
File renamed without changes.
File renamed without changes.
Empty file.
Oops, something went wrong.