Skip to content

Commit

Permalink
fix: expose train script in pypi (#20)
Browse files Browse the repository at this point in the history
* refactor: only use pip, remove conda

* ci: add workflow to push to pypi on release

* fix: make train script available when installed using pip

* fix: bump ci python to 3.8

* fix: macos-14 does not have python version <3.10 so use macos13

* fix: bump python to 3.10, remove loader.py, train_baseline.py

* deps: remove tensorflow and deepchem deps

* fix: python version shall be string

* fix: test macos-13 again

* ci: run ci

* chore: bump version to 1.0.0
  • Loading branch information
fiskrt authored May 17, 2024
1 parent 7653dae commit 7d5c501
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 946 deletions.
24 changes: 5 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- os: ubuntu-20.04
pip_cache_path: ~/.cache/pip
experimental: false
- os: macos-latest
- os: macos-13
pip_cache_path: ~/Library/Caches/pip
experimental: false
defaults:
Expand All @@ -28,39 +28,25 @@ jobs:
- name: Checkout and setup python
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: '3.10'
architecture: 'x64'

- name: Cache conda
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir # from: conda-incubator/setup-miniconda@v2
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('conda.yml') }}

- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ matrix.pip_cache_path }}
key: ${{ runner.os }}-pip--${{ env.CACHE_NUMBER }}-${{
hashFiles('requirements.txt') }}

- name: Conda environment setup
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: toxsmi
environment-file: conda.yml
auto-activate-base: false
use-only-tar-bz2: true # This needs to be set for proper caching
auto-update-conda: true # Required for windows for `use-only-tar-bz2`

- name: Install dependencies and test code
run: |
pip3 install --no-cache-dir -r requirements.txt
pip3 install --no-deps .
python3 -c "import toxsmi"
python3 scripts/train_baselines.py -h
python3 scripts/train_tox.py -h
python3 scripts/train_tox -h
chmod +x scripts/train_tox
scripts/train_tox -h
- name: Send Slack notification
uses: 8398a7/action-slack@v2
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/push_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --skip-existing dist/*
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ print(f"Clinical toxicitiy predictions: {clintox('CCO')}")
### Setup
The library itself has few dependencies (see [setup.py](setup.py)) with loose requirements.
```sh
conda env create -f conda.yml
conda activate toxsmi
pip install -e .
```

### Start a training

In the `scripts` directory is a training script [train_tox.py](./scripts/train_tox.py).
In the `scripts` directory is a training script [train_tox](./scripts/train_tox).

Download sample data from the Tox21 database and store it in a folder called `data`
[here](https://ibm.box.com/s/kahxnlg2k2s0x3z0r5fa6y67tmfhs6or).

```console
(toxsmi) $ python3 scripts/train_tox.py \
(toxsmi) $ python3 scripts/train_tox \
--train data/tox21_train.csv \
--test data/tox21_score.csv \
--smi data/tox21.smi \
Expand All @@ -64,7 +62,7 @@ Download sample data from the Tox21 database and store it in a folder called `da
- Set ```--finetune``` to the path to a `.pt` file to start from a pretrained model
- Set ```--embedding_path``` to the path of pretrained embeddings

Type `python scripts/train_tox.py -h` for further help.
Type `python scripts/train_tox -h` for further help.

### Evaluate a model
In the `scripts` directory is an evaluation script [eval_tox.py](./scripts/eval_tox.py).
Expand Down
19 changes: 0 additions & 19 deletions conda.yml

This file was deleted.

9 changes: 4 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
paccmann_predictor @ git+https://github.com/PaccMann/paccmann_predictor@sarscov2
numpy>=1.14.3
torch>=1.5.1
deepchem>=2.4
six>=1.15.0
torch
six
scikit-learn>=0.21.3
tensorflow>=2.0
Pillow>=7.1.0
brc_pytorch>=0.1.3
pytoda>=1.1.2
rdkit
pytoda>=1.1.5
2 changes: 1 addition & 1 deletion scripts/eval_tox.py → scripts/eval_tox
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#! /usr/bin/env python3
"""Test toxsmi predictor."""
import argparse
import glob
Expand Down
109 changes: 0 additions & 109 deletions scripts/train_baselines.py

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/train_tox.py → scripts/train_tox
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#! /usr/bin/env python3
"""Train toxsmi predictor."""
import argparse
import json
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ def get_version(rel_path):
author_email=("jab@zurich.ibm.com, greta.markert@gmail.com, drugilsberg@gmail.com"),
install_requires=[
"paccmann_predictor @ git+https://github.com/PaccMann/paccmann_predictor",
"numpy>=1.14.3",
"torch",
"deepchem",
"tensorflow>=2.0",
"Pillow",
"six",
"scikit-learn>=0.21.3",
"brc_pytorch>=0.1.3",
"pytoda>=1.1.2",
"rdkit"
],
packages=find_packages("."),
zip_safe=False,
scripts=['scripts/train_tox', 'scripts/eval_tox']
)
2 changes: 1 addition & 1 deletion toxsmi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Initialization for `toxsmi` module."""
__version__ = "0.0.3"
__version__ = "1.0.0"
__name__ = "toxsmi"
3 changes: 0 additions & 3 deletions toxsmi/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from .hyperparams import LOSS_FN_FACTORY # noqa
from .loaders import load_organdb_github # noqa
from .loaders import load_organdb_suppl # noqa
from .loaders import load_tox21 # noqa
from .utils import * # noqa
Loading

0 comments on commit 7d5c501

Please sign in to comment.