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.4.tar.gz (8.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dagex-2026.4-cp312-none-win_amd64.whl (176.1 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.4-cp312-cp312-manylinux_2_34_x86_64.whl (334.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dagex-2026.4-cp312-cp312-macosx_11_0_arm64.whl (241.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.4-cp311-none-win_amd64.whl (176.2 kB view details)

Uploaded CPython 3.11Windows x86-64

dagex-2026.4-cp311-cp311-manylinux_2_34_x86_64.whl (334.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.4-cp311-cp311-macosx_11_0_arm64.whl (241.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.4-cp310-none-win_amd64.whl (176.2 kB view details)

Uploaded CPython 3.10Windows x86-64

dagex-2026.4-cp310-cp310-manylinux_2_34_x86_64.whl (334.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.4-cp310-cp310-macosx_11_0_arm64.whl (241.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.4-cp39-none-win_amd64.whl (176.5 kB view details)

Uploaded CPython 3.9Windows x86-64

dagex-2026.4-cp39-cp39-manylinux_2_34_x86_64.whl (334.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

dagex-2026.4-cp39-cp39-macosx_11_0_arm64.whl (241.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.4-cp38-none-win_amd64.whl (176.4 kB view details)

Uploaded CPython 3.8Windows x86-64

dagex-2026.4-cp38-cp38-manylinux_2_34_x86_64.whl (334.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.4-cp38-cp38-macosx_11_0_arm64.whl (241.6 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.4.tar.gz
Algorithm Hash digest
SHA256 08d0d1652f25d4f5a169fb1cabe49289275a5b97d465eb0bb033f31147cd5356
MD5 68e4860a7018666fc6e63f70665cab55
BLAKE2b-256 e073344fcb2b3144be42a20944530645c12064830178e3ae38b2b75f0dd93aec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.4-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 176.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.4-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 65deaea9926bf660923b293a5bad19e95c05ff259628500754920f650c297f03
MD5 e72029e36019b8f90faa53264c9cc882
BLAKE2b-256 c15c67cbc37a897474a79c27abd41264e901dc73d5e96723705610a2032e8c86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6524600b9a075054a1e5f43dd6a72d35bbd1a02b32d37d0a14721894c8f4d75d
MD5 665bfaf8df444412d239981dbf4f5240
BLAKE2b-256 c5ff846f3455e3666e25461c905e8b23493d23e1125a7d8ba55193e7c5997f35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1ab3d864163e7b7266345c0caf55b98a50d58aef20168e2c8cc1a93900c6466
MD5 1628fe621f946caf20378ea1f5e47a64
BLAKE2b-256 3742cad0b92e52fcecfd8c87e9778900f003dd4907914b02094f904384b9b304

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.4-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 176.2 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.4-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 fab77839f1238d9c18d00cbe6dba0f6a543473fcad40884a1115b405236be883
MD5 73e3716813f250cf955d92cabe8d372a
BLAKE2b-256 f488098190aa6edbd9748a184b95c84e8ec2fd6d54e4aec0c5d76e7eac9f7e59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 32d2afec87d8dfd2efce180e4a804843158ef33e20dcf2d58c3715f0ec61609f
MD5 9c78698e736a1d5ebdc909a01ff86138
BLAKE2b-256 a4dc606d47f7d4ab83636f780b4fe8cd223bf2d651d4f825f470688358b41aca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c431fa451410647ac900a21fe4615f8b1b6732f39ca05c40716c6329d991dea
MD5 e3ce6fc81b58d1eb4028fbfc6be2304c
BLAKE2b-256 a85e21145e6efb60cb1cf0d07469cb4e9615cc4f6a71afa88e4985870b3ceca7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.4-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 176.2 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.4-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 9661dff447f4d93ae293e4e592fc6cde8e8aea8a33eee9305c952a75b0fee1c0
MD5 feffab6b40af9396b23d6383b6ce32c6
BLAKE2b-256 ddeea3d45d97517a1df614598793a9d0d0632e00c99fae48a8d25de594fe499a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3a5411bcf6b9d12edd823f413f3378aa2a1f99b07dd98b88d2f97f06d6dce952
MD5 4cec22991f40cd20ff730a6ffb2fca2f
BLAKE2b-256 148db6fb7091366794f3435df8c63a120f38ea1f8ce3b4907a3d468de28ff1f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2e49d0f1c605e6a1c673d26436f00cdc49810e44a86fa66f31f61eb31b191c8
MD5 90ea287f125babd812a710a9f4cdb060
BLAKE2b-256 d961cb7b41bf98e1a4eb36257e3c20e55eb55637d8b32347ffe85fd8951dc3a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.4-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 176.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.4-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 2a71b9417a3231f77548a186e572280680bfb840c560b16195dd6f4ec9fa6488
MD5 1ceac98750277e0fcffc91f507011c61
BLAKE2b-256 2311bb326c8092267f9d4fae9596013f4e54d56c48053e3a3297461a7a031362

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3f87ba47d8c4f5d7e1663ce0d50f9224d9dcc8a5916ed35f5ee7032a34f8a014
MD5 f3b0a61686a6cb8d82c3e3b06f88ccb9
BLAKE2b-256 d3d8e3a1571e397462dacc06f2e4bcbc236e911775320c89a0875310e4db3e46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a98818bbcea80e3911193429ec97455dcae805b3ade3011ee045608ac4f9cfd0
MD5 db0c49a34f70f163d0eed3dc20a39ecd
BLAKE2b-256 55b530e23d0ca091997ecafdd43d21210b9c2babe39b91b654d1488c86ecd7d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.4-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 176.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.4-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 363d6a8bc61138ebce648ec5af56ae2a230f0f5e9b3bf2edbe0f508c56e30346
MD5 3522084af617bbfb51e74da6948824d0
BLAKE2b-256 f2a49e8c658427e5ec431bbb0111af2b4f6536424228ebb1dcae9c7e18441efe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d587734615801326d696fde04d7b4432dbe0e2c05d2b7698fc609e52b2566c7c
MD5 9b77d6f33c6d9669f42c3f9d600ac7e6
BLAKE2b-256 4919faf36a61739f8dc67e7d09bb2b880f31135fd907dbc61ef837571ac46cba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fdb7958e3b344ff2f67018addb1c2c1fa5008f668d105b95323da70fe08360ed
MD5 860b9798c4416f6bdce7a417a8eb9d52
BLAKE2b-256 3847eac579268431b93b03f961e509e6fb069449d4ae84b36515ae34b7182025

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