Skip to main content

A pure Rust DAG executor supporting implicit node connections, branching, and config sweeps

Project description

dagex

A pure Rust DAG executor with Python bindings

dagex

A pure Rust DAG (Directed Acyclic Graph) executor with Python bindings for building and executing computational pipelines.

Features

  • Implicit Node Connections: Nodes automatically connect based on execution order
  • Parallel Branching: Create fan-out execution paths with .branch()
  • Configuration Variants: Use .variant() to create parameter sweeps
  • Mermaid Visualization: Generate diagrams with .to_mermaid()
  • Parallel Execution: Execute independent branches concurrently
  • Native Performance: Rust-powered execution with Python convenience
  • Memory Efficient: Zero-copy data sharing between nodes using Arc (18x performance improvement for large datasets)

Installation

pip install dagex

No Rust toolchain required - prebuilt wheels are available for all major platforms.

Quick Start

Basic Pipeline

import dagex

def data_source(inputs, variant_params):
    """Generate initial data"""
    return {"value": 42}

def multiply(inputs, variant_params):
    """Process the data"""
    val = inputs.get("x", 0)
    return {"doubled": val * 2}

# Create graph
graph = dagex.Graph()

# Add nodes
graph.add(
    function=data_source,
    label="DataSource",
    inputs=None,
    outputs=[("value", "data")]
)

graph.add(
    function=multiply,
    label="Multiply",
    inputs=[("data", "x")],
    outputs=[("doubled", "result")]
)

# Build and execute
dag = graph.build()
context = dag.execute()

print(f"Result: {context['result']}")  # Output: Result: 84

Parallel Branching

Create multiple parallel processing paths:

import dagex
import time

def source(inputs, variant_params):
    return {"data": 100}

def branch_a(inputs, variant_params):
    time.sleep(0.1)  # Simulate work
    return {"result_a": inputs["x"] * 2}

def branch_b(inputs, variant_params):
    time.sleep(0.1)  # Simulate work
    return {"result_b": inputs["x"] * 3}

def branch_c(inputs, variant_params):
    time.sleep(0.1)  # Simulate work
    return {"result_c": inputs["x"] + 50}

graph = dagex.Graph()

# Source node
graph.add(source, label="Source", outputs=[("data", "shared_data")])

# Create parallel branches
graph.branch()
graph.add(branch_a, label="BranchA", inputs=[("shared_data", "x")], outputs=[("result_a", "a")])

graph.branch()
graph.add(branch_b, label="BranchB", inputs=[("shared_data", "x")], outputs=[("result_b", "b")])

graph.branch()
graph.add(branch_c, label="BranchC", inputs=[("shared_data", "x")], outputs=[("result_c", "c")])

dag = graph.build()
result = dag.execute(parallel=True)

print(f"Branch A (100*2): {result['a']}")  # 200
print(f"Branch B (100*3): {result['b']}")  # 300
print(f"Branch C (100+50): {result['c']}")  # 150

Visualization

Generate Mermaid diagrams to visualize your pipeline:

print(dag.to_mermaid())

Output:

graph TD
    0["Source"]
    1["BranchA"]
    2["BranchB"]
    3["BranchC"]
    0 -->|shared_data → x| 1
    0 -->|shared_data → x| 2
    0 -->|shared_data → x| 3
    style 1 fill:#e1f5ff
    style 2 fill:#e1f5ff
    style 3 fill:#e1f5ff

Working with NumPy Arrays

dagex seamlessly handles NumPy arrays and complex numbers:

import dagex
import numpy as np

def generate_signal(inputs, variant_params):
    """Generate a complex signal"""
    samples = 256
    t = np.linspace(0, 1, samples)
    signal = np.exp(2j * np.pi * 10 * t)  # 10 Hz complex exponential
    return {
        "signal": signal,  # numpy array passed directly
        "num_samples": samples
    }

def process_signal(inputs, variant_params):
    """Process with FFT"""
    signal = np.array(inputs["signal"], dtype=complex)
    spectrum = np.fft.fft(signal)
    magnitude = np.abs(spectrum)
    peak_freq = np.argmax(magnitude)
    
    return {
        "spectrum": spectrum,
        "peak_frequency": int(peak_freq)
    }

graph = dagex.Graph()

graph.add(
    generate_signal,
    label="GenerateSignal",
    outputs=[("signal", "sig"), ("num_samples", "n")]
)

graph.add(
    process_signal,
    label="ProcessSignal",
    inputs=[("sig", "signal")],
    outputs=[("spectrum", "spec"), ("peak_frequency", "peak")]
)

dag = graph.build()
result = dag.execute()

print(f"Peak frequency bin: {result['peak']}")

Data Types

