Commit 02d19741 authored by VIGNESHinZONE's avatar VIGNESHinZONE
Browse files

setting torch environment

parent 1097a8ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ jobs:
    - name: PyTest
      if: ${{ (success() || failure()) && (steps.install.outcome == 'failure' || steps.install.outcome == 'success') }}
      shell: bash -l {0}
      run: pytest -v -m "not slow and not jax" --cov=deepchem --cov-report=xml deepchem
      run: pytest -v -m "not slow and not jax and not torch" --cov=deepchem --cov-report=xml deepchem
    - name: Upload coverage to Codecov
      if: ${{ (success() || failure()) && (steps.install.outcome == 'failure' || steps.install.outcome == 'success') }}
      uses: codecov/codecov-action@v1
+136 −0
Original line number Diff line number Diff line
name: Test for DeepChem Jax
on:
  push: # ci work when pushing master branch
    branches:
      - master
  pull_request: # ci work when creating a PR to master branch
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: [3.7]
    steps:
    - uses: actions/checkout@v2
    - name: Cache pip modules for Linux
      uses: actions/cache@v2
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('env.*.yml') }}
        restore-keys: |
          ${{ runner.os }}-pip-
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Build DeepChem
      run: |
        python -m pip install --upgrade pip
        pip install -e '.[torch]'
    - name: Import checking
      run: python -c "import deepchem; import torch;"

  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        python-version: [3.7]
        include:
          - os: ubuntu-latest
            python-version: 3.6
    env:
      OS: ${{ matrix.os }}
      PYTHON_VERSION: ${{ matrix.python-version }}
    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    # https://github.com/galaxyproject/tools-iuc/blob/master/.github/workflows/pr.yaml
    # The range of commits to check for changes is:
    # - for events on the master branch we compare against the sha before the event
    #   (note that this does not work for feature branch events since we want all
    #   commits on the feature branch and not just the commits of the last event)
    # - for pull requests we compare against the 1st ancestor, given the current
    #   HEAD is the merge between the PR branch and the base branch
    - name: Set commit range (push to the master branch, e.g. merge)
      if: github.ref == 'refs/heads/master' && github.event_name == 'push'
      run: echo "COMMIT_RANGE=${{ github.event.before }}.." >> $GITHUB_ENV
    - name: Set commit range (pull request)
      if: github.event_name == 'pull_request'
      run: |
        git fetch origin master
        echo "COMMIT_RANGE=origin/master..." >> $GITHUB_ENV
    - name: Cache pip packages for Linux
      if: runner.os == 'Linux'
      uses: actions/cache@v2
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('env.*.yml') }}
        restore-keys: |
          ${{ runner.os }}-pip-
    - name: Cache pip packages for MacOS
      if: runner.os == 'macOS'
      uses: actions/cache@v2
      with:
        path: ~/Library/Caches/pip
        key: ${{ matrix.os }}-pip-${{ hashFiles('env.*.yml') }}
        restore-keys: |
          ${{ runner.os }}-pip-
    - name: Cache pip packages for Windows
      if: runner.os == 'Windows'
      uses: actions/cache@v2
      with:
        path: ~\AppData\Local\pip\Cache
        key: ${{ matrix.os }}-pip-${{ hashFiles('env.*.yml') }}
        restore-keys: |
          ${{ runner.os }}-pip-
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Create env.yml
      shell: bash
      run: |
        python -m pip install --upgrade pip;
        pip install conda-merge;
        if [ "$(uname)" == 'Darwin' ]; then
          conda-merge requirements/deepchem-torch/env_torch.yml requirements/deepchem-torch/env_torch.cpu.yml env.test.yml > env.yml
        else
          conda-merge env_jax.yml env.test.yml > env.yml
        fi;
    - name: Install all dependencies
      uses: conda-incubator/setup-miniconda@v2
      with:
        miniconda-version: "latest"
        auto-update-conda: true
        activate-environment: deepchem
        channels: omnia,conda-forge,defaults
        python-version: ${{ matrix.python-version }}
        environment-file: env.yml
    - name: Install DeepChem
      id: install
      shell: bash -l {0}
      run: pip install -e '.[torch]'
    - name: Yapf (version 0.22.0)
      id: yapf
      # on Windows, yapf raise the strange error..., so ignore
      if: runner.os == 'Linux' || runner.os == 'macOS'
      shell: bash -l {0}
      run: |
        CHANGED_FILES=`git diff --name-only $COMMIT_RANGE | grep .py$ | grep -v contrib/ || true`
        if [ -n "$CHANGED_FILES" ]; then
          yapf -d $CHANGED_FILES
        fi
    - name: Flake8
      if: ${{ (success() || failure()) && (steps.install.outcome == 'failure' || steps.install.outcome == 'success') }}
      shell: bash -l {0}
      run: source scripts/flake8_for_ci.sh
    - name: PyTest
      if: ${{ (success() || failure()) && (steps.install.outcome == 'failure' || steps.install.outcome == 'success') }}
      shell: bash -l {0}
      run: pytest -v -m torch deepchem
