Skip to content

Commit

Permalink
Merge branch 'dev' into feature-blackbox-rosetta
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgondu committed Jul 31, 2024
2 parents 608e217 + 2b4142a commit 84d6ad7
Show file tree
Hide file tree
Showing 174 changed files with 2,040 additions and 1,596 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Tests on poli (dev, conda, python 3.9)
name: poli base (conda, py3.9)

on: [push]
on:
push:
schedule:
- cron: '0 0 * * 0'

jobs:
build-linux:
Expand All @@ -24,6 +27,6 @@ jobs:
- name: Test linting with tox
run: |
tox -c tox.ini -e lint
- name: Test poli-base with tox (ignoring RaSP)
- name: Test basic behaviors of poli with tox and pytest
run: |
tox -c tox.ini -e poli-base-py39 -- --ignore=src/poli/tests/registry/proteins/test_rasp.py
tox -c tox.ini -e poli-base-py39
29 changes: 29 additions & 0 deletions .github/workflows/python-tox-testing-dockstring-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: poli dockstring (conda, py3.9)

on:
push:
schedule:
- cron: '0 0 * * 0'

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 dockstring-related black boxes with tox and pytest
run: |
tox -c tox.ini -e poli-dockstring-py39
29 changes: 29 additions & 0 deletions .github/workflows/python-tox-testing-lambo-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: poli lambo (conda, py3.9)

on:
push:
schedule:
- cron: '0 0 * * 0'

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 lambo-related black boxes with tox and pytest
run: |
tox -c tox.ini -e poli-lambo-py39
29 changes: 29 additions & 0 deletions .github/workflows/python-tox-testing-protein-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: poli protein (conda, py3.9)

on:
push:
schedule:
- cron: '0 0 * * 0'

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 protein-related black boxes with tox and pytest
run: |
tox -c tox.ini -e poli-protein-py39
29 changes: 29 additions & 0 deletions .github/workflows/python-tox-testing-rmf-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: poli rmf (conda, py3.9)

on:
push:
schedule:
- cron: '0 0 * * 0'

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 rmf-related black boxes with tox and pytest
run: |
tox -c tox.ini -e poli-rmf-py39
29 changes: 29 additions & 0 deletions .github/workflows/python-tox-testing-tdc-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: poli tdc (conda, py3.9)