dagex supports any Python data type:

  • Primitives: int, float, str, bool
  • Complex numbers: Built-in complex and numpy.complex128
  • Collections: list, dict, tuple
  • NumPy arrays: All dtypes including complex arrays
  • Custom objects: Any Python object can be passed through the graph

The framework doesn't impose type restrictions - your node functions determine what data flows through the pipeline.

API Reference

Graph

  • Graph() - Create a new graph builder
  • graph.add(function, label=None, inputs=None, outputs=None) - Add a node
    • function: Callable with signature (inputs: dict, variant_params: dict) -> dict
    • label: Optional node name (str)
    • inputs: List of (broadcast_var, node_input_var) tuples
    • outputs: List of (node_output_var, broadcast_var) tuples
  • graph.branch(subgraph=None) - Create a parallel branch
  • graph.build() - Build the DAG and return a Dag object

Dag

  • dag.execute(parallel=False, max_threads=None) - Execute the graph
    • parallel: Enable parallel execution of independent nodes
    • max_threads: Limit concurrent threads (None = unlimited)
    • Returns: dict with all broadcast variables
  • dag.to_mermaid() - Generate Mermaid diagram (str)

Examples

The package includes several example scripts:

  • python_demo.py - Basic pipeline construction
  • python_comprehensive_demo.py - Multiple pipeline patterns
  • python_parallel_demo.py - Parallel execution examples
  • python_data_types_demo.py - Working with various data types
  • python_radar_demo.py - Signal processing pipeline with NumPy

Find them in the examples/py directory on GitHub.

Performance Notes

  • The DAG executor is written in Rust for performance
  • Python functions are called from Rust with proper GIL handling
  • Parallel execution releases the GIL during graph traversal
  • For CPU-bound Python code, use libraries like NumPy that release the GIL internally
  • Best performance gains with parallel execution of I/O-bound or NumPy-based operations

License

MIT License - see LICENSE for details.

Links

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

dagex-2026.14.tar.gz (71.4 kB view details)

Uploaded Source

Built Distributions

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