+4 −7
Original line number Diff line number Diff line
import unittest
import tempfile
import pytest

import numpy as np

@@ -17,8 +17,7 @@ except:
  has_torch_and_dgl = False


@unittest.skipIf(not has_torch_and_dgl,
                 'PyTorch, DGL, or DGL-LifeSci are not installed')
@pytest.mark.torch
def test_attentivefp_regression():
  # load datasets
  featurizer = MolGraphConvFeaturizer(use_edges=True)
@@ -48,8 +47,7 @@ def test_attentivefp_regression():
  model.fit(train_set, nb_epoch=1)


@unittest.skipIf(not has_torch_and_dgl,
                 'PyTorch, DGL, or DGL-LifeSci are not installed')
@pytest.mark.torch
def test_attentivefp_classification():
  # load datasets
  featurizer = MolGraphConvFeaturizer(use_edges=True)
@@ -84,8 +82,7 @@ def test_attentivefp_classification():
  model.fit(train_set, nb_epoch=1)


@unittest.skipIf(not has_torch_and_dgl,
                 'PyTorch, DGL, or DGL-LifeSci are not installed')
@pytest.mark.torch
def test_attentivefp_reload():
  # load datasets
  featurizer = MolGraphConvFeaturizer(use_edges=True)
+4 −4
Original line number Diff line number Diff line
import unittest
import pytest
import tempfile
from os import path, remove

@@ -17,7 +17,7 @@ except:
  has_pytorch_and_dgl = False


@unittest.skipIf(not has_pytorch_and_dgl, 'PyTorch and DGL are not installed')
@pytest.mark.torch
def test_cgcnn_regression():
  # load datasets
  current_dir = path.dirname(path.abspath(__file__))
@@ -53,7 +53,7 @@ def test_cgcnn_regression():
    remove(path.join(current_dir, 'perovskite.json'))


@unittest.skipIf(not has_pytorch_and_dgl, 'PyTorch and DGL are not installed')
@pytest.mark.torch
def test_cgcnn_classification():
  # load datasets
  current_dir = path.dirname(path.abspath(__file__))
@@ -95,7 +95,7 @@ def test_cgcnn_classification():
    remove(path.join(current_dir, 'mp_is_metal.json'))


@unittest.skipIf(not has_pytorch_and_dgl, 'PyTorch and DGL are not installed')
@pytest.mark.torch
def test_cgcnn_reload():
  # load datasets
  current_dir = path.dirname(path.abspath(__file__))
+4 −7
Original line number Diff line number Diff line
import unittest
import pytest
import tempfile

import numpy as np
@@ -17,8 +17,7 @@ except:
  has_torch_and_dgl = False


@unittest.skipIf(not has_torch_and_dgl,
                 'PyTorch, DGL, or DGL-LifeSci are not installed')
@pytest.mark.torch
def test_gat_regression():
  # load datasets
  featurizer = MolGraphConvFeaturizer()
@@ -54,8 +53,7 @@ def test_gat_regression():
  model.fit(train_set, nb_epoch=1)


@unittest.skipIf(not has_torch_and_dgl,
                 'PyTorch, DGL, or DGL-LifeSci are not installed')
@pytest.mark.torch
def test_gat_classification():
  # load datasets
  featurizer = MolGraphConvFeaturizer()
@@ -92,8 +90,7 @@ def test_gat_classification():
  model.fit(train_set, nb_epoch=1)


@unittest.skipIf(not has_torch_and_dgl,
                 'PyTorch, DGL, or DGL-LifeSci are not installed')
@pytest.mark.torch
def test_gat_reload():
  # load datasets
  featurizer = MolGraphConvFeaturizer()
Loading