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.6.tar.gz (49.6 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.6-cp312-none-win_amd64.whl (176.2 kB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.6-cp38-none-win_amd64.whl (176.3 kB view details)

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.6-cp38-cp38-macosx_11_0_arm64.whl (241.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.6.tar.gz
Algorithm Hash digest
SHA256 51407425da49b4fb2e87c44d7419e04fd903a53359e17395f6ad699028aaba8b
MD5 dd391c2ace3008e76cef5e080f45d5bb
BLAKE2b-256 7d734e05b3870405ded0dc4488f98449f90d4a480d55de371e756e9b0d3f7d80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.6-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 176.2 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.6-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 4c9e045520d90629a2a9078ccd64d6fc9873909223a89cf03d6905e06e27e30d
MD5 37f67ef8814ed3d0801bbe0c259bc5fd
BLAKE2b-256 0a1bfadde57bca60f5c243aa0ae35ac01b4f0801c2164e34765766f11143c81c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d0eb3a853eb3b1fb078acfce56c1634182f6b9d3752d935cd50189bab29b4fa6
MD5 97c8c625d7122a84cf95e37863fa1de2
BLAKE2b-256 3415bec35093407b065e1764ffcb9beeb26697bb5924446a803d0788c3978d90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24a69eb745e81c5b3b353226cdd6d93ea9dc304329e75584944688308197206f
MD5 637e04c3d0b936ec1ef378b3c909ebbf
BLAKE2b-256 10446b180eae624588662b333bc664f0f10db5c0a576dfb2d1017ab4cd648eff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.6-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.6-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 194bde14e123fbd3ce3dd2ee5772e1896e21b397a813c9b26f8ca35f3e0654f1
MD5 ddf15dd0292e122f49cf182fc7fc412c
BLAKE2b-256 aa8bdbb578a53c59fa4516e9ce1c8c0afb0a4e84e0ae272bb0d486053873b027

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 54cc14a108597a603db14a89a18a67f367c58d249e38bcf2f7b19a9ba76c67d1
MD5 afce0d0eeb6ff960bd7ec3d0f3bc2299
BLAKE2b-256 8e1d6c9e592482a9e246dbb54d74b6e6b7bd7be3e6cf96a0715f1138dea44cfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0e2f6f0ad46898de778ed4e732e6c9ccb67420a62659f4fe06bbfc9d25aeb43e
MD5 11fbc5a5dbc097bcff27675b983387cf
BLAKE2b-256 4967bc1778de97316852871625b6b5a70e566bd117d0228de475cdbf68b3ef73

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.6-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.6-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 70aa158c527fa557f4ccea499deeee806276bad7757ab32ab6a3cb5c26f38164
MD5 67ab43e77e00a4b3ff7fbc67729cde2f
BLAKE2b-256 dfac5bcef67615b7c65e0f139e74866dedaa0856ad80c293936f62993bf14b8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 88b93d50337b316b63c835a246d9c80cd6cb08b95ce686c97655ef50c1b035f3
MD5 0b26e9d49d5b49a8bc8caf54c4451527
BLAKE2b-256 b1d70bb5b5986143cc34cd3370c548532cab3693080d5e5be5a71b81e2105589

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 249149032ab9744669d5e75d0cafcac12f971c7b0ebc0a75b9d598ffad51d006
MD5 ea301484953d75e87e4b0f76b1eb47a0
BLAKE2b-256 eebb49973a4f415385e4fdd8d01a739ae93e8d5d606367f920bba73341af25b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.6-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.6-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 5ac0c066bc57a43ab06aab7bc1e82cfeb3981317887e925d6dd2109ba334ab7d
MD5 dcb652a2870bb641538f8076027e51ba
BLAKE2b-256 50fe4f57ef58eba717b95c77bbad1c38d31d933e867593482e136622fb107080

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dcd3431f17423befcc40acc4ad22bf04bdbd8a7aa0838e7ceec583b137297301
MD5 8da92418ff113bd4786562b8458d12f4
BLAKE2b-256 d2174a49691e70f970e2d1f67c04c31565edd0637dbf67e70de2ab09f1e01e38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d398a4a204a61b41fc39d17b5c3d7db85aa1826e2fd584193ca00cc4c80a3fd
MD5 b7507c6e75bd8a7fcaa6e706b39e8b35
BLAKE2b-256 cefe765252634ced3ed61d1a90d1907fbab66982e33e3a28b6db7c9b80e87972

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.6-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 176.3 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.6-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 ae69eb7ad89b43ce5f2c8090b96b85e97d6a541b70604fd8755a36e2f811d8b8
MD5 8bb13e4851842bf585b1a5f22c5caf7e
BLAKE2b-256 f324fd2d75b6f018559c5b0a92b29229d348a6fdf17b10bb79977ed57b63fd36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fd86571c6800dbeb646ca951792d10532e6dfd4ea97a58999c5e8bb394da773d
MD5 509023fa3ba04ad3cd6aeeec64d82e23
BLAKE2b-256 eb499714f7d286443fd659f75c5e3bbb0b869403173a13531e3a877e6bdf84e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.6-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1da94be4e83e2507dee1dab0ba8b00c2f429685c51f885bade3994fcad5721af
MD5 efbda5023483ece491a651fc1e7c859b
BLAKE2b-256 9a5e36f68854bd85f26ee3eab7b50604593d5e10e31ca08ecd98a41cf972a46a

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