Ogha — durable execution for Python
Write ordinary Python. It survives crashes, restarts, deploys, and month-long waits. You split your code into steps (units of real work) and workflows (compositions of them); Ogha records every step and replays it faithfully after any failure, so a multi-step process finishes even if a worker dies halfway through. No retry loops, no idempotency tables, no state machines to hand-build.
Alpha. The API is stable in shape (nine methods); details may still change before 1.0.
import ogha
@ogha.step(retry=ogha.RetryPolicy(max_attempts=5), pivot=True)
def charge(order, amount):
return payments.charge(order["card"], amount) # runs once; recorded
@ogha.workflow
async def checkout(ctx, order):
total = await ctx.call(validate, order)
receipt = await ctx.call(charge, order, total) # survives a crash right here
return receipt
Install
pip install ogha # Python 3.10+
Run the engine
Ogha ships as one container that carries the engine, storage, and a live
dashboard. Pull it (public, no login) and open http://localhost:8080:
docker run -p 8080:8080 public.ecr.aws/h6s8i3h8/ogha:0.1.0-obf \
--storage=postgres --dsn="postgres://…" --auth-disabled
A ready-to-use docker compose (engine + PostgreSQL) is in the getting-started
guide below.
The nine methods
Everything a workflow can do is nine methods on ctx:
| Method | What it does |
|---|---|
ctx.call(fn, …) |
run a step durably |
ctx.rpc(svc, m) |
durably call a service you can't import |
ctx.spawn(wf) |
start a child workflow — its own run |
ctx.join(*h, until=) |
wait on many: all / any / quorum(n) |
ctx.sleep(s) |
durable sleep, seconds to months |
ctx.wait(name) |
wait for the outside world (a webhook) |
ctx.gate(action) |
a fail-closed human approval |
ctx.emit(event) |
a milestone on the run's timeline |
ctx.cancel(h?) |
cooperatively cancel a child or the run |
Retries, timeouts, and saga compensation are declared on the step
(retry=, compensate_with=, pivot=), not scattered through the workflow.
A worker
A worker is a long-running process that executes your steps; importing your module registers them.
import ogha, myapp # importing registers @step / @workflow
client = ogha.connect("http://localhost:8080")
ogha.Worker(client, target="python://checkout", concurrency=8).run()
Submit work and wait for it:
run = client.submit("checkout", data, target="python://checkout")
result = client.result(run.run_id) # blocks until terminal
Documentation
- Overview & the nine methods: https://coding2fun.in/ogha
- Getting started (full example): https://coding2fun.in/ogha/python
License
See the project for licensing.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ogha-0.1.1.tar.gz.
File metadata
- Download URL: ogha-0.1.1.tar.gz
- Upload date:
- Size: 46.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fd7c94d9ec76a12db72b1ec915d4014842a73448d9fcfa9cfc58afdba6a9742
|
|
| MD5 |
8004f16c930da6d1b957d9b15102ba51
|
|
| BLAKE2b-256 |
cb943cf79d88a53d4945ac35238e2e1755e6f1921d62cf984ab675df22ae7266
|
File details
Details for the file ogha-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ogha-0.1.1-py3-none-any.whl
- Upload date:
- Size: 47.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
148a7fb29060059ea9258b0b404248de476ace14da4daf4fcc8f918d9d3e326e
|
|
| MD5 |
1c568c85198c86d824b305dd906bfdc4
|
|
| BLAKE2b-256 |
24db28a4948e585674cfb45178c04d4656eaf92bde21234e867ad20c388080f3
|