Skip to main content

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

Project description

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

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.8.tar.gz (50.2 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.8-cp312-none-win_amd64.whl (199.3 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.8-cp312-cp312-manylinux_2_34_x86_64.whl (358.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dagex-2026.8-cp312-cp312-macosx_11_0_arm64.whl (263.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.8-cp311-none-win_amd64.whl (199.3 kB view details)

Uploaded CPython 3.11Windows x86-64

dagex-2026.8-cp311-cp311-manylinux_2_34_x86_64.whl (358.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.8-cp311-cp311-macosx_11_0_arm64.whl (263.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.8-cp310-none-win_amd64.whl (199.3 kB view details)

Uploaded CPython 3.10Windows x86-64

dagex-2026.8-cp310-cp310-manylinux_2_34_x86_64.whl (357.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.8-cp310-cp310-macosx_11_0_arm64.whl (263.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.8-cp39-none-win_amd64.whl (199.6 kB view details)

Uploaded CPython 3.9Windows x86-64

dagex-2026.8-cp39-cp39-manylinux_2_34_x86_64.whl (358.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

dagex-2026.8-cp39-cp39-macosx_11_0_arm64.whl (264.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.8-cp38-none-win_amd64.whl (199.4 kB view details)

Uploaded CPython 3.8Windows x86-64

dagex-2026.8-cp38-cp38-manylinux_2_34_x86_64.whl (358.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.8-cp38-cp38-macosx_11_0_arm64.whl (264.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.8.tar.gz
Algorithm Hash digest
SHA256 b5dace0ffe0cb6965415bedfdc138aaa65cbf089eddc4fdcf0ebbf36ded90784
MD5 68f0d9b7a44d6b52cb3e3a7e5e90038d
BLAKE2b-256 ef6b2aa17aca7e0993957c53a73ffd477fd72a49a629b8f262353a09b075a8d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.8-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 199.3 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.8-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 32dbe631de0d65e5097275906bad576b0c59223469ff49149741e84218fa2149
MD5 97a10cbf44300c720c835d3528d4b9d2
BLAKE2b-256 1f91fcea2738080e0b134d7b55a37f88fc253c31c525ae8bef6d0fef2c6809df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d3aa7c2165f7441b53622aaf294795fd77beea0f58716f785727022fe093bda0
MD5 a698c8be8383d9a1b3c08631d0f6f4b2
BLAKE2b-256 79099c4ff601ba42735a17ebde6a89335d05e9c6e3623a7d1aeb1f6139748da9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8cad8640236b75f6c8fde46c9af9d63a3ea011ed698daccf4859074448b30ae3
MD5 6c5986e69c9ff27d520985458979027b
BLAKE2b-256 98c664b97d212359efafe6dee955d0107f50fd28a2ed7d19d9ec5c619e072dd2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.8-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 199.3 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.8-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 8225f33c3f624386b4a978c802f20ae7c5e29ce0e7947a45f2e174537e78c23d
MD5 6a026e0ad6eaa3b0f5a904be51c9c500
BLAKE2b-256 341b54a315420d0e231e42b2d874b8e0db26783cb51774700a4da8dea74aa060

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5e779524efbb6f7c468eabe666db490bf93e9a132d3387336698cea996723473
MD5 fcb7d91a2a0f09d7cd6d24abf076ef03
BLAKE2b-256 29aa2cc6366aa685c01ac53f247e744123eee4e4aa4166fd50ea9519fb42da1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05f8a72378bd1efac41bc5327d9227edec5f999f749ff74653637eb6db7507e3
MD5 b0a1565fb0f57fe8f705506b9c1717cd
BLAKE2b-256 1de34b3b4e3ac0de1e20048e108aa06cd25a172db3f9058aa514738e982f9b1d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.8-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 199.3 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.8-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 6b63f2862cc966e8cd54ea793aa6e339f1cfac07b9f739e1639ebd825e434b16
MD5 6db4835dc93051cd063cb488389c0a05
BLAKE2b-256 473c150dc8ae14d1152a395890145740f63417369241cdc7cbd55c7ec6aed315

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9bf4113971b8c0da2805a052f4ab863149d59fac7b1f7159a7b426f5cdb0f790
MD5 65ed75e24e0351a153930ec195a4864d
BLAKE2b-256 9f7d886c1860872261acce08053207bed08e0dd1761737eeefe8ea8f823c1e8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87ac88b7a34a7ff725ebca695e57ebc20cb42cfb9cf88f2a33f955fcbe62ff4a
MD5 628a7bad2a895d7430ffe144b96a8ba1
BLAKE2b-256 084ad8190931011627e22f19f096c910e0bb1cf426f6c1d41c1fc363bf50e65f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.8-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 199.6 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.8-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 a12f50b571de9030e4689f09a91ef69a434986ddde1f64eb071f310e697073b7
MD5 38b0a804c30f5f79667b45d2d2b46c8a
BLAKE2b-256 dea178bac42837e5366e6a8f2d295f1f32d6e0d947a08d7c75e8a58232ec1e67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 577dfab321d6016623b9318bd25a192d122b2c503ed43875f76a5af0f400a772
MD5 2595bb57f1eec35ee940acad0437f7d4
BLAKE2b-256 303864c03d0c71e60ebf3f20b0062dd638d33fffb5e02fb71a7410c33c8efa36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57f2bdf6c78eff9e63cb978a42ca6a3fe0aea0f2a7731f6f8bae4e07371eca48
MD5 74077dc9e83f02cf55d989b9e796a699
BLAKE2b-256 50c561f5ba624699ca5dfdd568d6c8f97930fea533257297f6d65d6c90d6088a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.8-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 199.4 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.8-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 3c29d8673b6728d33197387c8dba5c21c557546e46a4fbd13715c87a13aa46bf
MD5 48860c20d5b30f882a3b99e6e1d275d5
BLAKE2b-256 e3e8c6c53f8db42ba7ebba556adfc5ec6dff54780f2c9fef2c92eab3108269e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f2bca7ba8e3fe1148a1dd670f026a083e8359610ef119509995febffb1dab1b5
MD5 3eb1e76313f712723e42dc5908628421
BLAKE2b-256 17d564dc197f47666092f4b97e74f4bc2f5027eb1bcf05a35c2c2a67e639c22f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.8-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 727d9bba38f720aa4c224d95c641274b84dc67878e5c65c4ebffd4835297884a
MD5 a02dd768451d65ecd62fa10926889223
BLAKE2b-256 204a68e8da32554eaea2f746e45badae9c8401706c94b7aaf9d93531894172c0

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