on:
push:
schedule:
- cron: '0 0 * * 0'

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 PyTDC-related black boxes with tox and pytest
run: |
tox -c tox.ini -e poli-tdc-py39
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: '.*\.pdb$'
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.5.5
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ authors:
- family-names: "Michael"
given-names: "Richard"
title: "poli: a libary of discrete sequence objectives"
version: 0.1.0
version: 0.2.1
date-released: 2024-01-23
url: "https://github.com/MachineLearningLifeScience/poli"
49 changes: 33 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,65 @@
![Linting: black](https://img.shields.io/badge/Linting-black-black)
![Testing: pytest](https://img.shields.io/badge/Testing-pytest-blue)
![Testing: tox](https://img.shields.io/badge/Testing-tox-blue)
![Main branch: black](https://img.shields.io/badge/Pull_request_to-dev-blue)
![Main branch: dev](https://img.shields.io/badge/Pull_request_to-dev-blue)

This note details how to contribute to `poli`.

## Forking and making pull requests

The main development branch is called `dev`. To contribute, we recommend creating a fork of this repository and making changes on your version. Once you are ready to contribute, we expect you to document, lint and test.

## Documentation standards
## Installing dev dependencies and pre-commit hooks

We follow [numpy's documentation standards](https://numpydoc.readthedocs.io/en/latest/format.html).
We recommend you create a `poli-dev` environment in conda

## Linting your changes
```bash
conda create -n poli-dev python=3.10
conda activate poli-dev
pip install -r requirements.txt
pip install -r requirements-dev.txt
```

We expect you to lint the code you write or modify using `black`.
The dev requirements include `pre-commit`. Install the hooks in our config by running

```bash
pip install black
black ./path/to/files
pre-commit install
```

## Testing your changes for `dev``
Now every commit will run linting and isorting for you. You can also run it manually by saying

```bash
pre-commit run --all-files
```

## Documentation standards

We follow [numpy's documentation standards](https://numpydoc.readthedocs.io/en/latest/format.html).

## Creating a new environment? Mark your tests

If you're contributing a black box in a new environment, remember to

1. Mark all your tests with `@pyest.mark.poli__your_env`.
2. Add a description of your marker to the `[tool.pytest.ini_options]`.

## Testing your changes for `dev`

Since we are testing multiple conda environments, we settled for using a combination of `tox` and `pytest`.

```bash
pip install tox

# To test linting (from the root of the project)
tox -c tox.dev.ini -e lint
tox -c tox.ini -e lint

# To test in the base environment for poli
tox -c tox.dev.ini -e poli-base-py39
tox -c tox.ini -e poli-base-py39
```

If you want to run tests in all environments, remove `-e poli-base-py39` and just run `tox`.

## More thorough testing

In many cases, testing with the instructions above should be enough. However, since we are dealing with creating conda environments, the definite test comes by building the Docker image specified in `Dockerfile.test`, and running it.
There are several different environments (depending on the black boxes we test). Check `tox.ini` for more details.

When contributing to the `@master` branch (i.e. to release), we will run these tests.
If you want to run tests in all environments, remove `-e poli-base-py39` and just run `tox`. This might take a while, and several conda envs will be created.

## Create a pull request to dev

Expand Down
27 changes: 17 additions & 10 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# poli 🧪, a library for discrete objective functions
# `poli` 🧪, a library for discrete objective functions

[![Testing (conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-including-conda.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-including-conda.yml)
[![Link to documentation](https://img.shields.io/badge/docs-poli_docs-blue)](https://machinelearninglifescience.github.io/poli-docs/)
[![poli base (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml)
[![Link to documentation](https://img.shields.io/badge/documentation-poli_docs-blue)](https://machinelearninglifescience.github.io/poli-docs/)

poli is a library of discrete objective functions for benchmarking optimization algorithms. Examples include:
- 🔬 **stability** of mutations from a wildtype protein (using [foldx](https://foldxsuite.crg.eu/) or [rasp](https://github.com/KULL-Centre/_2022_ML-ddG-Blaabjerg)).
- 🧪 **docking scores** of ligands to proteins (using [dockstring](https://github.com/dockstring/dockstring), [pyscreener](https://github.com/coleygroup/pyscreener) and [pytdc](https://tdcommons.ai/functions/oracles/)).
- 💊 **druglikeness** or **synthetic acccesibility** of small molecules (using [rdkit](https://github.com/rdkit/rdkit) and [pytdc](https://tdcommons.ai/functions/oracles/)).
`poli` is a library of discrete objective functions for benchmarking optimization algorithms.

Some of `poli`'s features:
## Black boxes

| Black box | References | Tests
|----------|----------|----------|
| [Toy continuous functions (e.g. Ackley, Hartmann...)](https://machinelearninglifescience.github.io/poli-docs/using_poli/objective_repository/toy_continuous_problems.html) | [(Al-Roomi 2015)](https://www.al-roomi.org/benchmarks/unconstrained), [(Surjanovic & Bingham 2013)](https://www.sfu.ca/~ssurjano/optimization.html) | [![poli base (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml) |
| Ehrlich functions | [(Stanton et al. 2024)](https://arxiv.org/abs/2407.00236) | [![poli base (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-base.yml)
| [PMO/GuacaMol benchmark](https://machinelearninglifescience.github.io/poli-docs/#small-molecules) | [(Brown et al. 2019)](https://arxiv.org/abs/1811.09621), [(Gao et al. 2022)](https://openreview.net/forum?id=yCZRdI0Y7G), [(Huang et al. 2021)](https://openreview.net/pdf?id=8nvgnORnoWr) | [![poli tdc (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-tdc-env.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-tdc-env.yml)
| [Dockstring](https://machinelearninglifescience.github.io/poli-docs/using_poli/objective_repository/dockstring.html) | [(García-Ortegón et al. 2022)](https://pubs.acs.org/doi/full/10.1021/acs.jcim.1c01334) | [![poli dockstring (dev, conda, python 3.9)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-dockstring-env.yml/badge.svg)](https://github.com/MachineLearningLifeScience/poli/actions/workflows/python-tox-testing-dockstring-env.yml)
| [FoldX stability and SASA](https://machinelearninglifescience.github.io/poli-docs/#proteins) | [(Schymkowitz et al. 2005)](https://academic.oup.com/nar/article/33/suppl_2/W382/2505499?login=true) | - |
| [RaSP](https://machinelearninglifescience.github.io/poli-docs/using_poli/objective_repository/RaSP.html) | [(Blaabjerg et al. 2023)](https://elifesciences.org/articles/82593) | -

## Features
- 🔲 **isolation** of black box function calls inside conda environments. Don't worry about clashes w. black box requirements, poli will create the relevant conda environments for you.
- 🗒️ **logging** each black box call using observers.
- A numpy interface. Inputs are `np.array`s of strings, outputs are `np.array`s of floats.
Expand All @@ -27,8 +35,7 @@ pip install git+https://github.com/MachineLearningLifeScience/poli.git@dev
To check if everything went well, you can run

```bash
$ python -c "from poli import get_problems ; print(get_problems())"
['aloha', ..., 'white_noise']
$ python -c "from poli import create"
```

### An example: dockstring
Expand Down
1 change: 1 addition & 0 deletions examples/minimal_working_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import numpy as np

from poli import objective_factory

problem = objective_factory.create(name="white_noise")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
from pathlib import Path

import numpy as np
from wandb_observer import WandbObserver

from poli.core.problem import Problem
from poli.objective_repository import QEDProblemFactory

from wandb_observer import WandbObserver

THIS_DIR = Path(__file__).parent.resolve()

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"""

import numpy as np
import wandb

import wandb
from poli.core.black_box_information import BlackBoxInformation
from poli.core.util.abstract_observer import AbstractObserver

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
from pathlib import Path

import numpy as np
from mlflow_observer import MlFlowObserver

from poli import objective_factory

from mlflow_observer import MlFlowObserver

THIS_DIR = Path(__file__).parent.resolve()

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

from pathlib import Path

import mlflow
import numpy as np

Expand Down Expand Up @@ -60,8 +61,6 @@ def initialize_observer(
}
)

mlflow.log_param("x0", x0)
mlflow.log_param("y0", y0)
mlflow.log_param("seed", seed)

def observe(self, x: np.ndarray, y: np.ndarray, context=None) -> None:
Expand Down
Loading

0 comments on commit 84d6ad7

Please sign in to comment.