Skip to content

Commit 5b9a85c

Browse files
committed
tests
1 parent e0dad8f commit 5b9a85c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2373
-205
lines changed

.github/workflows/push.yml

+30-30
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,36 @@ jobs:
1414
with:
1515
name: "python-package-distributions"
1616
path: "dist/"
17-
# pytest:
18-
# strategy:
19-
# matrix:
20-
# platform:
21-
# - "macos-latest"
22-
# - "ubuntu-latest"
23-
# # - "windows-latest"
24-
# python:
25-
# - "3.10"
26-
# - "3.11"
27-
# runs-on: ${{ matrix.platform }}
28-
# steps:
29-
# - uses: "actions/checkout@v4"
30-
# - uses: "actions/setup-python@v5"
31-
# with:
32-
# python-version: ${{ matrix.python }}
33-
# - run: "python -m pip install -r requirements.in"
34-
# - run: "python -m pip install -r requirements-dev.in"
35-
# - run: "python -m pip install --editable ."
36-
# - run: "python -m pytest"
37-
# - env:
38-
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39-
# uses: "codecov/codecov-action@v3"
17+
pytest:
18+
strategy:
19+
matrix:
20+
platform:
21+
- "macos-latest"
22+
- "ubuntu-latest"
23+
# - "windows-latest"
24+
python:
25+
- "3.10"
26+
- "3.11"
27+
runs-on: ${{ matrix.platform }}
28+
steps:
29+
- uses: "actions/checkout@v4"
30+
- uses: "actions/setup-python@v5"
31+
with:
32+
python-version: ${{ matrix.python }}
33+
- run: "python -m pip install -r requirements.in"
34+
- run: "python -m pip install -r requirements-dev.in"
35+
- run: "python -m pip install --editable ."
36+
- run: "python -m pytest"
37+
- env:
38+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
39+
uses: "codecov/codecov-action@v3"
40+
ruff:
41+
runs-on: "ubuntu-latest"
42+
steps:
43+
- uses: "actions/checkout@v4"
44+
- uses: "chartboost/ruff-action@v1"
45+
with:
46+
args: "format --check"
4047
# pypi:
4148
# environment:
4249
# name: "pypi.org"
@@ -74,13 +81,6 @@ jobs:
7481
# - env:
7582
# GITHUB_TOKEN: "${{ github.token }}"
7683
# run: "gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}'"
77-
# ruff:
78-
# runs-on: "ubuntu-latest"
79-
# steps:
80-
# - uses: "actions/checkout@v4"
81-
# - uses: "chartboost/ruff-action@v1"
82-
# with:
83-
# args: "format --check"
8484
# testpypi:
8585
# environment:
8686
# name: "test.pypi.org"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
**L**anguage models for **B**iological **S**equence **T**ransformation and **E**volutionary **R**epresentation
33

44

5-
`lobster` is a "batteries included" language model library for proteins and other biological sequences. Led by [Nathan Frey](https://github.com/ncfrey), [Taylor Joren](https://github.com/taylormjs), [Aya Abdlesalam Ismail](https://github.com/ayaabdelsalam91), and [Allen Goodman](https://github.com/0x00b1), with many valuable contributions from [Contributors](docs/CONTRIBUTORS.md) across [Prescient Design, Genentech](https://www.gene.com/scientists/our-scientists/prescient-design).
5+
`lobster` is a "batteries included" language model library for proteins and other biological sequences. Led by [Nathan Frey](https://github.com/ncfrey), [Taylor Joren](https://github.com/taylormjs), [Aya Abdlesalam Ismail](https://github.com/ayaabdelsalam91), [Joseph Kleinhenz](https://github.com/kleinhenz) and [Allen Goodman](https://github.com/0x00b1), with many valuable contributions from [Contributors](docs/CONTRIBUTORS.md) across [Prescient Design, Genentech](https://www.gene.com/scientists/our-scientists/prescient-design).
66

77
This repository contains code and access to pre-trained language models for biological sequence data.
88

docs/CONTRIBUTORS.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
* Karina Zadorozhny
2-
* Joseph Kleinhenz
32
* Matthieu Kirchmeyer
43
* Sai Pooja Mahajan
54
* Amy Wang

src/lobster/data/_cyno_pk_datamodule.py

-173
This file was deleted.

tests/__init__.py

Whitespace-only changes.

tests/lobster/__init__.py

Whitespace-only changes.

tests/lobster/cmdline/__init__.py

Whitespace-only changes.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import subprocess
2+
3+
4+
class TestLobsterCmdline:
5+
def test_train(self):
6+
output = subprocess.check_output("lobster_train -h", shell=True)
7+
8+
output = output.splitlines()
9+
10+
assert output[0] == b"_train is powered by Hydra."
11+
12+
assert len(output) > 1
13+
14+
def test_embed(self):
15+
output = subprocess.check_output("lobster_embed -h", shell=True)
16+
output = output.splitlines()
17+
18+
assert output[0] == b"_embed is powered by Hydra."
19+
20+
assert len(output) > 1

tests/lobster/conftest.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import logging
2+
3+
import pytest
4+
from lobster.data import NegLogDataModule
5+
6+
7+
@pytest.fixture(autouse=True)
8+
def configure_logging():
9+
logger = logging.getLogger()
10+
logger.setLevel(logging.DEBUG)
11+
for handler in logger.handlers:
12+
handler.setLevel(logging.DEBUG)
13+
14+
15+
@pytest.fixture(scope="session")
16+
def ppi_datamodule(tmp_path_factory):
17+
root = tmp_path_factory.mktemp("neglog")
18+
return NegLogDataModule(
19+
root=root,
20+
download=False,
21+
lengths=[0.7, 0.2, 0.1],
22+
truncation_seq_length=50,
23+
)

tests/lobster/data/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import pytest
2+
import torch
3+
from lobster.data import CalmLightningDataModule
4+
from lobster.model import LobsterPMLM
5+
from torch import Size
6+
7+
8+
@pytest.fixture(autouse=True)
9+
def dm(tmp_path):
10+
datamodule = CalmLightningDataModule(
11+
root="/data/bucket/freyn6/data/",
12+
batch_size=8,
13+
lengths=(0.8, 0.1, 0.1),
14+
train=False,
15+
download=False,
16+
)
17+
datamodule.setup(stage="fit")
18+
19+
return datamodule
20+
21+
22+
@pytest.mark.skip(reason="Need to mock.")
23+
class TestCalmLightningDataModule:
24+
def test_setup(self, dm: CalmLightningDataModule):
25+
assert len(dm._train_dataset) == 3481
26+
assert len(dm._val_dataset) == 435
27+
assert len(dm._test_dataset) == 435
28+
29+
batch, _targets = next(iter(dm.train_dataloader()))
30+
31+
assert batch["input_ids"].shape == Size([8, 1, 512])
32+
assert batch["attention_mask"].shape == Size([8, 1, 512])
33+
assert batch["labels"].shape == Size([8, 1, 512])
34+
35+
model = LobsterPMLM(model_name="MLM_mini", max_length=2048)
36+
model.eval()
37+
38+
batch, _targets = next(iter(dm.train_dataloader()))
39+
40+
with torch.inference_mode():
41+
loss, _ = model._compute_loss(batch)
42+
43+
assert isinstance(loss, torch.Tensor)

0 commit comments

Comments
 (0)