dagex-2026.14-cp312-none-win_amd64.whl (189.6 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.14-cp312-cp312-manylinux_2_34_x86_64.whl (344.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dagex-2026.14-cp312-cp312-macosx_11_0_arm64.whl (251.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.14-cp311-none-win_amd64.whl (189.6 kB view details)

Uploaded CPython 3.11Windows x86-64

dagex-2026.14-cp311-cp311-manylinux_2_34_x86_64.whl (344.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.14-cp311-cp311-macosx_11_0_arm64.whl (251.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.14-cp310-none-win_amd64.whl (189.6 kB view details)

Uploaded CPython 3.10Windows x86-64

dagex-2026.14-cp310-cp310-manylinux_2_34_x86_64.whl (344.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.14-cp310-cp310-macosx_11_0_arm64.whl (251.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.14-cp39-none-win_amd64.whl (189.7 kB view details)

Uploaded CPython 3.9Windows x86-64

dagex-2026.14-cp39-cp39-manylinux_2_34_x86_64.whl (345.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

dagex-2026.14-cp39-cp39-macosx_11_0_arm64.whl (251.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.14-cp38-none-win_amd64.whl (189.6 kB view details)

Uploaded CPython 3.8Windows x86-64

dagex-2026.14-cp38-cp38-manylinux_2_34_x86_64.whl (345.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.14-cp38-cp38-macosx_11_0_arm64.whl (251.4 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file dagex-2026.14.tar.gz.

File metadata

  • Download URL: dagex-2026.14.tar.gz
  • Upload date:
  • Size: 71.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dagex-2026.14.tar.gz
Algorithm Hash digest
SHA256 e36382e261349a39c67d4fb53858bc1b3e07c1827ae6406ef7892cde5cbe3572
MD5 0f3b568ac114a29a419847f40a036511
BLAKE2b-256 97c032d2c71b40fdcb37703e4af90b60ba789021755be0c931b82b7a83950499

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp312-none-win_amd64.whl.

File metadata

  • Download URL: dagex-2026.14-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 189.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dagex-2026.14-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 d2d2dd0816618f037a8937b0a8461a26e2aeb244af571fb7d4986aa09064b5be
MD5 ecbbcceae88ccf658801bdf02c1f940f
BLAKE2b-256 be4921f64c0d22b50c40a7845084d45517a648f5895a20874384a21e6a500ae3

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 39de6381c15e78b83c77caa93186d91cecfa6729a402f845b82e910f6d5875fe
MD5 5e50dfc49cccb171ba93e8bba539a620
BLAKE2b-256 5d50977a2c5daeed5365cacdd0d93066f4f20b2f064485df97ffe6e0bca94140

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d6bd8322e9c41a3b58d28625d1ab87c865c483ce3383f544679dba25e111f0c
MD5 acaa647e29c96981a5372b5cb64a6ee2
BLAKE2b-256 278652802923ace4ac9748f8118f8f4b23e0b3be2e2d8bef8433c1185e6f5a06

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp311-none-win_amd64.whl.

File metadata

  • Download URL: dagex-2026.14-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 189.6 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dagex-2026.14-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 1a89ae110a1827dfe0d34ed4e9b0ead0a84977560488c18cb1a84048bb5f284b
MD5 a1a2c70c1420660cc3fb07cf267fa3f9
BLAKE2b-256 922022eb9fb97ea61dd77681cbdccadbe9bd7bab2ae7aae7cc6104ba29b7204a

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1c74493ca557dac018ef0484dff6c11ab855b8562d129a483f187db066516186
MD5 56367f98bd2f3af746157077ecf9ae84
BLAKE2b-256 904b32814341895753188357b50b43e52b7b20a71c6e685d1051d00103cf2167

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95c82d8aa8e8a803eb4b415eef625abef9a10a17eadd5639c35b5f5e2c4fed81
MD5 7582a6c41f64fcf25f25e55e4dbe97e6
BLAKE2b-256 abc7c8b03e1bc1682776f778b7dcaac010958553189e68615ba23c5bc529d4bc

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp310-none-win_amd64.whl.

File metadata

  • Download URL: dagex-2026.14-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 189.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dagex-2026.14-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 4e0e4e6efe7c5d6dccd2cf66769d20295eb1001989f1232efd6af3a125f390b3
MD5 590d3451f4a0f0a8db71e9ed2c4da3c5
BLAKE2b-256 61ff0a5201e86b3b1ae3f53f7f71bbc11b3929a6187179e33bc0e6bacda9c93f

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 534a9183d783e564d86c251e75cc08526f358e7f317e6e05ed3f7c9e8929a9b0
MD5 776cc8f21abdd29b043bb4a45aef3640
BLAKE2b-256 51ef2b702c2642add1b08c89dfd4ee188e5a21262916efc21b61d8593094626a

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fac968a747e617141b78607e85be936dfc1c5077c6fe74a1e39fddc7ccd5d910
MD5 52ba82edb340717f530dd56ad50dc4a4
BLAKE2b-256 c9fdc46bbd79c2f408b70f25efc5fb4c82b460245495f4ed2ff4bd822b4e9318

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp39-none-win_amd64.whl.

File metadata

  • Download URL: dagex-2026.14-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 189.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dagex-2026.14-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 c3533cd4d61f025cf43c4adc2684fa1d34aa6327c2e59ea0751761b7daf8026c
MD5 b759de3bfc6cbdefa9742f3b9a5861e0
BLAKE2b-256 604f3fdabcc2ca650c0fa624ec9efb939845de9db37794687f4a9f81a49acd80

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c5ffa823b4451fb46dd2c1810ac98f519f5e0010c7f886afad78bceaac7a8340
MD5 956904f1258d7f7b606b8ddac6e2c775
BLAKE2b-256 730c3091132d6891d202fd5cc72610f5576afb711743eda08f4ff1806f1c4525

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8faf3558b1532dd6c6d6a27141c3f0a64da70cc3380b1885eabc6395af6ad553
MD5 d453aedbd4c728d7fd8fbe42fe88cb54
BLAKE2b-256 37c16f6d2dccfab6c4369e12ffa90938558da75f369060b051eb803e19b05392

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp38-none-win_amd64.whl.

File metadata

  • Download URL: dagex-2026.14-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 189.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for dagex-2026.14-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 53a150d5508b66dc77a29026dd5e9182d0a058e24ffb2621218df3bac52791a9
MD5 99c419f1430622d9968322102d1a84d5
BLAKE2b-256 2da5edf7d88993176b4ad31e1c6e86a49d5161c7a3100aefe86a98d0c37be02b

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 07f84964163aca862b7a0a14e772ee6e1ff3589e986a9f67234057eff74eabd2
MD5 9c25362012a70bde98cd0d825a1839a0
BLAKE2b-256 6f89e58a35f98bfd939a14840d5869dc647a609102e9e3f077ce7e21671cbc6c

See more details on using hashes here.

File details

Details for the file dagex-2026.14-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dagex-2026.14-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd279bb3b878ca5a167edfde49b63f48b4427d158b1d253555cfd80e88dcf433
MD5 ea788f68165a41e79cd6ceb9c709c5b3
BLAKE2b-256 b1f68e8573129551262347d356b2587baf331d8943eff54e677056822aff87ac

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