Skip to main content

Pure-Python client for the sbol-db HTTP API, with a PartShop-compatible facade.

Project description

sbol-db

A pure-Python client for the sbol-db HTTP API, plus a PartShop-compatible facade for code migrating from SynBioHub's pysbol2 PartShop.

The client depends only on httpx. SBOL documents cross the wire as RDF strings; structured records come back as typed dataclasses. There is no SBOL object model and no dependency on pysbol2/pysbol3 or sbol-rs; SBOL2 to SBOL3 conversion happens on the server via the version parameter.

Install

pip install sbol-db
# optional: rdflib, for navigating pulled RDF as a graph
pip install "sbol-db[rdf]"

The import name is sbol_db:

from sbol_db import SbolDbClient, PartShop

Broad client

from sbol_db import SbolDbClient

db = SbolDbClient("http://localhost:8888")

# import a document, search, pull, delete
db.create_graph(open("part.ttl").read(), format="turtle",
                document_iri="https://ex.org/part")
for obj in db.search("pLac", object_type="Component"):
    print(obj.display_id, obj.iri)

rdf = db.export_rdf("https://ex.org/pLac", version="sbol2")   # server converts
rows = db.sparql("SELECT ?s WHERE { ?s ?p ?o } LIMIT 10").bindings()
db.delete_graph_by_document_iri("https://ex.org/part")

PartShop facade

from sbol_db import PartShop

shop = PartShop("http://localhost:8888")
shop.login("dba", "dba")                       # HTTP Basic; getKey() is empty
rdf = shop.pull("https://ex.org/pLac")         # RDF text
shop.submit(rdf, collection="https://ex.org/myCollection", overwrite=1)
print(shop.searchCount("pLac"))

Attachments (attachFile, downloadAttachment) raise NotImplementedError: they are out of scope for sbol-db.

Development

The environment is managed by uv; the dev tools live in a dev dependency group that uv run installs automatically.

make test    # unit tests only (uv run pytest -m "not e2e")
make e2e     # build the sbol-db server, then run the full suite against it
make lint    # isort + black + flake8 + mypy

make e2e builds a fresh sbol-db binary and points the test fixtures at it, so the end-to-end tests never run against a stale build. They boot a real server on a throwaway SQLite database (no external services). To also run them against Postgres:

docker compose up -d postgres          # from the repo root
make e2e SBOL_DB_TEST_BACKENDS=sqlite,postgres

Without a discoverable binary the e2e tests skip, so uv run pytest still runs the unit suite anywhere.

Publishing

The package is built and published with uv. Bump version in pyproject.toml and in src/sbol_db/__init__.py, then:

make build           # sdist + wheel into dist/
make check           # twine check dist/*
make publish         # upload to PyPI (needs a token, see below)

make publish reads a PyPI API token from the environment:

export UV_PUBLISH_TOKEN=pypi-...
make publish

To dry-run against TestPyPI first:

uv publish --publish-url https://test.pypi.org/legacy/ dist/*

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

sbol_db-0.1.0.tar.gz (62.2 kB view details)

Uploaded Source

Built Distribution

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

sbol_db-0.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file sbol_db-0.1.0.tar.gz.

File metadata

  • Download URL: sbol_db-0.1.0.tar.gz
  • Upload date:
  • Size: 62.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.7

File hashes

Hashes for sbol_db-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9b6d684d7b6878b153c7915c923d7b6d90a0d06309c80d965b9391a28a4b06c2
MD5 cb36eac98c7b26cd4c1de22e6c5deb4a
BLAKE2b-256 a48b4d5ddd0a3d869df8e848c0044d3f33d9dfc21a64ca3a7164b4d000db5016

See more details on using hashes here.

File details

Details for the file sbol_db-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sbol_db-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.7

File hashes

Hashes for sbol_db-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7945e2590bfde4942565201cc69b16d28bafbadf2a22b887474ea9f798d8a074
MD5 33316d504c21f276274d2c33720261e4
BLAKE2b-256 d635099fc12d02092fb4e8afb5b17bc14dbe09518b6e82b77a5041a88a039db6

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