Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ name: Python package

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.11", "3.13"]
python-version: ["3.10", "3.12", "3.13"]

steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest sentencepiece rdkit
python -m pip install git+https://github.com/novonordisk-research/pepfunn.git
python -m pip install .
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv pip install flake8 pytest sentencepiece rdkit --system
uv pip install git+https://github.com/novonordisk-research/pepfunn.git --system
uv pip install . "transformers<5" --system
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
5 changes: 4 additions & 1 deletion autopeptideml/reps/lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
os.environ['TOKENIZERS_PARALLELISM'] = 'False'

import numpy as np
from packaging.version import parse as V
import torch
import transformers
from transformers import AutoModel, AutoTokenizer, T5Tokenizer, T5EncoderModel

from typing import *

from .engine import RepEngineBase
Expand Down Expand Up @@ -200,7 +202,8 @@ def _load_model(self, model: str):
elif 'ankh' in model.lower():
self.lab = 'ElnaggarLab'
elif 'molformer' in model.lower():
print("Warning: Molformer does not support transformers>=5.0.0, we recommend using an earlier version, e.g., transformers==4.41.2")
if V(transformers.__version__) >= V('5.0.0'):
print("Warning: Molformer does not support transformers>=5.0.0, we recommend using an earlier version, e.g., transformers==4.41.2")
self.lab = 'ibm'
elif 'chemberta' in model.lower():
self.lab = 'DeepChem'
Expand Down
7 changes: 7 additions & 0 deletions tests/test_reps.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def test_rostlab_family():
assert np.array(a).shape == (1, re.dim())


def test_molformer_family():
re = RepEngineLM('molformer-xl')
a = re.compute_reps(['C[C@H](N)C(=O)N[C@@H](CCCNC(=N)N)C(=O)N[C@H]'], batch_size=12)
assert re.dim() == 768
assert np.array(a).shape == (1, re.dim())


if __name__ == '__main__':
test_esm_family()
print('ESM OK')
Expand Down