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.13.tar.gz (70.9 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.13-cp312-none-win_amd64.whl (189.1 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.13-cp312-cp312-manylinux_2_34_x86_64.whl (346.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.13-cp38-cp38-macosx_11_0_arm64.whl (252.2 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.13.tar.gz
Algorithm Hash digest
SHA256 7966189e048911d73bce640934c5a54cdc3c49d39ce039f3f77454bb7102ac77
MD5 1a7b8eecdf4debe2d09dec0f681984ef
BLAKE2b-256 7ca17ab4b44bc2c9a7807a04f4946f6b390240b05c1ec60e28cce445d8104482

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.13-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 189.1 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.13-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 545ab3ecdb6ecde9e99d5ef52b4698e3bc810ed21d42d5874efebecbeb05b516
MD5 1512ff5b05373e39fdd957aa5d6946ae
BLAKE2b-256 9fbe75255c75ff1d2f2c6d16eade622083ae43e13b1db920370041f4c01039fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2d5b30f8b9078b4ee5a0250fbbbd84c448728ce6392991fb6f0a9be0fa67ec05
MD5 88c3cdfe41fa43ffc1ceef09a5d9f329
BLAKE2b-256 1f34a5ffb115f41e1fde162d3827c94254a5eafb9916e022f36ae728fc4f0320

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f23fc52fc656b0dc3dc3dedf77d403c7eb9b41547834f7fce457b8014a466590
MD5 490d8dc2c2dbfb5941e8347dbd39cb9c
BLAKE2b-256 d7193cabd58afc2bbe27b9674705a4173340d88d30894bf67d1e947b66fdf7be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.13-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.13-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 5d0b838da02e041c11374de44ef484f4f356d42420cc26bcd41d4264fecac2ce
MD5 29e8c7609f5d8bd1c83fab3852e243e7
BLAKE2b-256 4fd7c45643bf57d52e9f84893675c419a4cc5ef6f4cf1aac6c761d39aad972b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ba65456e6f7beb0760c2cabb012098fc25d8487b1830f6c547ea287053fb4f1b
MD5 02f6b09efc73564716aa1517b50e9ca0
BLAKE2b-256 d441b45d458125272066d6155bad86d44ae29874d957a2a24c0b7f98b626e491

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d6f32cbde5d260e0f1bc2de0a813e6b1f8266d51d84ae0a8885a4119cf6fd571
MD5 f8e44f33544de519b3d1e26faf50e3f2
BLAKE2b-256 46960306f35865b5df1593e7a2e10658d49a37c62cbf26a0df9261b0d3469b2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.13-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.13-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 27106fcbfc6c601399c6027a0543b0ddc9095606a102d08fac11c3dfbfc9fa68
MD5 6135a459edc58882f419b5b3750d68a3
BLAKE2b-256 41739bf4cb2d4f4dfd287843f857dc98f549fcc9011568a55875334e097a6907

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b1ac046c68687f0ba653fd0a2445f9e5fe1f851685689cdd19983ffa2eebfa2d
MD5 4cb3407fa56ac5b42982ca4ee9255700
BLAKE2b-256 cd5714c4f4c15f4bfd7b8e88faf6204e14475d8ef69a57d620994991720e18a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0443ec1ac1fe4ef6695ddc6078473c74a01c1afc0e5280e4338bbc6c10c2910c
MD5 40384d1967c6a7bae1c66fa6da0c9cae
BLAKE2b-256 997ebe53124ebe5ec92653a7720d51ad3d43c7d5ed93d86cbf084f5e5d9c11bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.13-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.13-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 0e159cb320669873568e5488b3ca1770149f1c6808a61e9f49130c0ccc20209c
MD5 c01a618872853d8d91cf511cdc4b4114
BLAKE2b-256 3eb01dadd2e055653a9a19fa9ba27e284422c7421c62c18823f619d9e36c9667

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f195ea0e3f73be698ccf7fe5202f01d6a328d34f70d0a3923d4b4dbc21829963
MD5 6fdda44fa59f16ef101c8147baef1b75
BLAKE2b-256 de0f2df4c8894a5933ca9e3e8dc831ddc7e45f20eff8989f34c92450107d03c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0b808807a3442e5832ffa08b0e3ad3ce662a934417dd817b29c5c1cb3607a9a9
MD5 fc4e6ce9b73e20c3d8625691a87f3a3c
BLAKE2b-256 d2c43957aa8e7fc3b7ed420b3e4eaf8b557e7d9fc25e6fbd3b55a51cae0588b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.13-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.13-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 7cbf57d990d3d08deb812a073c355ccc01223f6836ac9800713385651b682fc1
MD5 c19e2c316c8d1f4f9697324d1ee2a804
BLAKE2b-256 eac4983bcb849ea5aec49c1331bf43392dced48125b94e2358a92b237ab9845f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e67aaedf53ed03e1aac55ba3b7c03fe82db164c3a8dac9c37ff91621474ebed0
MD5 5f602482f2901634fee82ca0c02b9707
BLAKE2b-256 88395b3305fc2d7fed918ad317d0228f0db60d4e5d1bb769499f084d7d6cbf44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.13-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90d60b69c3ce90000c064ed4e33375c1b95bca4bd02a052f411566c5bfee3a6d
MD5 1bb26fafab6af0ca35b0965bb4865af5
BLAKE2b-256 d381f1d708a8ab8c8e0c12f08c80552abcac67e5353620a50024eee6666fe1d7

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