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.2-obf \
  --storage=postgres --dsn="postgres://…" --auth-disabled

A ready-to-use docker compose (engine + PostgreSQL) is in the getting-started guide below.

Upgrading an existing project is one script — it verifies PyPI, the docs' pinned compose, and the registry agree on the release, then swaps the engine (health-checked, auto-rollback) and optionally this SDK in the same move:

curl -fsSL -O https://coding2fun.in/ogha/update.sh && chmod +x update.sh
./update.sh --apply --sdk .venv/bin/python

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

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.3
File Size Uploaded Provenance
ogha-0.1.3.tar.gz 48.9 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 105.0 kB

Release files / ogha-0.1.3.tar.gz

Download URL ogha-0.1.3.tar.gz
Size 48.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cebfa7d52c23887dfeecc8a07d0b583dd57e751d0e77ffb0eee37fa625aca693
BLAKE2b-256 checksum
How to use checksums
9abcb064aa5b880242c6efe2854b6e681b33a187ec9041debe4aa7976df00d8e
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.3-py3-none-any.whl

Download URL ogha-0.1.3-py3-none-any.whl
Size 56.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e472cba0ac96432c0c5e39af5478f251a2e0a890e45779b058084625110e7483
BLAKE2b-256 checksum
How to use checksums
bac64a60cda1f73f6872d1022b6e5735c8720855b82342fb3d12c6acdd3d158d
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.3

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