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.9.tar.gz (55.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.9-cp312-none-win_amd64.whl (188.9 kB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.9-cp311-none-win_amd64.whl (188.9 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.9-cp311-cp311-macosx_11_0_arm64.whl (251.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.9-cp310-none-win_amd64.whl (188.9 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.9-cp310-cp310-macosx_11_0_arm64.whl (251.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.9-cp39-none-win_amd64.whl (189.2 kB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.9-cp38-none-win_amd64.whl (189.0 kB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.9-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.9.tar.gz.

File metadata

  • Download URL: dagex-2026.9.tar.gz
  • Upload date:
  • Size: 55.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.9.tar.gz
Algorithm Hash digest
SHA256 ac51ec129a8fd9691055d7855d01811707ebd4bc3b395e0b8f4833ea7029252e
MD5 c5328da735555e2b513fa4d9d0521302
BLAKE2b-256 9620fabb5825a3b492e8bc911ed361217ff7ebf3a4d5f1f964ad67c29f8e18f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.9-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 188.9 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.9-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 0c79a309d67548b6ee5395ffb66f6754a1448b48e6895cbbf58605f5c50d2397
MD5 1f8ff2413d2b96a3bb10c00f56a550c8
BLAKE2b-256 da3669c57002b5fbb8c56e498bd7872c1f2a89b16598e95ea257d7f214879233

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f7bbf4e1baddd633f58e27870b70df70670ae7abecc7e7940ebe4d0a975ab308
MD5 8b9cad168cdde235e4a54b562da010c8
BLAKE2b-256 c0eb02b372d5b1b6de661593c737f69b0a8cbc860729a58ea179f19375f45983

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3a441e766d476abfa24ff6782ae4a35941e390765c1b6af224c61de3cbc8793
MD5 1623ac01dd1db9c7e36ce25356a45d71
BLAKE2b-256 6cb107bd902b5e959df8da65f663c418193baa272404a200b3441c533a0b5262

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.9-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 188.9 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.9-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 5b1e61f8a3449a26f13b3a3d39e25b3beeb8e8270441c2e64e1466bfb7f748b5
MD5 45cde4918e5c776eecfb3709058d2feb
BLAKE2b-256 c8c40a76a878fa65da2bff7bf983f08f8038f174f3e91f5c9c0cff0257607663

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b82520d6156a9396ba3b9fd986c0ef2ba6275be611bd80cb131f6ce79a00291d
MD5 63c9680bb5f00da1be675007e9cb8f87
BLAKE2b-256 987fc09350b7022c83070dda0a3c0cd9fe1ad439653242cbe7c027d473a476d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f45a8cb698ce6500b0b65f459166ea63b637ed2c503e6740900c982c16317b87
MD5 e654998329e6fd24b01ec8c558b77b95
BLAKE2b-256 4fd4542e6a6d92e0798d942f76b914af4b0156cc946c553243e0528597b7ea4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.9-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 188.9 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.9-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 88df6ed78fb2ffb0b2ef0ccbbcccd911aaadd6ba9da35af8e564ce49588b30ba
MD5 cceaa5846e980f17aa3e26098d5f9ca8
BLAKE2b-256 b18fa4bb92d3bac55840ba2c5a02a7099c8807ea9a3263ebb83c6732d98cc29e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1df4ca95d951cf41d7765a95b75311803c552debeccf54856ea92ed64f800015
MD5 4066b12d3dfa6c75eec6dc1c1cab7a24
BLAKE2b-256 b3623bdc2ecb3d13fc039609d42120242b92a09d0c1408f7b6cc8855f779e64e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a46387a2b844ecf0d0ff95f124cc420a9abb3ab6b38c35c658064cf454d562a8
MD5 b565f9f2d201f3702200743683148f05
BLAKE2b-256 138a9c06f4dc6a743d43547ccccd3b3f51117df17e837043df3caf8d6f62afc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.9-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 189.2 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.9-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 6ad2025d340f2023639d53aab931e8a1ab9aa432468ad574a15dfdac64313f47
MD5 2cce0196c3b2134974ad883f5ce7d819
BLAKE2b-256 f0bc7e180b64ce405ae6c8a9ff8bff742e84d312e237d910d6ea06137bcc45a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 02410021358e3c805c9fdb251e18b206bc840cd8a91e50b1864a2d8d10b2617b
MD5 2fe8beb27c88f434fe7df5468f1c4875
BLAKE2b-256 acdc86f8a76870d61318f6ff068342fe725b3f33ba0c952893472603b6932895

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03fbe26357a95a3267eba25ed2a80815502943828d8060b867d08345be6c38ac
MD5 f12c3766e7aed5d3b4816cb0665e941a
BLAKE2b-256 de6e818943733bd41b3a6c3a4216d9648197c431c0ce9ece2c2dfe66aae1c73c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.9-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 189.0 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.9-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 41fe16c78a88a7de327193516c80e29272716a6da00b2d7761a58e91f029eb9c
MD5 c7b99af1a966f60118ef8b30bc6b374a
BLAKE2b-256 9b8574ad488a3c4fd3cbe7260155e0ac1ca99c4f487a25132119ed938cc25a12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2b2dfa1b89b37633aef60bb72cead3f0095b4ce731816273d6bdbfb71c67706d
MD5 891bc68614a073aa757a8a4840889258
BLAKE2b-256 1551f0644f1ada5e51f63621efed07e6ecbbbaf9429f2b453d80c8546782cc16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.9-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f5c688e56f6791c8e50f7209c06183f90f7775cc7b432f8308eeeeceb62f6cc
MD5 9a8d2404efa6ef4b2e22f9532555fbf4
BLAKE2b-256 c48e2a273f93f85d5366b38378d4a451ba17d4fb4375d727143a2acbbeb3b916

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