Skip to main content

Ultra-lightweight durable execution in Python

Project description

DBOS Transact: Ultra-Lightweight Durable Execution

Documentation   •   Examples   •   Github   •   Discord


DBOS Transact is a Python library providing ultra-lightweight durable execution. For example:

@DBOS.step()
def step_one():
    ...

@DBOS.step()
def step_two():
    ...

@DBOS.workflow()
def workflow()
    step_one()
    step_two()

Durable execution means your program is resilient to any failure. If it is ever interrupted or crashes, all your workflows will automatically resume from the last completed step. If you want to see durable execution in action, check out this demo app (source code here). No matter how many times you try to crash it, it always resumes from exactly where it left off!

Under the hood, DBOS Transact works by storing your program's execution state (which workflows are currently executing and which steps they've completed) in a Postgres database. So all you need to use it is a Postgres database to connect to—there's no need for a "workflow server." This approach is also incredibly fast, for example 25x faster than AWS Step Functions.

Some more cool features include:

  • Scheduled jobs—run your workflows exactly-once per time interval.
  • Exactly-once event processing—use workflows to process incoming events (for example, from a Kafka topic) exactly-once.
  • Observability—all workflows automatically emit OpenTelemetry traces.

Getting Started

Install and configure with:

pip install dbos
dbos init --config

Then, try it out with this simple program (requires Postgres):

from fastapi import FastAPI
from dbos import DBOS

app = FastAPI()
DBOS(fastapi=app)

@DBOS.step()
def step_one():
    print("Step one completed!")

@DBOS.step()
def step_two():
    print("Step two completed!")

@DBOS.workflow()
def dbos_workflow():
    step_one()
    for _ in range(5):
        print("Press Control + \ to stop the app...")
        DBOS.sleep(1)
    step_two()

@app.get("/")
def fastapi_endpoint():
    dbos_workflow()

Save the program into main.py, edit dbos-config.yaml to configure your Postgres connection settings, and start it with fastapi run. Visit localhost:8000 in your browser to start the workflow. When prompted, press Control + \ to force quit your application. It should crash midway through the workflow, having completed step one but not step two. Then, restart your app with fastapi run. It should resume the workflow from where it left off, completing step two without re-executing step one.

To learn how to build more complex workflows, see our programming guide or examples.

Documentation

https://docs.dbos.dev

Examples

  • AI-Powered Slackbot — A Slackbot that answers questions about previous Slack conversations, using DBOS to durably orchestrate its RAG pipeline.
  • Widget Store — An online storefront that uses DBOS durable workflows to be resilient to any failure.
  • Earthquake Tracker — A real-time earthquake dashboard that uses DBOS to stream data from the USGS into Postgres, then visualizes it with Streamlit.

More examples here!

Community

If you're interested in building with us, please star our repository and join our community on Discord! If you see a bug or have a feature request, don't hesitate to open an issue here on GitHub. If you're interested in contributing, check out our contributions guide.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

dbos-0.13.0a2.tar.gz (104.1 kB view details)

Uploaded Source

Built Distribution

dbos-0.13.0a2-py3-none-any.whl (83.2 kB view details)

Uploaded Python 3

File details

Details for the file dbos-0.13.0a2.tar.gz.

File metadata

  • Download URL: dbos-0.13.0a2.tar.gz
  • Upload date:
  • Size: 104.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dbos-0.13.0a2.tar.gz
Algorithm Hash digest
SHA256 fdfe83ac79db57dc7e9a0da207d2f0cf075539251fdfb1212a3f0d6b25b81eee
MD5 6685b3fc0a3186b8f085d6c19b352acf
BLAKE2b-256 9e54f8fd1c0c5af4e505ce683a81826cbf8ed01fad240c310db339d02f967fb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbos-0.13.0a2.tar.gz:

Publisher: publish.yml on dbos-inc/dbos-transact-py

Attestations:

File details

Details for the file dbos-0.13.0a2-py3-none-any.whl.

File metadata

  • Download URL: dbos-0.13.0a2-py3-none-any.whl
  • Upload date:
  • Size: 83.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dbos-0.13.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 116c7f6c183f527070e4c6da9c8d4d9f8bfb7bdf70cc39e3ccec010d83543511
MD5 ca44946171abe8ca1fdd90ad9d6f9c0f
BLAKE2b-256 b6d6ed2485c1412cb5ce73c181f09a077e1651b955dc09c0e6b51df0ac8516fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbos-0.13.0a2-py3-none-any.whl:

Publisher: publish.yml on dbos-inc/dbos-transact-py

Attestations:

Supported by

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