Skip to main content

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.

Beta. 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

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

ogha-0.1.0.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

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

ogha-0.1.0-py3-none-any.whl (47.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ogha-0.1.0.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ogha-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0f464cbb984fce5902c339fe1bb13322bbf795180d74e022fe6e3385edf60c2
MD5 9221d1448d3bcf077baec0228913b3c1
BLAKE2b-256 6aaf8d1b3a7ac4b84c688cb16c06975314bd7f3bf33ddd039e4e8619de452666

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ogha-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 47.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for ogha-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 083ee73b638837fe99e2f6c83e5bd6b072ec9dd4d623056ef974bcc6bb0f52ca
MD5 ce44b3421a6f6d466860f1fb3a5d1a36
BLAKE2b-256 6a7ca80bcaa60f04f092ee56f46a003d44621dbc50ccb2a3d30ed57e012cb6f8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Supported by

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