Skip to content

Commit 2c45937

Browse files
committed
Add GitHub workflows
Change version number Add two workflows that run tests on the dev and master branches and added some shields to the README.md file.
1 parent bf69345 commit 2c45937

File tree

7 files changed

+98
-9
lines changed

7 files changed

+98
-9
lines changed

.github/workflows/test_dev.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Tests (dev)
5+
6+
on:
7+
push:
8+
branches: [ "dev" ]
9+
pull_request:
10+
branches: [ "dev" ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install flake8 pytest
31+
python -m pip install -e .
32+
- name: Lint with flake8
33+
run: |
34+
# stop the build if there are Python syntax errors or undefined names
35+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
- name: Test with pytest
39+
run: |
40+
pytest

.github/workflows/test_master.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Tests (master)
5+
6+
on:
7+
push:
8+
branches: [ "master"]
9+
pull_request:
10+
branches: [ "master"]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install flake8 pytest
31+
python -m pip install -e .
32+
- name: Lint with flake8
33+
run: |
34+
# stop the build if there are Python syntax errors or undefined names
35+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
- name: Test with pytest
39+
run: |
40+
pytest

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# Fréchet ChemNet Distance
2+
![PyPI](https://img.shields.io/pypi/v/fcd)
3+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fcd)
4+
![Tests (master)](https://github.com/bioinf-jku/fcd/actions/workflows/test_master.yml/badge.svg?branch=dev)
5+
![Tests (dev)](https://github.com/bioinf-jku/fcd/actions/workflows/test_dev.yml/badge.svg?branch=dev)
6+
![PyPI - Downloads](https://img.shields.io/pypi/dm/fcd)
7+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/bioinf-jku/fcd)
8+
![GitHub release date](https://img.shields.io/github/release-date/bioinf-jku/fcd)
9+
![GitHub](https://img.shields.io/github/license/bioinf-jku/fcd)
10+
211

312
Code for the paper "Fréchet ChemNet Distance: A Metric for Generative Models for Molecules in Drug Discovery"
413
[JCIM](https://pubs.acs.org/doi/10.1021/acs.jcim.8b00234) /

fcd/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
"canonical_smiles",
1212
]
1313

14-
__version__ = "1.2"
14+
__version__ = "1.2.1"

fcd/fcd.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_predictions(
5050
smiles_list: List[str],
5151
batch_size: int = 128,
5252
n_jobs: int = 1,
53-
device: str | None = None,
53+
device: Optional[str] = None,
5454
) -> np.ndarray:
5555
"""Calculate Chemnet activations
5656
@@ -81,7 +81,7 @@ def get_predictions(
8181
return np.row_stack(chemnet_activations)
8282

8383

84-
def get_fcd(smiles1: List[str], smiles2: List[str], model: nn.Module | None = None, device=None) -> float:
84+
def get_fcd(smiles1: List[str], smiles2: List[str], model: Optional[nn.Module] = None, device=None) -> float:
8585
"""Calculate FCD between two sets of Smiles
8686
8787
Args:

fcd/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import warnings
33
from contextlib import contextmanager
44
from multiprocessing import Pool
5-
from typing import List
5+
from typing import List, Optional
66

77
import numpy as np
88
import torch
@@ -43,7 +43,7 @@ def tokenize(smiles: str) -> List[str]:
4343
return tok_smile
4444

4545

46-
def get_one_hot(smiles: str, pad_len: int | None = None) -> np.ndarray:
46+
def get_one_hot(smiles: str, pad_len: Optional[int] = None) -> np.ndarray:
4747
"""Generate one-hot representation of a Smiles string.
4848
4949
Args:

test/test_fcd.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import pytest
21
import numpy as np
2+
import pytest
3+
from pytest import approx
34

45
from fcd import get_fcd
5-
from fcd.utils import get_one_hot, SmilesDataset
6-
from pytest import approx
6+
from fcd.utils import SmilesDataset, get_one_hot
77

88

99
class TestFCD:
@@ -12,7 +12,7 @@ def test_random_smiles_cpu(self):
1212
smiles_list2 = ["ISi#()", "Si#()+", "#()+-", "()+-1"]
1313
target = 8.8086
1414
fcd = get_fcd(smiles_list1, smiles_list2, device="cpu")
15-
assert fcd == approx(target, abs=1e-3)
15+
assert fcd == approx(target, abs=1e-2)
1616

1717
def test_random_smiles_gpu(self):
1818
# Skip test if CUDA is not available

0 commit comments

Comments
 (0)