Skip to content

Commit

Permalink
Merge pull request #3 from basf/implement_chemprop_regression
Browse files Browse the repository at this point in the history
adapt to chemprop 2.0.0 structure and implement remaining predictors
  • Loading branch information
c-w-feldmann committed Apr 25, 2024
2 parents f8144ac + c7a4bff commit e7d736c
Show file tree
Hide file tree
Showing 11 changed files with 574 additions and 152 deletions.
67 changes: 66 additions & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install $(find . -name "requirement*" -type f -printf ' -r %p')
pip install mypy
mypy . || exit_code=$?
mypy --install-types --non-interactive
Expand Down Expand Up @@ -148,3 +147,69 @@ jobs:
- name: Analysing the code with isort
run: |
isort --profile black .
test_basis:
needs:
- pylint
- mypy
- pydocstyle
- docsig
- black
- flake8
- interrogate
- bandit
- isort
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
pip install .
- name: Run unit-tests
run: |
python -m unittest discover -v -s tests -t .
test_chemprop:
needs:
- test_basis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install package
run: |
python -m pip install --upgrade pip
pip install torch
pip install .[chemprop]
- name: Run unit-tests for chemprop
run: |
python -m unittest discover -v -s test_extras/test_chemprop -t .
test_notebooks:
needs:
- test_basis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install package
run: |
python -m pip install --upgrade pip
pip install .[notebooks]
- name: Run unit-tests for notebooks
run: |
python test_extras/test_notebooks/test_notebooks.py --continue-on-failure
56 changes: 0 additions & 56 deletions .github/workflows/unittests.yml

This file was deleted.

21 changes: 14 additions & 7 deletions molpipeline/estimators/chemprop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"""Initialize Chemprop module."""

import pkgutil
try:
from molpipeline.estimators.chemprop.models import ( # noqa: F401
ChempropClassifier,
ChempropModel,
ChempropNeuralFP,
ChempropRegressor,
)

installed_packages = {pkg.name for pkg in pkgutil.iter_modules()}
if "chemprop" in installed_packages:
from molpipeline.estimators.chemprop.models import ChempropModel # noqa

__all__ = ["ChempropModel"]
else:
__all__ = [
"ChempropClassifier",
"ChempropModel",
"ChempropNeuralFP",
"ChempropRegressor",
]
except ImportError:
__all__ = []
4 changes: 2 additions & 2 deletions molpipeline/estimators/chemprop/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy.typing as npt

try:
from chemprop.data import MoleculeDataset, MolGraphDataLoader
from chemprop.data import MoleculeDataset, build_dataloader
from chemprop.models.model import MPNN
from lightning import pytorch as pl
except ImportError:
Expand Down Expand Up @@ -90,7 +90,7 @@ def fit(
if y.ndim == 1:
y = y.reshape(-1, 1)
X.Y = y
training_data = MolGraphDataLoader(
training_data = build_dataloader(
X, batch_size=self.batch_size, num_workers=self.n_jobs
)
self.lightning_trainer.fit(self.model, training_data)
Expand Down
Loading

0 comments on commit e7d736c

Please sign in to comment.