Skip to main content

A lightweight multiprocessing DAG execution engine with message queues and external control options.

Project description

EasyDAG

EasyDAG is a lightweight, multiprocessing-friendly Directed Acyclic Graph (DAG) execution engine for Python.

It lets you define task nodes, declare dependencies, and execute them in parallel — while emitting structured lifecycle events and inter-process messages for logging, progress reporting, or external systems such as web dashboards.

EasyDAG is designed to be simple, explicit, and embeddable, without the operational overhead of workflow schedulers.


Key Features

  • ⚙️ Define DAGs using plain Python functions
  • ⚡ Parallel execution via multiprocessing
  • 🧠 Automatic dependency resolution
  • 📬 Multiprocess-safe message queue for side effects
  • 🧵 Message handlers run safely in the main process
  • 🪝 Lifecycle hooks via a clean interface (ABC)
  • 🛑 Cancellation, fail-fast, and timeout support
  • 🌐 Optional WebSocket interface for live monitoring & control
  • 📦 No external runtime dependencies for the core engine

Installation

pip install easydag

Quick Start

from EasyDAG import EasyDAG, DAGNode

def task_a():
    return 2

def task_b(id_a):
    return id_a * 10

dag = EasyDAG(processes=4)

dag.add_node(DAGNode("id_a", task_a))
dag.add_node(DAGNode("id_b", task_b))

dag.add_edge("id_a", "id_b")

outputs = dag.run()
print(outputs)

Core Concepts

DAG

A DAG is a set of nodes with directed dependencies. A node may only execute once all of its dependencies have completed successfully.

EasyDAG guarantees:

  • No node runs before its dependencies
  • Each node runs at most once (unless retried)
  • Independent nodes run in parallel

DAGNode

Each node wraps:

  • A callable function
  • Static positional and keyword arguments
  • Retry configuration (optional)
DAGNode(
    node_id="A",
    func=process_data,
    args=(10,),
    kwargs={"foo": "bar"},
    max_retries=2
)

Dependencies are resolved automatically by matching upstream node IDs to function parameters.


Message Queue System (Side Effects)

EasyDAG includes an optional multiprocessing-safe message queue designed for side effects:

  • Logging
  • Progress updates
  • Metrics
  • Database writes
  • External notifications

This keeps compute nodes pure and avoids unsafe shared state.


Defining a Queue

from EasyDAG import MultiprocessQueue

queue = MultiprocessQueue()
dag = EasyDAG(processes=4, mp_queue=queue)

Registering Handlers (Main Process)

Handlers always run in the main process, never in workers.

def log_progress(payload):
    print("Progress:", payload)

queue.register_message_handler("progress", log_progress)

Sending Messages from Nodes

If a node function includes the reserved message_queue parameter, EasyDAG injects it automatically.

def process_data(x, message_queue=None):
    message_queue.put(
        QueueMessage("progress", {"value": x})
    )
    return x * 2

If the parameter is omitted, the queue is not passed.


Lifecycle Interface (Execution Hooks)

EasyDAG exposes a formal interface abstraction via an abstract base class:

from EasyDAG import EasyInterface

This allows you to observe and control execution without coupling logic to the engine.

Supported Hooks

  • dag_started
  • dag_finished
  • node_started
  • node_progress
  • node_finished
  • node_errored
  • run()
  • cancel()

You can implement your own interface to:

  • Emit events
  • Drive UIs
  • Collect metrics
  • Integrate APIs

Cancellation & Fail-Fast

EasyDAG supports:

  • User-initiated cancellation
  • Fail-fast execution
  • Execution timeouts

Cancellation halts scheduling of new nodes and can be configured to terminate or safely complete in-flight tasks.

Execution outcome is tracked explicitly via DAG status (success, failed, cancelled, timeout).


WebSocket + FastAPI Demo

A full working example is available at:

📁 https://github.com/Mechatronicist/easyDAG-Web

What the demo shows

  • Building a DAG
  • Emitting node & DAG lifecycle events
  • Streaming events over WebSockets
  • Starting and cancelling execution from the browser
  • Viewing live progress in real time

When to Use EasyDAG

EasyDAG is ideal when you need:

  • A local, Python-native DAG engine

  • Parallel execution with dependencies

  • Fine-grained control over execution

  • Lightweight orchestration without infrastructure

  • A simpler alternative to:

    • Airflow
    • Prefect
    • Ray
    • Dask

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

easydag-0.2.2.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

easydag-0.2.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file easydag-0.2.2.tar.gz.

File metadata

  • Download URL: easydag-0.2.2.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for easydag-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c1785330287f126944cd635bf273131f27ce631a1f2266ca1a666a378e7b28af
MD5 0280d416f786c2de657502ba2349cf49
BLAKE2b-256 2433aa2c86df07ad006ddb29a68f05c3bdfb201c3efadf9988bbe24da43a7778

See more details on using hashes here.

Provenance

The following attestation bundles were made for easydag-0.2.2.tar.gz:

Publisher: publish.yml on Mechatronicist/easyDAG

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file easydag-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: easydag-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for easydag-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f4f032ae09ce0aa2798ff9bdb7bbca3dabe9f9f33eafd9e908ab3173c7eb5fc
MD5 16be7f87ea5354974fce5997276b34a4
BLAKE2b-256 e73de5432f27274aec69498ea5a2f76dbca920a3cd25af268beb0f3971253fad

See more details on using hashes here.

Provenance

The following attestation bundles were made for easydag-0.2.2-py3-none-any.whl:

Publisher: publish.yml on Mechatronicist/easyDAG

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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