Skip to main content

BioLM Python client for the hosted platform and biolm-hub

Project description

https://img.shields.io/pypi/v/biolm.svg https://api.travis-ci.com/BioLM/py-biolm.svg?branch=production Documentation Status

Python client and SDK for BioLM

Install the package:

pip install biolm

Open-source models (biolm-hub):

# In biolm-hub: bh serve
biolm hub set
biolm model list
biolm model run esm2-8m encode -i seq.json

See docs/cli/hub.rst.

Basic usage:

from biolm import biolm

# Encode a single sequence
result = biolm(entity="esm2-8m", action="encode", type="sequence", items="MSILVTRPSPAGEEL")

# Predict a batch of sequences
result = biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"])

# Write results to disk
biolm(entity="esmfold", action="predict", type="sequence", items=["SEQ1", "SEQ2"], output='disk', file_path="results.jsonl")

Asynchronous usage:

from biolm.core.http import BioLMApiClient
import asyncio

async def main():
    model = BioLMApiClient("esmfold")
    result = await model.predict(items=[{"sequence": "MDNELE"}])
    print(result)

asyncio.run(main())

Overview

The BioLM Python client provides a high-level, user-friendly interface for interacting with the BioLM API. It supports both synchronous and asynchronous usage, automatic batching, flexible error handling, and efficient processing of biological data.

Main features:

  • High-level BioLM constructor for quick requests

  • Sync and async interfaces

  • Automatic or custom rate limiting/throttling

  • Schema-based batch size detection

  • Flexible input formats (single key + list, or list of dicts)

  • Low memory usage via generators

  • Flexible error handling (raise, continue, or stop on error)

  • Universal HTTP client for both sync and async

Features

  • High-level constructor: Instantly run an API call with a single line.

  • Sync and async: Use BioLM for sync, or BioLMApiClient for async.

  • Flexible rate limiting: Use API throttle, disable, or set your own (e.g., ‘1000/second’).

  • Schema-based batching: Automatically queries API for max batch size.

  • Flexible input: Accepts a single key and list, or list of dicts, or list of lists for advanced batching.

  • Low memory: Uses generators for validation and batching.

  • Error handling: Raise HTTPX errors, continue on error, or stop on first error.

  • Disk output: Write results as JSONL to disk.

  • Universal HTTP client: Efficient for both sync and async.

  • Direct access to schema and batching: Use BioLMApi for advanced workflows, including .schema(), .call(), and ._batch_call_autoschema_or_manual().

Example endpoints and actions:

  • esm2-8m/encode: Embedding for protein sequences.

  • esmfold/predict: Structure prediction for protein sequences.

  • progen2-oas/generate: Sequence generation from a context string.

  • dnabert2/predict: Masked prediction for protein sequences.

  • ablang2/encode: Embeddings for paired-chain antibodies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biolm_sdk-0.0.1.tar.gz (4.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biolm_sdk-0.0.1-py2.py3-none-any.whl (258.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file biolm_sdk-0.0.1.tar.gz.

File metadata

  • Download URL: biolm_sdk-0.0.1.tar.gz
  • Upload date:
  • Size: 4.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for biolm_sdk-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ef035913d474df22c8367a9c623999b94bd74ef5ab7a3831394a61bde5ed3d20
MD5 cc0267ffe0db417d4fadc90f5316625c
BLAKE2b-256 1a3b6643eb39f7828228e78fb73e885ab609eeb24945a2ebaaf398578e1906e5

See more details on using hashes here.

File details

Details for the file biolm_sdk-0.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: biolm_sdk-0.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 258.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for biolm_sdk-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f8504cd6820bb3465872c0c1ec8b81de15857708b5e7d0fb077b99f60243338d
MD5 45332ee5c24822c13016d57e8513d7a6
BLAKE2b-256 b81c3037dd799702e359917279afa7a492f27efaa5ed4ebcec0bbaab42092266

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page