Skip to content

Commit

Permalink
Updated Dockerfile and README.md for LatentGAN (molecularsets#70)
Browse files Browse the repository at this point in the history
* updated Dockerfile for LatentGAN

* updated README

* add rdkit version

* remove rdkit from external installation script

* TF 1.14

* pip instead of conda
  • Loading branch information
danpol authored Feb 6, 2020
1 parent 7e366c2 commit 58a18e2
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
28 changes: 20 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ ENV DEBIAN_FRONTEND noninteractive
ENV TERM linux

RUN mkdir /moses
COPY . /moses

RUN set -ex \
&& apt-get update -yqq \
&& apt-get upgrade -yqq \
&& apt-get install -yqq --no-install-recommends \
git wget curl ssh libxrender1 libxext6 software-properties-common apt-utils \
&& wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh \
&& /bin/bash Miniconda3-4.6.14-Linux-x86_64.sh -f -b -p /opt/miniconda \
&& wget --no-check-certificate https://repo.continuum.io/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh \
&& /bin/bash Miniconda3-4.7.12.1-Linux-x86_64.sh -f -b -p /opt/miniconda \
&& add-apt-repository ppa:git-core/ppa \
&& (curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash) \
&& apt-get install git-lfs \
&& git lfs install \
&& apt-get clean \
&& /opt/miniconda/bin/conda install conda=4.6.14=py36_0 \
&& /opt/miniconda/bin/conda install conda=4.8.1=py37_0 \
&& /opt/miniconda/bin/conda clean -yq -a \
&& rm Miniconda3-4.6.14-Linux-x86_64.sh \
&& rm Miniconda3-4.7.12.1-Linux-x86_64.sh \
&& rm -rf \
/tmp/* \
/var/tmp/* \
Expand All @@ -29,10 +28,23 @@ RUN set -ex \
/usr/share/doc-base

ENV PATH /opt/miniconda/bin:$PATH
RUN conda install -yq numpy=1.16.0 scipy=1.2.0 matplotlib=3.0.1 pandas=0.25 scikit-learn=0.20.3 tqdm>=4.26.0 \
&& conda install -yq -c rdkit rdkit=2019.03.2 \
RUN conda install -yq numpy=1.16.0 scipy=1.2.0 matplotlib=3.0.1 \
pandas=0.25 scikit-learn=0.20.3 tqdm>=4.26.0 \
&& conda install -yq -c rdkit rdkit=2019.09.3 \
&& conda install -yq -c pytorch pytorch=1.1.0 torchvision=0.2.1 \
&& conda clean -yq -a
&& conda clean -yq -a \
&& pip install tensorflow-gpu==1.14

RUN git clone https://github.com/pcko1/Deep-Drug-Coder.git --branch moses \
&& cd Deep-Drug-Coder \
&& python setup.py install \
&& cd .. \
&& git clone https://github.com/EBjerrum/molvecgen.git \
&& cd molvecgen \
&& python setup.py install \
&& cd ..

COPY . /moses

WORKDIR /moses
RUN python setup.py install && git lfs pull && conda clean -yq -a && rm -rf .git/lfs
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ For comparison of molecular properties, we computed the Frèchet distance betwee
# Installation

### PyPi
The simplest way to install MOSES (models and metrics) is to install [RDKit](https://www.rdkit.org/docs/Install.html): `conda install -yq -c rdkit rdkit` and then install MOSES (`molsets`) from pip (`pip install molsets`).
The simplest way to install MOSES (models and metrics) is to install [RDKit](https://www.rdkit.org/docs/Install.html): `conda install -yq -c rdkit rdkit` and then install MOSES (`molsets`) from pip (`pip install molsets`). If you want to use LatentGAN, you should also install additional dependencies using `bash install_latentgan_dependencies.sh`.

If you are using Ubuntu, you should also install `sudo apt-get install libxrender1 libxext6` for RDKit.

Expand Down Expand Up @@ -238,6 +238,11 @@ git clone https://github.com/molecularsets/moses.git
python setup.py install
```

4. (Optional) Install dependencies for LatentGAN:
```bash
bash install_latentgan_dependencies.sh
```


# Benchmarking your models

Expand Down
8 changes: 2 additions & 6 deletions install_moses.sh → install_latentgan_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash
# A script to install everything needed to run MOSES in a new environment
conda create -n moses_env python=3.6
eval "$(conda shell.bash hook)"
conda activate moses_env
set -e
git clone https://github.com/pcko1/Deep-Drug-Coder.git --branch moses
cd Deep-Drug-Coder
python setup.py install
Expand All @@ -11,6 +9,4 @@ git clone https://github.com/EBjerrum/molvecgen.git
cd molvecgen
python setup.py install
cd ..
conda install tensorflow-gpu==1.12
conda install -c conda-forge rdkit
python setup.py install
pip install tensorflow-gpu==1.14
2 changes: 1 addition & 1 deletion moses/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2'
__version__ = '0.2.1'
3 changes: 2 additions & 1 deletion moses/latentgan/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import torch.nn as nn
import numpy as np
import torch
from ddc_pub import ddc_v3 as ddc
import os
from rdkit import Chem
import sys
Expand Down Expand Up @@ -120,6 +119,8 @@ def sample(self, n_batch, max_length=100):


def load_model(model_version=None):
from ddc_pub import ddc_v3 as ddc

# Import model
currentDirectory = os.getcwd()

Expand Down
3 changes: 1 addition & 2 deletions moses/latentgan/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from .model import load_model
from .model import Sampler
from rdkit import Chem
from ddc_pub import ddc_v3 as ddc


class LatentGANTrainer(MosesTrainer):
Expand Down Expand Up @@ -159,7 +158,7 @@ def fit(self,
model,
train_data,
val_data=None):

from ddc_pub import ddc_v3 as ddc
self.generator = model.Generator
self.discriminator = model.Discriminator
cuda = True if torch.cuda.is_available() else False
Expand Down
1 change: 1 addition & 0 deletions scripts/run_all_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ for MODEL in char_rnn vae aae
do
for SEED in 1 2 3
do
mkdir -p checkpoints/$MODEL/$MODEL\_$SEED
python scripts/run.py \
--model $MODEL \
--data data \
Expand Down

0 comments on commit 58a18e2

Please sign in to comment.