Skip to content

Commit 7d5c501

Browse files
authored
fix: expose train script in pypi (#20)
* 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
1 parent 7653dae commit 7d5c501

12 files changed

+42
-946
lines changed

.github/workflows/build.yml

+5-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- os: ubuntu-20.04
1414
pip_cache_path: ~/.cache/pip
1515
experimental: false
16-
- os: macos-latest
16+
- os: macos-13
1717
pip_cache_path: ~/Library/Caches/pip
1818
experimental: false
1919
defaults:
@@ -28,39 +28,25 @@ jobs:
2828
- name: Checkout and setup python
2929
uses: actions/setup-python@v2
3030
with:
31-
python-version: 3.6
31+
python-version: '3.10'
3232
architecture: 'x64'
3333

34-
- name: Cache conda
35-
uses: actions/cache@v2
36-
with:
37-
path: ~/conda_pkgs_dir # from: conda-incubator/setup-miniconda@v2
38-
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
39-
hashFiles('conda.yml') }}
40-
4134
- name: Cache pip
4235
uses: actions/cache@v2
4336
with:
4437
path: ${{ matrix.pip_cache_path }}
4538
key: ${{ runner.os }}-pip--${{ env.CACHE_NUMBER }}-${{
4639
hashFiles('requirements.txt') }}
4740

48-
- name: Conda environment setup
49-
uses: conda-incubator/setup-miniconda@v2
50-
with:
51-
activate-environment: toxsmi
52-
environment-file: conda.yml
53-
auto-activate-base: false
54-
use-only-tar-bz2: true # This needs to be set for proper caching
55-
auto-update-conda: true # Required for windows for `use-only-tar-bz2`
56-
5741
- name: Install dependencies and test code
5842
run: |
5943
pip3 install --no-cache-dir -r requirements.txt
6044
pip3 install --no-deps .
6145
python3 -c "import toxsmi"
6246
python3 scripts/train_baselines.py -h
63-
python3 scripts/train_tox.py -h
47+
python3 scripts/train_tox -h
48+
chmod +x scripts/train_tox
49+
scripts/train_tox -h
6450
6551
- name: Send Slack notification
6652
uses: 8398a7/action-slack@v2

.github/workflows/push_pypi.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-python@v2
13+
- name: Install dependencies
14+
run: |
15+
python -m pip install --upgrade pip
16+
pip install setuptools wheel twine
17+
- name: Build and publish
18+
env:
19+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
20+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
21+
run: |
22+
python setup.py sdist bdist_wheel
23+
twine upload --skip-existing dist/*

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ print(f"Clinical toxicitiy predictions: {clintox('CCO')}")
3838
### Setup
3939
The library itself has few dependencies (see [setup.py](setup.py)) with loose requirements.
4040
```sh
41-
conda env create -f conda.yml
42-
conda activate toxsmi
4341
pip install -e .
4442
```
4543

4644
### Start a training
4745

48-
In the `scripts` directory is a training script [train_tox.py](./scripts/train_tox.py).
46+
In the `scripts` directory is a training script [train_tox](./scripts/train_tox).
4947

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

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

67-
Type `python scripts/train_tox.py -h` for further help.
65+
Type `python scripts/train_tox -h` for further help.
6866

6967
### Evaluate a model
7068
In the `scripts` directory is an evaluation script [eval_tox.py](./scripts/eval_tox.py).

conda.yml

-19
This file was deleted.

requirements.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
paccmann_predictor @ git+https://github.com/PaccMann/paccmann_predictor@sarscov2
22
numpy>=1.14.3
3-
torch>=1.5.1
4-
deepchem>=2.4
5-
six>=1.15.0
3+
torch
4+
six
65
scikit-learn>=0.21.3
7-
tensorflow>=2.0
86
Pillow>=7.1.0
97
brc_pytorch>=0.1.3
10-
pytoda>=1.1.2
8+
rdkit
9+
pytoda>=1.1.5

scripts/eval_tox.py scripts/eval_tox

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#! /usr/bin/env python3
22
"""Test toxsmi predictor."""
33
import argparse
44
import glob

scripts/train_baselines.py

-109
This file was deleted.

scripts/train_tox.py scripts/train_tox

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#! /usr/bin/env python3
22
"""Train toxsmi predictor."""
33
import argparse
44
import json

setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ def get_version(rel_path):
3030
author_email=("jab@zurich.ibm.com, greta.markert@gmail.com, drugilsberg@gmail.com"),
3131
install_requires=[
3232
"paccmann_predictor @ git+https://github.com/PaccMann/paccmann_predictor",
33+
"numpy>=1.14.3",
3334
"torch",
34-
"deepchem",
35-
"tensorflow>=2.0",
3635
"Pillow",
3736
"six",
37+
"scikit-learn>=0.21.3",
3838
"brc_pytorch>=0.1.3",
3939
"pytoda>=1.1.2",
40+
"rdkit"
4041
],
4142
packages=find_packages("."),
4243
zip_safe=False,
44+
scripts=['scripts/train_tox', 'scripts/eval_tox']
4345
)

toxsmi/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Initialization for `toxsmi` module."""
2-
__version__ = "0.0.3"
2+
__version__ = "1.0.0"
33
__name__ = "toxsmi"

toxsmi/utils/__init__.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
from .hyperparams import LOSS_FN_FACTORY # noqa
2-
from .loaders import load_organdb_github # noqa
3-
from .loaders import load_organdb_suppl # noqa
4-
from .loaders import load_tox21 # noqa
52
from .utils import * # noqa

0 commit comments

Comments
 (0)