Skip to content

Commit

Permalink
Improve build and installation process (#69)
Browse files Browse the repository at this point in the history
* Update installation to rely only on pyproject and setup.py

* Update readthedocs settings

* Change to python github actions

* Correct error ci.yml

* Switch to only using poetry

* Update Github action to use setup-poetry

* Ensure action installs poetry dependencies'

* Upgrade gryffin

* Fix installation and build

* Fix readthedocs install

* Wipe build env on readthdocs and downgrade python ver

* Update README.md with badges and fix typo in pyproject.toml

* Update README

* Finish redo of Github actions workflow to include test,build & publish

* Correct ci.yml

* Test publish step

* Comment out pytest

* Move get_version to main folder

* Add job dependency

* Bump version in preparation for new release and clean up README

* Enable automated insertion of open in colab badge
  • Loading branch information
marcosfelt authored Sep 12, 2020
1 parent e9dc6ca commit bc5ab90
Show file tree
Hide file tree
Showing 20 changed files with 1,566 additions and 460 deletions.
84 changes: 71 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,79 @@
name: Run Tests
name: Test & Publish
on: [push]

jobs:
pytest:
name: pytest
#Run pytest and build package
test_build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Install
uses: abatilo/actions-poetry@v1.5.0
- name: Checkout repository
uses: actions/checkout@v2

- name: Install python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install poetry
uses: Gr1N/setup-poetry@v3

- name: Cache poetry dependencies
uses: actions/cache@v1
with:
python_version: 3.7.7
poetry_version: 1.0.10
args: install -E experiments
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
run: poetry install -E experiments

- name: Run pytest
uses: abatilo/actions-poetry@v1.5.0
run: poetry run pytest --doctest-modules --ignore=case_studies --ignore=experiments

- name: Build package
run: poetry build

- name: Save build
uses: actions/upload-artifact@v2
with:
name: ${{ github.sha }}-build
path: dist/


# Publish to pypi on version change
publish:
needs: test_build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
# Make sure to fetch the last two commits
# Needed forthe version bump and tag
fetch-depth: 2

- name: Install toml
run: pip install toml

- name: Check for version bump and tag
id: version_check
uses: salsify/action-detect-and-tag-new-version@v2
with:
python_version: 3.7.7
poetry_version: 1.0.10
args: run python -m pytest --doctest-modules --ignore=case_studies --ignore=experiments
create-tag: $ {{ github.ref == 'refs/heads/master' }} # only create new tag on master
version-command: |
python get_version.py
- name: Download poetry build
uses: actions/download-artifact@v2
with:
name: ${{ github.sha }}-build

- name: Install poetry
uses: Gr1N/setup-poetry@v3

- name: Publish
# Only publish if there is a new tag
if: ${{ steps.version_check.tag }}
run: poetry publish -u {{ secrets.PYPI_USERNAME }} -p {{ $ secrets.PYPI_PASSWORD }}
20 changes: 20 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py


# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.6
install:
- method: pip
path: .
extra_requirements:
- docs
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2020 Kobi Felton, Jan Rittig, Alexei Lapkin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 11 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Summit
![summit_banner](docs/source/_static/banner_4.png)
![summit_banner](https://raw.githubusercontent.com/sustainable-processes/summit/master/docs/source/_static/banner_4.png)

<p align="center">
<a href='https://gosummit.readthedocs.io/en/latest/?badge=latest'>
<img src='https://readthedocs.org/projects/gosummit/badge/?version=latest' alt='Documentation Status' />
</a>
<a href="https://pypi.org/project/nsummit/"><img alt="PyPI" src="https://img.shields.io/pypi/v/summit"></a>
</p>

Summit is a set of tools for optimising chemical processes. We’ve started by targeting reactions.

## What is Summit?
Currently, reaction optimisation in the fine chemicals industry is done by intuition or design of experiments, Both scale poorly with the complexity of the problem.
Currently, reaction optimisation in the fine chemicals industry is done by intuition or design of experiments. Both scale poorly with the complexity of the problem.

Summit uses recent advances in machine learning to make the process of reaction optimisation faster. Essentially, it applies algorithms that learn which conditions (e.g., temperature, stoichiometry, etc.) are important to maximising one or more objectives (e.g., yield, enantiomeric excess). This is achieved through an iterative cycle.

Expand All @@ -15,26 +22,15 @@ Summit has two key features:

To get started, see the Quick Start below or follow our [tutorial](https://gosummit.readthedocs.io/en/latest/tutorial.html).

Currently, Summit has the following strategies implemented:

- **TSEMO**: Multi-objective Bayesian optimisation strategy by [Bradford et al.]()
- **Gryffin**: Single-objective Bayesian optimisation strategy designed for categoical variables [Häse et al.](https://arxiv.org/abs/2003.12127)
- **SOBO**: Single-objective Bayesian optimisation strategy ([GpyOpt](https://gpyopt.readthedocs.io/))
- **Nelder-Mead**: Single-objective optimisation stategy for local search
- **SNOBFIT**: Single-objective optimisation strategy by [Huyer et al.](https://www.mat.univie.ac.at/~neum/ms/snobfit.pdf)
- **Deep Raction Optimiser**: Deep reinforcement learning by [Zhou et al.](https://pubs.acs.org/doi/10.1021/acscentsci.7b00492)
- **Factorial DoE**: Factorial design of experiments
- **Random**: Random search

## Installation

To install summit, use the following command:

```pip install git+https://github.com/sustainable-processes/summit.git@0.5.0#egg=summit```
```pip install summit```

## Quick Start

Below, we show how to use the Nelder-Mead strategy to optimise a benchmark representing a nucleophlic aromatic substitution (SnAr) reaction.
Below, we show how to use the Nelder-Mead strategy to optimise a benchmark representing a nucleophlic aromatic substitution (SnAr) reaction.
```python
# Import summit
from summit.benchmarks import SnarBenchmark, MultitoSingleObjective
Expand Down Expand Up @@ -67,4 +63,3 @@ The documentation for summit can be found [here](https://gosummit.readthedocs.io
## Issues?
Submit an [issue](https://github.com/sustainable-processes/summit/issues) or send an email to kcmf2@cam.ac.uk.


107 changes: 0 additions & 107 deletions README.rst

This file was deleted.

29 changes: 29 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
import os
import sys
import subprocess

sys.path.insert(0, os.path.abspath("../.."))

Expand Down Expand Up @@ -56,6 +57,34 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# -- Google Colab badge -------------------------------------------------
COLAB = "https://colab.research.google.com/github"


def get_current_git_branch():
branch = subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True)
branch = str(branch).replace("\\n", "").replace("b", "").replace("'", "")
return branch


def get_colab_base_link(
user="sustainable-processes", repo="summit", docs_path="docs/source"
):
branch = get_current_git_branch()
return f"{COLAB}/{user}/{repo}/blob/{branch}/{docs_path}"


badge_link = "https://colab.research.google.com/assets/colab-badge.svg"
nbsphinx_prolog = r"""
{%% set docname = env.doc2path(env.docname, base=None) %%}
.. role:: raw-html(raw)
:format: html
.. |colab_badge| replace:: :raw-html:`<a href="%s/{{ docname }}"><img src="%s" alt="Open in colab"/></a>`
""" % (
get_colab_base_link(),
badge_link,
)

# -- Options for NBShpinx ----------------------------------------------------

Expand Down
22 changes: 17 additions & 5 deletions docs/source/experiments_benchmarks/new_benchmarks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@
"source": [
"## Google Colab\n",
"\n",
"If you would like to follow along with this tutorial, you can open it in Google Colab using the button below.\n",
"\n",
"{{ badge }}\n",
"\n",
"If you would like to follow along with this tutorial, you can open it in Google Colab using the button below."
]
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
"|colab_badge|"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You will need to run the following cell to make sure Summit and all its dependencies are installed. If prompted, restart the runtime."
]
},
Expand All @@ -28,7 +40,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install git+https://github.com/sustainable-processes/summit.git#egg=summit"
"!pip install summit"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Summit is a set of tools for optimising chemical processes. We’ve started by t

What is Summit?
##################
Currently, reaction optimisation in the fine chemicals industry is done by intuition or design of experiments, Both scale poorly with the complexity of the problem.
Currently, reaction optimisation in the fine chemicals industry is done by intuition or design of experiments. Both scale poorly with the complexity of the problem.

Summit uses recent advances in machine learning to make the process of reaction optimisation faster. Essentially, it applies algorithms that learn which conditions (e.g., temperature, stoichiometry, etc.) are important to maximising one or more objectives (e.g., yield, enantiomeric excess). This is achieved through an iterative cycle.

Expand Down
Loading

0 comments on commit bc5ab90

Please sign in to comment.