Skip to content

Commit

Permalink
[DGL-LifeSci] Final release preparation for 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeili authored Apr 2, 2020
1 parent 00efec6 commit 0ee9f56
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 49 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ DGL is an easy-to-use, high performance and scalable Python package for deep lea

**A data scientist** may want to apply a pre-trained model to your data right away. For this you can use DGL's [Application packages, formally *Model Zoo*](https://github.com/dmlc/dgl/tree/master/apps). Application packages are developed for domain applications, as is the case for [DGL-LifeScience](https://github.com/dmlc/dgl/tree/master/apps/life_sci). We will soon add model zoo for knowledge graph embedding learning and recommender systems. Here's how you will use a pretrained model:
```python
from dgl.data.chem import Tox21, smiles_to_bigraph, CanonicalAtomFeaturizer
from dgl import model_zoo
from dgllife.data import Tox21
from dgllife.model import load_pretrained
from dgllife.utils import smiles_to_bigraph, CanonicalAtomFeaturizer

dataset = Tox21(smiles_to_bigraph, CanonicalAtomFeaturizer())
model = model_zoo.chem.load_pretrained('GCN_Tox21') # Pretrained model loaded
model = load_pretrained('GCN_Tox21') # Pretrained model loaded
model.eval()

smiles, g, label, mask = dataset[0]
feats = g.ndata.pop('h')
label_pred = model(g, feats)
print(smiles) # CCOc1ccc2nc(S(N)(=O)=O)sc2c1
print(label_pred[:, mask != 0]) # Mask non-existing labels
# tensor([[ 1.4190, -0.1820, 1.2974, 1.4416, 0.6914,
# 2.0957, 0.5919, 0.7715, 1.7273, 0.2070]])
```

**Further reading**: DGL is released as a managed service on AWS SageMaker, see the medium posts for an easy trip to DGL on SageMaker([part1](https://medium.com/@julsimon/a-primer-on-graph-neural-networks-with-amazon-neptune-and-the-deep-graph-library-5ce64984a276) and [part2](https://medium.com/@julsimon/deep-graph-library-part-2-training-on-amazon-sagemaker-54d318dfc814)).
Expand Down
89 changes: 64 additions & 25 deletions apps/life_sci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,68 @@ featurization, and evaluation, model architectures, training scripts and pre-tra

**For a full list of work implemented in DGL-LifeSci, see [here](examples/README.md).**

## Installation

### Requirements

DGL-LifeSci should work on

* all Linux distributions no earlier than Ubuntu 16.04
* macOS X
* Windows 10

DGL-LifeSci requires python 3.6+, DGL 0.4.3+ and PyTorch 1.2.0+.

Additionally, we require `RDKit 2018.09.3` for cheminformatics. We recommend installing it with

```
conda install -c conda-forge rdkit==2018.09.3
```

For other installation recipes for RDKit, see the [official documentation](https://www.rdkit.org/docs/Install.html).

### Pip installation for DGL-LifeSci

```
pip install dgllife
```

### Conda installation for DGL-LifeSci

```
conda install -c dglteam dgllife
```

### Installation from source

If you want to try experimental features, you can install from source as follows:

```
git clone https://github.com/dmlc/dgl.git
cd apps/life_sci/python
python setup.py install
```

### Verifying successful installation

Once you have installed the package, you can verify the success of installation with

```python
import dgllife

print(dgllife.__version__)
# 0.2.1
```

If you are new to DGL, the first time you import dgl a message will pop up as below:

```
DGL does not detect a valid backend option. Which backend would you like to work with?
Backend choice (pytorch, mxnet or tensorflow):
```

and you need to enter `pytorch`.

## Example Usage

To apply graph neural networks to molecules with DGL, we need to first construct `DGLGraph` --
Expand Down Expand Up @@ -78,7 +140,8 @@ print(label_pred[:, mask != 0]) # Mask non-existing labels
# 2.0957, 0.5919, 0.7715, 1.7273, 0.2070]])
```

Similarly, we can load a pre-trained model for generating molecules.
Similarly, we can load a pre-trained model for generating molecules. If possible, we recommend running
the code block below with Jupyter notebook.

```python
from dgllife.model import load_pretrained
Expand Down Expand Up @@ -108,30 +171,6 @@ SVG(Draw.MolsToGridImage(mols, molsPerRow=4, subImgSize=(180, 150), useSVG=True)
```

![](https://data.dgl.ai/dgllife/dgmg/dgmg_model_zoo_example2.png)

## Installation

DGL-LifeSci requires python 3.5+, DGL 0.4.3+ and PyTorch 1.2.0+.

Additionally, we require `RDKit 2018.09.3` for cheminformatics. We recommend installing it with
`conda install -c conda-forge rdkit==2018.09.3`. For other installation recipes,
see the [official documentation](https://www.rdkit.org/docs/Install.html).

We provide installation of `DGL-LifeSci` with pip. Once you have installed the package,
verify the success of installation with

```python
import dgllife

print(dgllife.__version__)
# 0.2.0
```

### Using pip

```
pip install dgllife
```

## Speed Reference

Expand Down
5 changes: 1 addition & 4 deletions apps/life_sci/conda/dgllife/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
git submodule init
git submodule update --recursive
cd python
$PYTHON setup.py install --single-version-externally-managed --record=record.txt
$PYTHON setup.py install --single-version-externally-managed --record=record.txt # Python command to install the script.
1 change: 0 additions & 1 deletion apps/life_sci/conda/dgllife/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
python:
- 3.5
- 3.6
- 3.7
17 changes: 7 additions & 10 deletions apps/life_sci/conda/dgllife/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package:
name: dgllife{{ environ.get('APP_PACKAGE_SUFFIX', '') }}
version: "0.2.0"
version: "0.2.1"

source:
git_rev: 0.2.0
git_url: https://github.com/dmlc/dgl/tree/master/apps/dgllife
url: https://files.pythonhosted.org/packages/7d/ca/543802eca0e8d263a73309379f79a054b3bb7e7377ead0b69d2451728465/dgllife-0.2.1.tar.gz
sha256: 11a1622ba587f7ff67f42ad8bc88d238faaa459ab554cf59e1b69a10079d41c0

requirements:
build:
Expand All @@ -19,12 +19,9 @@ requirements:
- scikit-learn
- pandas
- tqdm

test:
imports:
- dgllife
- numpy
- scipy
- networkx

about:
home: https://github.com/dmlc/dgl/tree/master/apps/dgllife
license_file: {{ environ.get('SRC_DIR') }}/LICENSE
license: Apache
license: Apache
4 changes: 3 additions & 1 deletion apps/life_sci/python/dgllife/libinfo.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""Information for the library."""
__version__ = '0.2.0'

# current version
__version__ = '0.2.1'
9 changes: 5 additions & 4 deletions apps/life_sci/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ def get_lib_path():
'life-science',
'drug-discovery'
],
zip_safe=False,
maintainer='DGL Team',
packages=[package for package in find_packages()
if package.startswith('dgllife')],
install_requires=[
'torch>=1.1'
'scikit-learn>=0.22.2',
'pandas>=0.24.2',
'pandas',
'requests>=2.22.0',
'tqdm'
'tqdm',
'numpy>=1.14.0',
'scipy>=1.1.0',
'networkx>=2.1',
],
url='https://github.com/dmlc/dgl/tree/master/apps/life_sci',
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion apps/life_sci/python/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import re

__version__ = "0.2.0"
__version__ = "0.2.1"
print(__version__)

# Implementations
Expand Down

0 comments on commit 0ee9f56

Please sign in to comment.