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

Uploaded CPython 3.12Windows x86-64

dagex-2026.5-cp312-cp312-manylinux_2_34_x86_64.whl (334.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.8Windows x86-64

dagex-2026.5-cp38-cp38-manylinux_2_34_x86_64.whl (334.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

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

File metadata

  • Download URL: dagex-2026.5.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.5.tar.gz
Algorithm Hash digest
SHA256 1e3e8f7c0ed6dd82e0bb4de5b292c0a400d5569b6113458e0a82ef1089b66a08
MD5 8fded82631a82558509510c29f8f700f
BLAKE2b-256 3c34dec4aca1c0423844932250ac0ad2dc109e38194c6f3b5c7bb7c5f65adf0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.5-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.5-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 1a39015ebeee8b8c66c2be93268b3dfd84815795f5caf25905b024a00fbc0bef
MD5 12637116cbdef2dc96b9de85efa6951b
BLAKE2b-256 8957db7e6eb56629cf558d9b2cf9861d464425759519ce1761c6555e341d339e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c758698b72db3592c4f9d6ec4e3c3233af304c3d9d72d1da4f52f33a5a1c5c6b
MD5 a04ab518893170b228eddd18ab3cfc57
BLAKE2b-256 2090fcc8c0ae22cf1b4494d6224f39a849fd70903270ba7c150e80027dfee5c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae130d39fc0141d14b454c629213a19a8474f7e974022e2ec7b665366da01fc8
MD5 07eafb68e22a7ecc5303ebf7a1e87070
BLAKE2b-256 74930b42da45715ca4696f39b4843ba33cafdfda6299c7e592396154d1aa41c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.5-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.5-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 e7e2ef273b971b72e28963f6a8718ecce6c232eace971e1ceed1376e27a88eff
MD5 09bc9400bc564526609169af24498972
BLAKE2b-256 e46913f791931df2cd5037fc6f7d6b6fdd91f30254532bdf887882dbb743c395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 08448790c9af7e1d2819891100b4a77f1f292d5acfbbc561c83f5fe09ee095b8
MD5 b157a4988cc7b751c78c653fe3c0c51c
BLAKE2b-256 8c13012118d4eb394bae370bd97027f164203e4ce7988189642ca03109b8271f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eee78eafcfb704efc1e4f85164af13478d469c59baaddc8b52594f824e4cc502
MD5 5a06f95e8753e5192fbb9c79ba6054a2
BLAKE2b-256 09a259fb3ef7598ec73be3d3708d4d507a8e6a8323b036ee6d6b879bb3527b21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.5-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.5-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 748b35a44c83001a8bcf9b2e0dd457da559f5f923d31f1fd177ddfa87956619c
MD5 730d481ecb21eb4fc1e4f1b3cc891cbb
BLAKE2b-256 42747a8d854ba3ac3d3904b234cdb88c7b4430342b26f58aa418055db71136ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0f551eb9677cad20a9773e331df882c7a5387c685716adc0f29dc33990433121
MD5 0d5ee209901eea9f5202c1e879d73571
BLAKE2b-256 a20ab4342cb769d50fcf3c76189d70cd41f861ac9f6965cf290621069a2ff48e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d3e92412cc997f613b7d990b5b5031ac0e8dafb651dae46ab7c34860d960a10a
MD5 eee9090300028e5c7930e1d409f3b2c4
BLAKE2b-256 50e884bc09e834e0abc04f277d0bdc016adfa30830d8d627770421cd3c41e355

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.5-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.5-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 50bd9e8b8a40e1a1b55fdcb83eafcdecd1cda36a78590abe3f437a32295e3f58
MD5 66cd559159befe692a3a746d7bfbb7a3
BLAKE2b-256 7343eb4aa6f4f9527af80235df981da0779bf3bbaa83967084b2e61177a3aa45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 330597a72f337a3180b41534a4f535d8fdefdfe55f13b81b52bd503839a2d306
MD5 23476516338fe218f3df772cbde60eda
BLAKE2b-256 9d7f0ba795f20c4c5df2a9cf7bee1d3cbfce658a3d8969006a369bff12e2f7ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4da42e00b07016d8341a8ac55da7d9ab6de9ce03e4bf683b3c9d1bf68fac69a
MD5 5f185d84a539bf00ada2e80a1eac9842
BLAKE2b-256 985b167f09699c1131aa281895bc76aab08f17ab6fb5b59d9ecd4f9be545c534

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.5-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.5-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 fd87619b0b68d6c5f922508b400acc2a123463d156bcee261f5637bca7c413da
MD5 a623ea272a6cb535fa87733e4d1e297e
BLAKE2b-256 25d5cebe0294cfd6fea808a895156ae2a4eea81ece93ad7d89c7e2ef92ec2b04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d9e18781acb864c9901bbcb961f00df1c42fbbf37763f1e58d059a956c32a452
MD5 08424d58f3520d34e31bd053ba48b7de
BLAKE2b-256 f414c936f59f1e65b464d489e4d2cba9bf78adb3781ebc64a4bc85f3e52135c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 94f5c72d3e0da9276ee80f4f33e1e7dd097cf247f33b236bec643321884b6bce
MD5 7ab35ce4ca09b96d0aa7a59090f91c39
BLAKE2b-256 96b24ed127ff5c5380343b8c69b2767390d9a91ceaa38dd03ca885281a4c45a6

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