Skip to content

Commit 507432d

Browse files
committed
Release v0.8.2
- release rfdiffusion interface - fixes problems with refactored fit umap, svd, predictor - a lot of docstrings updated
1 parent 9872fe5 commit 507432d

33 files changed

+1179
-339
lines changed

anaconda_build/meta.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: openprotein-python
3-
version: "0.8.0"
3+
version: "0.8.2"
44

55
source:
66
path: ../
@@ -14,10 +14,12 @@ requirements:
1414
build:
1515
- python >=3.10,<3.13
1616
- hatchling >=1.25.0,<2
17+
- hatch-vcs >=0.5.0,<1
1718
host:
1819
- python >=3.10,<3.13
1920
- pip
2021
- hatchling >=1.25.0,<2
22+
- hatch-vcs >=0.5.0,<1
2123
run:
2224
- python >=3.10,<3.13
2325
- requests >=2.32.3,<3

openprotein/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from openprotein.prompt import PromptAPI
1818
from openprotein.embeddings import EmbeddingsAPI
1919
from openprotein.fold import FoldAPI
20+
from openprotein.models import ModelsAPI
2021
from openprotein.svd import SVDAPI
2122
from openprotein.umap import UMAPAPI
2223
from openprotein.predictor import PredictorAPI
@@ -40,6 +41,7 @@ class OpenProtein(APISession):
4041
_fold = None
4142
_predictor = None
4243
_design = None
44+
_models = None
4345

4446
def wait(self, future: Future, *args, **kwargs):
4547
return future.wait(*args, **kwargs)
@@ -149,5 +151,14 @@ def fold(self) -> FoldAPI:
149151
self._fold = FoldAPI(self)
150152
return self._fold
151153

154+
@property
155+
def models(self) -> "ModelsAPI":
156+
"""
157+
The models submodule provides a unified entry point to all protein models.
158+
"""
159+
if self._models is None:
160+
self._models = ModelsAPI(self)
161+
return self._models
162+
152163

153164
connect = OpenProtein

openprotein/_version.py

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,48 @@
1-
try:
1+
"""Compute the version number and store it in the `__version__` variable.
2+
3+
Based on <https://github.com/maresb/hatch-vcs-footgun-example>.
4+
"""
5+
6+
7+
def _get_hatch_version():
8+
"""Compute the most up-to-date version number in a development environment.
9+
10+
Returns `None` if Hatchling is not installed, e.g. in a production environment.
11+
12+
For more details, see <https://github.com/maresb/hatch-vcs-footgun-example/>.
13+
"""
14+
import os
15+
16+
try:
17+
from hatchling.metadata.core import ProjectMetadata
18+
from hatchling.plugin.manager import PluginManager
19+
from hatchling.utils.fs import locate_file
20+
except ImportError:
21+
# Hatchling is not installed, so probably we are not in
22+
# a development environment.
23+
return None
24+
25+
pyproject_toml = locate_file(__file__, "pyproject.toml")
26+
if pyproject_toml is None:
27+
raise RuntimeError("pyproject.toml not found although hatchling is installed")
28+
root = os.path.dirname(pyproject_toml)
29+
metadata = ProjectMetadata(root=root, plugin_manager=PluginManager())
30+
# Version can be either statically set in pyproject.toml or computed dynamically:
31+
return metadata.core.version or metadata.hatch.version.cached
32+
33+
34+
def _get_importlib_metadata_version():
35+
"""Compute the version number using importlib.metadata.
36+
37+
This is the official Pythonic way to get the version number of an installed
38+
package. However, it is only updated when a package is installed. Thus, if a
39+
package is installed in editable mode, and a different version is checked out,
40+
then the version number will not be updated.
41+
"""
242
from importlib.metadata import version
3-
except ModuleNotFoundError:
4-
from importlib_metadata import version # type: ignore - py37
543

6-
try:
7-
__version__ = version("openprotein-python")
8-
except:
9-
__version__ = "None"
44+
__version__ = version(__package__) # type: ignore
45+
return __version__
46+
47+
48+
__version__ = _get_hatch_version() or _get_importlib_metadata_version()

