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.

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

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.1.tar.gz (46.8 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.1-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

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

Hashes for ogha-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3fd7c94d9ec76a12db72b1ec915d4014842a73448d9fcfa9cfc58afdba6a9742
MD5 8004f16c930da6d1b957d9b15102ba51
BLAKE2b-256 cb943cf79d88a53d4945ac35238e2e1755e6f1921d62cf984ab675df22ae7266

See more details on using hashes here.

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

Hashes for ogha-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 148a7fb29060059ea9258b0b404248de476ace14da4daf4fcc8f918d9d3e326e
MD5 1c568c85198c86d824b305dd906bfdc4
BLAKE2b-256 24db28a4948e585674cfb45178c04d4656eaf92bde21234e867ad20c388080f3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

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