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.12.tar.gz (70.8 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.12-cp312-none-win_amd64.whl (189.2 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.12-cp312-cp312-manylinux_2_34_x86_64.whl (346.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dagex-2026.12-cp312-cp312-macosx_11_0_arm64.whl (251.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.12-cp311-none-win_amd64.whl (189.1 kB view details)

Uploaded CPython 3.11Windows x86-64

dagex-2026.12-cp311-cp311-manylinux_2_34_x86_64.whl (346.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.12-cp311-cp311-macosx_11_0_arm64.whl (252.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.12-cp310-none-win_amd64.whl (189.1 kB view details)

Uploaded CPython 3.10Windows x86-64

dagex-2026.12-cp310-cp310-manylinux_2_34_x86_64.whl (346.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.12-cp310-cp310-macosx_11_0_arm64.whl (252.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.12-cp39-none-win_amd64.whl (189.5 kB view details)

Uploaded CPython 3.9Windows x86-64

dagex-2026.12-cp39-cp39-manylinux_2_34_x86_64.whl (346.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

dagex-2026.12-cp39-cp39-macosx_11_0_arm64.whl (252.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.12-cp38-none-win_amd64.whl (189.2 kB view details)

Uploaded CPython 3.8Windows x86-64

dagex-2026.12-cp38-cp38-manylinux_2_34_x86_64.whl (346.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.12-cp38-cp38-macosx_11_0_arm64.whl (252.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.12.tar.gz
Algorithm Hash digest
SHA256 1d8913c25fe1f613c435ff08201d6c55df864990c58ea1b7d89d59c85d2850e9
MD5 36ab99bd2787f2331c01068776acb132
BLAKE2b-256 a5267cd0144b1aac8176cc724166f1a2f07b0684a2ba81c6dc3ae616edfc1ced

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.12-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 189.2 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.12-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 f2f911eb6af89b1a284f94eda99d3a713f747cca6a5f9e040a3520e0bf2277c4
MD5 08b4ab8fe1bc147f9dc832172507c246
BLAKE2b-256 69d0d2452e5d65e4bb747e00e45df6aa535dd53d9d38fcf06f7af03235419001

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 51df21701a5e0e9920a1ff2506f2c9c96fb84bec3978ef6f29c89f92ed9f802c
MD5 88d5bee0795752e6e11dd05c3954b353
BLAKE2b-256 60d8522fe5dbd54fce1b33843b444d4efc97ea111bacaf65af427f20e6109c99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb2e6bb2910b2f7e1fa22cfb169331d7bfa9ab4091dd4dfdc3e401185d929917
MD5 18ed50f65ed06a032085dd01a97e5023
BLAKE2b-256 3560676bc63bd5adb5aff83f6c47374d9c9f8de4f3ccb8d1dcdcbca5687f92bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.12-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 189.1 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.12-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 2eba2e829fbca0c7bdc192870b3b279e43e30426ff7b10c3e50cc021ff55aaf3
MD5 b2574b819bb25fd29422f0a62a6dc81c
BLAKE2b-256 63967c531e5c763c4e855195273145e4d5d1facd7e0a0b8b35081ac241908f04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9da87f3ce558772710b201b64cc18f4e38dc7afa5da66dd569b403fe8a238795
MD5 deff2913b9ba61113cf76a2f3caa9d7a
BLAKE2b-256 90aa48e3aa24124c31500e40bb0343fb446346b65b722e9829e2e4838412ccc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42763215ca429c788a1421c71bb7c369dfb5dfe0102f81718f58112078f8a02a
MD5 16bf8e5cc79bb068e40564bb04d641d0
BLAKE2b-256 6ffa60c2d6246cde8aab3bfb418b332ad87e08895a71bfcd919b0a7b9b7077fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.12-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 189.1 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.12-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 aacb4b531aa329d8e5487dad43f6aa9aaecd19a75fb63424f42a31371a26f8b7
MD5 0a5f1f7f61d983576052e3c0596159ff
BLAKE2b-256 fca91886469be7964b53565c0efa857fe5f7678829f161a59b6028b0b9788123

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 beef13c5ddab8ea257936c7a6f41c6cd49091adc4ac80f33025367c4d86bbf2c
MD5 44716cae5f6240a5625516355be47dfc
BLAKE2b-256 a7f520cef2787f06adb1e6e8e111ebcca44b24bd58165b018824cafbf558aec3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12a24f3e4f4a98ff321e0e6fb6197e414cbe54993f61332f1ff7ed072dc6caf6
MD5 13f99aa099964b0391c52857e81d3cec
BLAKE2b-256 554f88c3c2fb75fc9464f8e4ceb0d9bd46fa9b4520418c7e5b8f48ea752a91c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.12-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 189.5 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.12-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 aa9f3fda2c0819c57105ca13fda17313d6d3163b8d3b8f441a89f21b9a1cb5ab
MD5 e88463631975d2d9ad0316ab92ce51bc
BLAKE2b-256 ba36fb60852fb54f46c4f83b9111b397a9ec86e57f858a9fca95b8fb199925fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 037ebfed1e44843838d63ae47ba31a2189e9fc1ff08b13f47cd4987b7eb4cf49
MD5 63f880434e8fe41eeeabc2293b847023
BLAKE2b-256 86b3f2cb9b32be62e74e6df2cfae7112585811396ee43abb78ce79d064fea3d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b88583243bf3ebbce86a801747d2ceba417be77262aa4efc84e2cffcae7a2ced
MD5 73516ac888620069e29a679a011e973c
BLAKE2b-256 f966a4457740975b7c14cc79c0baf651e590d73ad77cab6e3a041078caa3c185

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.12-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 189.2 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.12-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 97c0b809193240d6519b7889328595f26709704a7c1cc45364b2b66d28b12fe0
MD5 63d51349163ffbbb98481b873090bb30
BLAKE2b-256 996fc4bfea3a47c63e6423375c76de6da609a99e773598f11ad749ba64568bd0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 63bf3307321e743b32cd2c509f4ea284beafaa736df568ccd6322128dc895b26
MD5 0b66a53e840a851bbb9238ef717be9fd
BLAKE2b-256 d90fe10583bbdb610568c0af7d96e7b178296dc137bdea17f6f818656290edb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.12-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b7155ff7722e3ec985979c4baebd566646fcf83621d29c52e596b5a5370a0ae
MD5 f3327beccee9fd41328c8096631d0dae
BLAKE2b-256 49bf14f5d2662ce93ecd14d80196d1f32d3676a5d9551b20d326cc2c270ac2c1

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