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

Cron schedules

Run a workflow on a schedule the engine fires — occurrences keep firing and dedupe by their deterministic run id even while every worker is down:

@ogha.scheduled("0 6 * * *", context={"report": "kpi"})   # 5-field cron, UTC
@ogha.workflow(name="reports.daily")
async def reports_daily(ctx, param):
    at = ogha.scheduled_time(ctx)        # this occurrence, replay-safe
    return await ctx.call(build_report, param["report"], at.isoformat())

The worker serving the workflow creates the schedule at startup. To change a live schedule, edit the fields and bump revision= — the update is revision-guarded, so a rolling deploy converges instead of flapping:

@ogha.scheduled("0 7 * * *", context={"report": "kpi"}, revision=2)

Programmatic management mirrors it: client.create_schedule(...), client.update_schedule(..., revision=n), client.get_schedule(id), client.list_schedules(), client.delete_schedule(id).

Documentation

License

See the project for licensing.

Metadata

Release files for ogha 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ogha 0.1.2
File Size Uploaded Provenance
ogha-0.1.2.tar.gz 48.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ogha 0.1.2
File Interpreter ABI Platform
ogha-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 103.9 kB

Release files / ogha-0.1.2.tar.gz

Download URL ogha-0.1.2.tar.gz
Size 48.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3a78111ddc8c10078198b3d81a64d66bd31d2ac61e276c8993ab8222283d7ae6
BLAKE2b-256 checksum
How to use checksums
3539e5ae013b33682d98ce8ee00215de1c7962950a6a406558b0ae25b3b702c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / ogha-0.1.2-py3-none-any.whl

Download URL ogha-0.1.2-py3-none-any.whl
Size 55.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cc851bd67f78c680b2df54ffa0ff50dd9826039b8cfe8808ae21f3237ef35f4
BLAKE2b-256 checksum
How to use checksums
8f9a5426177e9b8940c0c57899c9247b2dcd1eecad7585f8c8db40f8d6a4010f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for ogha 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page