openprotein/align/msa.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,6 @@
2222
class MSAFuture(AlignFuture, Future):
2323
"""
2424
Represents a future for MSA (Multiple Sequence Alignment) results.
25-
26-
Parameters
27-
----------
28-
session : APISession
29-
An instance of APISession for API interactions.
30-
job : MSAJob
31-
The MSA job.
32-
page_size : int, optional
33-
The number of results to fetch in a single page. Defaults to config.POET_PAGE_SIZE.
34-
35-
Attributes
36-
----------
37-
session : APISession
38-
An instance of APISession for API interactions.
39-
job : MSAJob | MafftJob | ClustalOJob | AbNumberJob
40-
The MSA job.
41-
page_size : int
42-
The number of results to fetch in a single page.
43-
msa_id : str
44-
The job ID for the MSA.
45-
46-
Methods
47-
-------
48-
get(verbose=False)
49-
Retrieve the MSA of the job as an iterator over CSV rows.
50-
sample_prompt(...)
51-
Create a protein sequence prompt from the linked MSA for PoET Jobs.
5225
"""
5326

5427
job: MSAJob | MafftJob | ClustalOJob | AbNumberJob

openprotein/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, token):
2727
self.token = token
2828

2929
def __call__(self, r):
30-
r.headers["authorization"] = "Bearer " + self.token
30+
r.headers["Authorization"] = "Bearer " + self.token
3131
return r
3232

3333

openprotein/embeddings/embeddings.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,32 @@ class EmbeddingsAPI:
4343

4444
# added for static typing, eg pylance, for autocomplete
4545
# at init these are all overwritten.
46+
47+
#: PoET-2 model
48+
poet2: PoET2Model
49+
#: PoET model
50+
poet: PoETModel
51+
#: Prot-seq model
4652
prot_seq: OpenProteinModel
53+
#: Rotaprot model trained on UniRef50
4754
rotaprot_large_uniref50w: OpenProteinModel
55+
#: Rotaprot model trained on UniRef90
4856
rotaprot_large_uniref90_ft: OpenProteinModel
49-
poet: PoETModel
5057
poet_2: PoET2Model
51-
poet2: PoET2Model
5258

59+
#: ESM1b model
5360
esm1b: ESMModel # alias
5461
esm1b_t33_650M_UR50S: ESMModel
5562

63+
#: ESM1v model
5664
esm1v: ESMModel # alias
5765
esm1v_t33_650M_UR90S_1: ESMModel
5866
esm1v_t33_650M_UR90S_2: ESMModel
5967
esm1v_t33_650M_UR90S_3: ESMModel
6068
esm1v_t33_650M_UR90S_4: ESMModel
6169
esm1v_t33_650M_UR90S_5: ESMModel
6270

71+
#: ESM2 model
6372
esm2: ESMModel # alias
6473
esm2_t12_35M_UR50D: ESMModel
6574
esm2_t30_150M_UR50D: ESMModel

openprotein/embeddings/esm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""Community-based ESM models."""
22

3-
from .models import EmbeddingModel
3+
from .models import AttnModel, EmbeddingModel
44

55

6-
class ESMModel(EmbeddingModel):
6+
class ESMModel(AttnModel, EmbeddingModel):
77
"""
88
Class providing inference endpoints for Facebook's ESM protein language models.
99
@@ -13,9 +13,9 @@ class ESMModel(EmbeddingModel):
1313
1414
.. code-block:: python
1515
16-
>>> import openprotein
17-
>>> session = openprotein.connect(username="user", password="password")
18-
>>> session.embedding.esm2_t12_35M_UR50D?
16+
>>> import openprotein
17+
>>> session = openprotein.connect(username="user", password="password")
18+
>>> session.embedding.esm2_t12_35M_UR50D?
1919
"""
2020

2121
model_id = [

openprotein/embeddings/future.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ def sequences(self) -> list[bytes] | list[str]:
6363
def id(self):
6464
return self.job.job_id
6565

66-
def keys(self):
66+
def __keys__(self):
67+
"""
68+
Get the list of sequences submitted for the embed request.
69+
70+
Returns
71+
-------
72+
list of bytes
73+
List of sequences.
74+
"""
6775
return self.sequences
6876

6977
def get_item(self, sequence: bytes) -> np.ndarray:

0 commit comments

Comments
 (0)