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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.18.1"
".": "0.18.2"
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.18.2 (2026-11-24)


### Bug Fixes

* **data:** export the stored prompt metadata as PromptMetadata
* **readme:** show the session.models poet calls

### Deprecations

* **data:** `openprotein.data.prompts.PromptSummary` and `openprotein.data.prompts.schemas.PromptSummary`: use `openprotein.data.PromptMetadata`. The old name still works, warns with a `FutureWarning`, and is removed in 0.19.0.

## 0.18.1 (2026-11-24)


Expand Down
92 changes: 43 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ The OpenProtein.AI Python Interface provides a user-friendly library to interact

# Table of Contents

| | Workflow | Description |
|---|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
| 0 | [`Quick start`](#Quick-start) | Quick start guide |
| 1 | [`Installation`](https://docs.openprotein.ai/python-api/installation.html) | Install guide for pip and conda. |
| 2 | [`Session management`](https://docs.openprotein.ai/python-api/index.html) | An overview of the OpenProtein Python Client & the asynchronous jobs system. |
| 3 | [`Property-Regression-Models`](https://docs.openprotein.ai/python-api/property-regression-models/index.html) | Covers core tasks such as data upload, model training & prediction, and sequence design. |
| 4 | [`De Novo prediction & generative models (PoET)`](https://docs.openprotein.ai/python-api/poet/index.html) | Covers PoET, a protein LLM for *de novo* scoring, as well as sequence generation. |
| 5 | [`Foundational models`](https://docs.openprotein.ai/python-api/foundation-models/index.html) | Covers methods for creating sequence embeddings with proprietary & open-source models. |
| | Workflow | Description |
|---|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| 0 | [`Quick start`](#quick-start) | Quick start guide |
| 1 | [`Installation`](#installation) | Install with pip or conda. |
| 2 | [`Python API reference`](https://docs.openprotein.ai/references/python-api/) | Sessions, jobs and every interface in the Python client. |
| 3 | [`Models`](https://docs.openprotein.ai/references/python-api/models/) | Embedding, scoring, generative and structure models, plus GP, SVD and UMAP. |
| 4 | [`PoET`](https://docs.openprotein.ai/references/python-api/models/#poet) | Score and generate sequences conditioned on a protein family. |
| 5 | [`Tutorials`](https://docs.openprotein.ai/tutorials/) | End-to-end workflows. |


# Quick-start

Get started with our quickstart README! You can peruse the [official documentation](https://docs.openprotein.ai/python-api/) for more details!
Get started with our quickstart README! You can peruse the [official documentation](https://docs.openprotein.ai/quickstart/) for more details!
## Installation

To install the python interface using pip, run the following command:
Expand All @@ -43,7 +43,7 @@ conda install -c openprotein openprotein-python
# Getting started


Read on below for the quick-start guide, or see the [docs](https://docs.openprotein.ai/python-api/) for more information!
Read on below for the quick-start guide, or see the [docs](https://docs.openprotein.ai/references/python-api/) for more information!

To begin, create a session using your login credentials.
```
Expand Down Expand Up @@ -97,69 +97,63 @@ future.rename(name="my-run", description="baseline model")
```

### Resuming Jobs
Jobs from prior workflows can be resumed using the load_job method provided by each API.
Jobs from prior workflows can be resumed by loading them by ID.
```
session.load_job(JOB_ID) # Replace JOB_ID with the ID of the training job to resume
future = session.jobs.get(JOB_ID) # Replace JOB_ID with the ID of the job to resume
```

## PoET interface
The PoET Interface allows scoring, generating, and retrieving sequences using the PoET model.

### Scoring Sequences
To score sequences, use the score function. Provide a prompt and a list of queries. The results will be a list of (sequence, score) pydantic objects.
PoET scores and generates sequences conditioned on a prompt, a set of sequences from the protein family. Model handles are on `session.models`.

### Building a Prompt
Create a prompt from sequences you already have, or sample one from an MSA built by homology search.
```
prompt_seqs = b'MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN'
model = session.models.poet

seed = "MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN"

prompt = session.poet.upload_prompt(prompt_seqs)
prompt = session.prompt.create_prompt([seed])

# or
msa = session.align.create_msa(seed)
prompt = msa.sample_prompt(num_sequences=50)
```

### Scoring Sequences
To score sequences, use `score` with a list of queries and the prompt.
```
queries = [
b'MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN',
b'MALWMRLLPLLVLLALWGPDPASAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN',
b'MALWTRLRPLLALLALWPPPPARAFVNQHLCGSHLVEALYLVCGERGFFYTPKARREVEGPQVGALELAGGPGAGGLEGPPQKRGIVEQCCASVCSLYQLENYCN',
b'MALWIRSLPLLALLVFSGPGTSYAAANQHLCGSHLVEALYLVCGERGFFYSPKARRDVEQPLVSSPLRGEAGVLPFQQEEYEKVKRGIVEQCCHNTCSLYQLENYCN',
b'MALWMRLLPLLALLALWAPAPTRAFVNQHLCGSHLVEALYLVCGERGFFYTPKARREVEDLQVRDVELAGAPGEGGLQPLALEGALQKRGIVEQCCTSICSLYQLENYCN',
"MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN",
"MALWMRLLPLLVLLALWGPDPASAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN",
"MALWTRLRPLLALLALWPPPPARAFVNQHLCGSHLVEALYLVCGERGFFYTPKARREVEGPQVGALELAGGPGAGGLEGPPQKRGIVEQCCASVCSLYQLENYCN",
]
```

```
future = session.poet.score(prompt, queries)
result = future.wait()
# result is a list of (sequence, score) pydantic objects
future = model.score(queries, prompt=prompt)
scores = future.wait()
# one log-likelihood per query, in the order submitted
# a prompt with several replicates gives one score per replicate
```

### Scoring Single Site Variants
For scoring single site variants, use the `single_site function`, providing the original sequence and setting `prompt_is_seed` to True if the prompt is a seed sequence.
To score every single-site substitution of a sequence, use `single_site`.
```
sequence = "MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGPGAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN"
future = session.poet.single_site(prompt, sequence, prompt_is_seed=True)
result = future.wait()
# result is a dictionary of {variant: score}
future = model.single_site(seed, prompt=prompt)
scores = future.wait()
# one score per substitution, 20 per position: positions in sequence order,
# substitutions in the order of openprotein.utils.sequence.AMINO_ACIDS
```

### Generating Sequences
To generate sequences from the PoET model, use the `generate` function with relevant parameters. The result will be a list of generated samples.
To sample new sequences from the prompt, use `generate`.
```
future = session.poet.generate(
prompt,
max_seqs_from_msa=1024,
future = model.generate(
prompt=prompt,
num_samples=100,
temperature=1.0,
topk=15
top_k=15,
)
samples = future.wait()
```

### Retrieving Input Sequences
You can retrieve the prompt, MSA, or seed sequences for a PoET job using the `get_input` function or the individual functions for each type.
```
future.get_input(INPUT_TYPE)
# or, functions for each type
future.get_prompt()
future.get_msa()
future.get_seed()
sequences = future.wait() # generated sequences as strings
scores = future.get(output="loglikelihood") # one log-likelihood per sequence
```

See more at our [Homepage](https://docs.openprotein.ai/)
3 changes: 2 additions & 1 deletion openprotein/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .assaydataset import Assay, AssayDataset
from .data import DataAPI
from .msa import MSA, MSAFormat, MSAMetadata
from .prompts import Prompt
from .prompts import Prompt, PromptMetadata
from .schemas import AssayDataPage, AssayDataRow, AssayMetadata

__all__ = [
Expand All @@ -21,4 +21,5 @@
"MSAFormat",
"MSAMetadata",
"Prompt",
"PromptMetadata",
]
26 changes: 23 additions & 3 deletions openprotein/data/prompts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
"""Client for stored prompts (``session.data.Prompt``)."""
"""Client for stored prompts (``session.data.Prompt``).

.. deprecated:: 0.18.2
``PromptSummary``: use ``openprotein.data.PromptMetadata``.
"""

from typing import Any

from openprotein import _deprecation

from .prompts import Prompt
from .schemas import PromptRecord, PromptSummary
from .schemas import PromptMetadata, PromptRecord

__all__ = [
"Prompt",
"PromptMetadata",
"PromptRecord",
"PromptSummary",
]


def __getattr__(name: str) -> Any:
if name == "PromptSummary":
_deprecation.warn_deprecated(
f"{__name__}.PromptSummary",
"`openprotein.data.PromptMetadata`",
since="0.18.2",
removed_in="0.19.0",
)
return PromptMetadata
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
4 changes: 2 additions & 2 deletions openprotein/data/prompts/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from openprotein.data._reads import read
from openprotein.errors import MissingParameterError

from .schemas import PromptRecord, PromptSummary
from .schemas import PromptMetadata, PromptRecord


class PromptPage(BaseModel):
"""One page of prompt summaries, newest first."""

items: list[PromptSummary]
items: list[PromptMetadata]
next: str | None = None


Expand Down
10 changes: 5 additions & 5 deletions openprotein/data/prompts/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from openprotein.jobs.schemas import Job, JobStatus

from . import _api, _replicates
from .schemas import PromptSummary
from .schemas import PromptMetadata

if TYPE_CHECKING:
from openprotein.align.schemas import MSASamplingMethod
Expand All @@ -33,7 +33,7 @@
_LIST_PAGE = 200


class Prompt(_Resource[PromptSummary]):
class Prompt(_Resource[PromptMetadata]):
"""A stored prompt.

``session.data.Prompt.create`` uploads one, ``session.data.Prompt.list``
Expand All @@ -49,7 +49,7 @@ class Prompt(_Resource[PromptSummary]):
_replicates: builtins.list[builtins.list[str]] | None = None

@classmethod
def _load(cls, session: APISession, id: str) -> PromptSummary:
def _load(cls, session: APISession, id: str) -> PromptMetadata:
return _api.prompts_get(session, id)

@classmethod
Expand All @@ -63,7 +63,7 @@ def _from_job(cls, session: APISession, job: Job) -> Self:
raise
prompt = bound(
session,
PromptSummary(
PromptMetadata(
id=job.job_id,
status=job.status,
job_id=job.job_id,
Expand Down Expand Up @@ -241,7 +241,7 @@ def _sample(
)
return Prompt._for(session)(
session,
PromptSummary(
PromptMetadata(
id=job["job_id"],
status=job["status"],
job_id=job["job_id"],
Expand Down
25 changes: 21 additions & 4 deletions openprotein/data/prompts/schemas.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""Schemas for stored prompts (``session.data.Prompt``)."""
"""Schemas for stored prompts (``session.data.Prompt``).

.. deprecated:: 0.18.2
``PromptSummary``: use ``openprotein.data.PromptMetadata``.
"""

from datetime import datetime
from typing import Any

from pydantic import BaseModel

from openprotein import _deprecation
from openprotein.jobs.schemas import JobStatus

__all__ = ["PromptRecord", "PromptSummary", "PromptUnitValue"]
__all__ = ["PromptMetadata", "PromptRecord", "PromptUnitValue"]


class PromptSummary(BaseModel):
class PromptMetadata(BaseModel):
"""One row as listed, without its replicates.

A row whose job hasn't finished has a ``status`` other than ``SUCCESS`` and
Expand All @@ -34,10 +39,22 @@ class PromptUnitValue(BaseModel):
value: dict[str, Any]


class PromptRecord(PromptSummary):
class PromptRecord(PromptMetadata):
"""One row read in full, carrying each replicate's presigned value.

``value`` is ``None`` until the row's job has produced the replicates.
"""

value: list[PromptUnitValue] | None = None


def __getattr__(name: str) -> Any:
if name == "PromptSummary":
_deprecation.warn_deprecated(
f"{__name__}.PromptSummary",
"`openprotein.data.PromptMetadata`",
since="0.18.2",
removed_in="0.19.0",
)
return PromptMetadata
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
46 changes: 46 additions & 0 deletions tests/data/test_prompt_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import importlib

import pytest

import openprotein.data
from openprotein.data import PromptMetadata

MODULES = ["openprotein.data.prompts", "openprotein.data.prompts.schemas"]


@pytest.mark.parametrize("module", MODULES)
def test_prompt_summary_resolves_to_prompt_metadata_and_warns(module):
with pytest.warns(FutureWarning) as record:
resolved = importlib.import_module(module).PromptSummary
assert resolved is PromptMetadata
assert [str(w.message) for w in record] == [
(
f"`{module}.PromptSummary` is deprecated since 0.18.2 and will be removed "
"in 0.19.0. Use `openprotein.data.PromptMetadata`."
)
]
assert record[0].filename == __file__


def test_from_import_of_prompt_summary_warns():
with pytest.warns(FutureWarning, match="openprotein.data.prompts.PromptSummary"):
from openprotein.data.prompts import PromptSummary # noqa: F401


def test_prompt_metadata_is_exported_beside_its_siblings():
assert {"AssayMetadata", "MSAMetadata", "PromptMetadata"} <= set(
openprotein.data.__all__
)
assert (
"PromptMetadata" in importlib.import_module("openprotein.data.prompts").__all__
)
assert (
"PromptSummary"
not in importlib.import_module("openprotein.data.prompts").__all__
)


@pytest.mark.parametrize("module", MODULES)
def test_an_unknown_name_raises_attribute_error(module):
with pytest.raises(AttributeError, match="NoSuchName"):
_ = importlib.import_module(module).NoSuchName
Loading
Loading