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.10.tar.gz (57.0 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.10-cp312-none-win_amd64.whl (189.0 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.10-cp312-cp312-manylinux_2_34_x86_64.whl (345.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dagex-2026.10-cp312-cp312-macosx_11_0_arm64.whl (251.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.10-cp311-none-win_amd64.whl (189.0 kB view details)

Uploaded CPython 3.11Windows x86-64

dagex-2026.10-cp311-cp311-manylinux_2_34_x86_64.whl (345.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.10-cp310-none-win_amd64.whl (189.0 kB view details)

Uploaded CPython 3.10Windows x86-64

dagex-2026.10-cp310-cp310-manylinux_2_34_x86_64.whl (345.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.10-cp39-none-win_amd64.whl (189.3 kB view details)

Uploaded CPython 3.9Windows x86-64

dagex-2026.10-cp39-cp39-manylinux_2_34_x86_64.whl (345.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

dagex-2026.10-cp39-cp39-macosx_11_0_arm64.whl (251.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.10-cp38-none-win_amd64.whl (189.1 kB view details)

Uploaded CPython 3.8Windows x86-64

dagex-2026.10-cp38-cp38-manylinux_2_34_x86_64.whl (346.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.10-cp38-cp38-macosx_11_0_arm64.whl (252.5 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.10.tar.gz
Algorithm Hash digest
SHA256 3e44bcd06cffc1af880731d089ddc2ac614a6f1b517fba72421253792041cc69
MD5 b557edeeac2ea34fd6d602b8db148ef6
BLAKE2b-256 111fe63199464486c59a1ce90c4b1e840de33ffe1ff42b400453f6050fadfa33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.10-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 189.0 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.10-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 83a9255c1d0f320e88e4b455eddf91efa6f616329665707bcd75c86aaed60088
MD5 2380753af6e592095d43eb271fc3af58
BLAKE2b-256 4f510c62ef589c96f9eb3772f659409a9f39a128977654cb3a2768c1766c0da7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 223c0fad4d644d01705f38b69657ace8a44e29de2efa24eb5f26d156edded436
MD5 d60ca1e334de83064cb11506fd984ad4
BLAKE2b-256 8376d46231a10e970b90deaf3a6150842acd55506ced3994657679f1e307f26a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f3fe95bae8660fea85608fbc46f792f8f70e263af8d12d35b57c81e8ebba129
MD5 47e6ebd929084840bbcb5391c1b4b435
BLAKE2b-256 48710bbb62037e3dd5e4a00f82cc38b4e8fb4fdffb90663acf94ef5f3fdfcdfe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.10-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 189.0 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.10-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 807dc477d83dd74d526d37d9dbe6c74d89337479109b39e30753ed7d4f382b13
MD5 9e56e42efc362ea5b9a2ea99fd52df60
BLAKE2b-256 5fa6e5eff4692b0c8b1a1026a81c8873e720a1f3ac8867200d7426349638eb28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 476c7b5a67149147563e8f7d97a75955f48e50ba7f1beb0d7df186b14f5368b7
MD5 96e9f5e5c8cc8593b447fa7db9576224
BLAKE2b-256 f3dcb9bd56d4aa52c8beb28fecc2c834cd93044ec7e7ea2b77a4498bbc45baa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bd3012a693f66bb1767f42f3bd8a0998451422a824ebef739fbf534329b8eda
MD5 68dcf813e4a404b101bc16077a8fc0a6
BLAKE2b-256 cfd0b46cecf7ff2716e17ec019aa84d321f6624fa418579801e0efc27d25deda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.10-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 189.0 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.10-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 ac46070ad6e02853ae87886e09f346f1611f3c8c5a8d0a33f99922df3533b4bb
MD5 c407b64569cf293c8adfcb715bb6c228
BLAKE2b-256 95478febb7979779846725790b032597176ad5fe3df1816c1f488abb9b51a759

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 96bcf7a0fa0f92b0acd077194ea90076dadc424f2c08a3526596c62e1b9efd16
MD5 f8b731784370d3c7132bb00d62e10fe2
BLAKE2b-256 4d3161b81493464a73d3f97b9f875b74fda56364242a2ab28a3bdaf7cc5cfee1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0924c114bc8d5fc721b5bed73a4aa6406f2d3cf09f4e98fc58148a6a61faa774
MD5 936104be41498869578523b88bb015de
BLAKE2b-256 6c8f87f1334cd68e414a20fba4324a10f1c0d042ffea8fd90d4c4cca7e2845b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.10-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 189.3 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.10-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 afb0fc1a5aaab0f62f169e1af8ccfa79163f259d37caee14c1e7a3e59c40402b
MD5 3fa69d6215dcb13c637f2f2c992d583c
BLAKE2b-256 2c4deb51e1adb9d89ee48e956f385a74b2ac6f508699725acadd2d8d5392a046

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 de53eabad49256af7d8484f59c26a583d06a1a5940da71d6ba2f6f848809b074
MD5 94f7edf379235355be8d15733cf7fb99
BLAKE2b-256 653f7aa9fae87cb4072d01c4d2306deec9986b9fdeaf92948966463406e4148a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ad0dc44a0f6f727128ecc7c58fcb35b7cdee5851e237066965836ef5131b3e3
MD5 43bcb4ff8ba7f65034d6d4b7a86e0b6c
BLAKE2b-256 4cc5a69ee617f886a3b2b1362df4862b61702473907d0f260f706ba6c9f099a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.10-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 189.1 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.10-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 c8b279a9a89d5cf757109aa63f38b0faea083830fd20caa4d44e0ff6d0e664de
MD5 95ccaeb3a618cfd7c61be4739e84c904
BLAKE2b-256 0c2a718a53877ddadaf85df82f13027a1bdb8ccc17d74af92150ca9afca49b13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4aad006e00956a2cc01ad91772db8f2e30f4156a35cc1b81ac86bd8e9be9c3a9
MD5 f196165dfa15dbb32c458215e27cbc00
BLAKE2b-256 5c5f6689c0329c87bcc529c54525d5e774cb56395d29d94842fd4e7f3b072656

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.10-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a0d505d9102e81910e393c6e403f66d50ef3833f55627f3fb5a6e22cf71c5e1
MD5 631a90a9e43aefefd08212662a886cb5
BLAKE2b-256 92706ad01a9484fa7d801143a7ba2c491ea80200d49a9cb50e7d7c40b7ec77fe

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