Skip to main content

Hush workflow engine core - A powerful async workflow orchestration framework

Project description

hush-icore

Core workflow engine for Hush — async DAG execution with built-in tracing and type-safe state management.

PyPI Python

Installation

pip install hush-icore

Quick Start

import asyncio
from hush.core import Hush, GraphOp, op, START, END, PARENT

@op
def double(x: int):
    return {"result": x * 2}

async def main():
    with GraphOp(name="workflow") as graph:
        step = double(x=PARENT["x"])
        START >> step >> END

    result = await Hush(graph).run(inputs={"x": 5})
    print(result["result"])  # 10

asyncio.run(main())

Key Concepts

Ops

  • @op — Turn any function into a workflow node
  • GraphOp — Container for nested workflows
  • BranchOp — Conditional routing (if_(...).else_(...))
  • @graph — Reusable workflow factory with auto-naming

@graph — Reusable Workflow Factory

from hush.core import graph, op, START, END, PARENT, GraphOp, Hush

#        fetch
#       /     \
# summarize  translate    (parallel)
#       \     /
#     merge_results

@op
def fetch(url: str):
    return {"data": f"content from {url}"}

@op
def summarize(text: str):
    return {"summary": text[:50] + "..."}

@op
def translate(text: str):
    return {"translated": f"[VI] {text}"}

@op
def merge_results(summary: str, translated: str):
    return {"report": f"{summary}\n{translated}"}

@graph
def process_url(url):
    f = fetch(url=url)
    s = summarize(text=f["data"])
    t = translate(text=f["data"])
    m = merge_results(summary=s["summary"], translated=t["translated"])
    START >> f >> [s, t] >> m >> END

@op
def publish(report: str):
    return {"status": f"published: {report[:30]}..."}

# Use in a parent graph — auto-named from variable
async def main():
    with GraphOp(name="pipeline") as pipeline:
        p = process_url(url=PARENT["url"])
        pub = publish(report=p["report"])
        START >> p >> pub >> END

    result = await Hush(pipeline).run(inputs={"url": "https://example.com"})
    print(result["status"])

Flow Control

# Sequential
START >> a >> b >> c >> END

# Parallel (fork + join)
START >> [a, b, c] >> merge >> END

# Generator (streaming iteration)
@op
def each_item(items: list):
    for item in items:
        yield {"value": item}

# Loop (feedback loop with condition)
with GraphOp.loop(until="count >= 5") as loop:
    inc = increment(counter=PARENT["count"])
    inc["counter"] >> PARENT["count"]
    START >> inc >> END

State References

# PARENT["key"] — external inputs from engine.run()
step = double(x=PARENT["input"])

# op["key"] — output from sibling op
upper = to_upper(text=greet["greeting"])

# Output mapping
step["result"] >> PARENT["answer"]

Tracing

from hush.core.tracing import LocalTracer

engine = Hush(graph, tracer=LocalTracer(tags=["dev"]))
result = await engine.run(inputs={...})
# Traces written to ~/.hush/traces/{request_id}.json

For external backends (Langfuse, OpenTelemetry), see hush-telemetry.

Rust Backend

hush-icore has a companion Rust crate for high-performance execution (~8x faster on pure-compute). Use via hush-serve:

engine = Hush(graph)
engine.serve(port=8000, backend="rust")

Related Packages

Package Description
hush-providers LLM, embedding, reranking integrations
hush-telemetry Langfuse, OpenTelemetry tracing
hush-serve HTTP API server (Python + Rust backends)

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hush_icore-0.4.6.tar.gz (105.0 kB view details)

Uploaded Source

Built Distribution

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

hush_icore-0.4.6-py3-none-any.whl (133.6 kB view details)

Uploaded Python 3

File details

Details for the file hush_icore-0.4.6.tar.gz.

File metadata

  • Download URL: hush_icore-0.4.6.tar.gz
  • Upload date:
  • Size: 105.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hush_icore-0.4.6.tar.gz
Algorithm Hash digest
SHA256 b25fc501480fd4a93cc3905ba32348f0f8e175ddf0e9a8285acc1c21543bb2ff
MD5 e134da5f68942317b260a0dbc96aa399
BLAKE2b-256 f31007e219c2ab67840aa0ba065cb83cce4dc7ff7a7d42af02d390da0f0d8493

See more details on using hashes here.

File details

Details for the file hush_icore-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: hush_icore-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 133.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hush_icore-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 729cc125c70cd4d8ead95d382bf8d3bbe07e27f20bf632720b656a244188bdb1
MD5 18b41cafc3d3227d9d24db76762a1e7d
BLAKE2b-256 da8ff9857992ea35c9ba058a90bcd2a515d418311e6ecc3c2a93c5fd57ffcc65

See more details on using hashes here.

Supported by

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