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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.7-cp311-cp311-macosx_11_0_arm64.whl (263.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

dagex-2026.7-cp310-cp310-manylinux_2_34_x86_64.whl (358.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.7-cp310-cp310-macosx_11_0_arm64.whl (263.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

dagex-2026.7-cp39-cp39-manylinux_2_34_x86_64.whl (358.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

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

File metadata

  • Download URL: dagex-2026.7.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.7.tar.gz
Algorithm Hash digest
SHA256 c8e477e42b1bd202415eb918c954ce90f2be12c03ea5555c01f426a1b3f720ce
MD5 ee614c5b4797bfce2307e1db733c041d
BLAKE2b-256 1b9407491aff8747f4a2e0044e49ef854e3f2d0cc8a48c2aaee401d1b05a6ed3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.7-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.7-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 63869243b87ccdd60730c4ca0ffa5d10c7484534e0982d7a41c358235872317c
MD5 615801c05af249bdc31610dd0088acd3
BLAKE2b-256 a99a53f32884da0db40a8f1fd2a90a7f7e71f912152b2cd43784d92eb00acfe5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7bc359302d783ca29d67bb635dba44a5bc4d0e6eaadaf9bdb38c5e54f8240ffd
MD5 3f506376b72873367a5e6c7a71a82fb4
BLAKE2b-256 1a7e39c8e3eec8d94febf2570e7df4ad4fe65db9765d2c54b8f2028d881e8730

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6906178b61ec62876fc034b9f878fb5ac2a38f5c18f86e9b57c596f59229a9a6
MD5 63cdc35ac06704e16841624a9bcf7beb
BLAKE2b-256 ac3117fd3788258be6549c617d1bc284010d606b6c32cd1bced87658a823de72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.7-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.7-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 900d052f14e526bd594dafa34a9f988b91f2abd762cd89616a0e1dcabdc82749
MD5 aee1cc94f653c787fddc0a39f74005f1
BLAKE2b-256 ee3e0ea7a6ee4ba9ed270fd6f212c797500d6e82e8930edd480d5f3efad5ff2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 39e034021a8bc662a7a4eab236a69dbc95324b43c0e30d3a9fbbb38e79ac4f78
MD5 cfa50f539dfdaff131b9655d36a80629
BLAKE2b-256 8596262cbecf1da812b98ab112f96d3bd1c6d5eb2dbe8f6305282772df5cb3d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ccd15e0a833f12ac275dd699c349c98aff1cb7dac551586a2153c219747b6ebe
MD5 2d4e086d0e01dee6285ab2f913aed47c
BLAKE2b-256 c3b8acd5520996d1f68a9d8428072b3c074e52c7f1d35cd5a84185d643fc4d44

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.7-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.7-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 a555e5dc8652e7fd746dae7a7c21dbb413b67d4d0d82a898cb9b8f1b1c59faf3
MD5 c60333f5944bb4c0f83ade6ec18de086
BLAKE2b-256 f1ef2931ba3e37246909718c3272aac21deb9ef00c527a25b85f429b2f9df36f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f3a8b60e9b740e9b1ca768c644867d47a406f9516442f9ee78cf4729c8897cff
MD5 184fab51f9e713bfa52e6496ec98e91b
BLAKE2b-256 e14a2608d73f1825a070b086d5a6c3813a634038ff3bee051760772f939977ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c83ab546f38d9ae947944e71d691cf1e33863e9c4a35bcf38c7eaef0ce32f84c
MD5 c653e58159121de17eafb6db7fdf20a4
BLAKE2b-256 bd1976ae3a0d72d29654e93d28399444bd367ed0be187930d61be26862a98f60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.7-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.7-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 1865401f874c1ef036c359bcab6481a90da1e0d1db468ff252063a8bde489b0a
MD5 16115112e126b17adb8330149a010484
BLAKE2b-256 22a1ae9ccb27a6e6b19c179629759665b14768ece371f0eca10d48db7d660e2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1690a1e32e917453a563bae37b6fd92a5092e29b55761d79868da190f0a00658
MD5 ce79d309a8456c5ec1822232d3f65738
BLAKE2b-256 a990b46d1f1baf27611a41471c5e1e2acd581a1c0a79c0a296d228bb5dc25d3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d68e9e84bc2a1916e1aeb1af05a1d4bb683816d9d5cf2a5591621ff81167aee
MD5 b828f62c67f697c06b410848b81124bb
BLAKE2b-256 5c8e9c40d708e2793bbe04e92571ace4138d82dd0d17aca480929d8d768f4751

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.7-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.7-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 97b23f3f9d88fcf4b87566e7e4a090b411d66c5d2efe05a7b2bc614b025e50e2
MD5 280aac8624cb19c55ab93f1dbd81a9c2
BLAKE2b-256 e146dc9442862a8ce383bb3980827398ba32cdd981f05e0897b179eb3151f721

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6d29b29acdac222dd96d2bd0e3a186cb0f3a8a652054178b03a2463aea79bf6b
MD5 e3b78b25541b3a91fa84b5be029f710b
BLAKE2b-256 e7e49dd31f94507c049972115146e01fd47d4acb5675be1a7202f88a57c6bbee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5a5045c1295938a3d0c6e647773107b0e1f962f491e08d43fe8fb129ed84de5
MD5 84cd5e5690c49b6c200b1ba586aec356
BLAKE2b-256 18a1303e3c8fec096d5ff04ed030e945de7b3b09cbe733436ab5d57292ca5856

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