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
- 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
complexandnumpy.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 buildergraph.add(function, label=None, inputs=None, outputs=None)- Add a nodefunction: Callable with signature(inputs: dict, variant_params: dict) -> dictlabel: Optional node name (str)inputs: List of(broadcast_var, node_input_var)tuplesoutputs: List of(node_output_var, broadcast_var)tuples
graph.branch(subgraph=None)- Create a parallel branchgraph.build()- Build the DAG and return aDagobject
Dag
dag.execute(parallel=False, max_threads=None)- Execute the graphparallel: Enable parallel execution of independent nodesmax_threads: Limit concurrent threads (None = unlimited)- Returns:
dictwith all broadcast variables
dag.to_mermaid()- Generate Mermaid diagram (str)
Examples
The package includes several example scripts:
python_demo.py- Basic pipeline constructionpython_comprehensive_demo.py- Multiple pipeline patternspython_parallel_demo.py- Parallel execution examplespython_data_types_demo.py- Working with various data typespython_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
- GitHub: https://github.com/briday1/dagex
- Documentation: https://docs.rs/dagex
- PyPI: https://pypi.org/project/dagex
- Crates.io: https://crates.io/crates/dagex
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dagex-2026.11.tar.gz.
File metadata
- Download URL: dagex-2026.11.tar.gz
- Upload date:
- Size: 61.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34aeca81ac694d6dd2d6442997ce58794dadbdfb20d6e95cdd43cc55af12be16
|
|
| MD5 |
e3803473ee6698dd33c1d255d3263c20
|
|
| BLAKE2b-256 |
20fbfdc6e92daae311ac333d8bb4c3f9adec08a70d2ffcc7761438c96d63043c
|
File details
Details for the file dagex-2026.11-cp312-none-win_amd64.whl.
File metadata
- Download URL: dagex-2026.11-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395714c973cfab5e2bff0858dc8e3474914b1aa40015073aaa2e7b3d1d04450f
|
|
| MD5 |
ad9011e7f04b50d7c0e88e7422f82d30
|
|
| BLAKE2b-256 |
36d55e6ff5b8e1f1b5dbcb562dda71f3ea11b7a6f92eb38720cbe5b1f2909d21
|
File details
Details for the file dagex-2026.11-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dagex-2026.11-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 346.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4706e6c6b6c1c9c3ec6d92459bf932e05087d2781b9c6dab8d956075e621e8f6
|
|
| MD5 |
36fb5496afcd61f40241df05588c28a7
|
|
| BLAKE2b-256 |
0e7eedb0c5708971c19f3c0c234230c6ffbd30186f4275a334482cdafbd8ce02
|
File details
Details for the file dagex-2026.11-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: dagex-2026.11-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 251.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b9313a6ad534cdaeb5d36dd8f1cf48b4bdc07ca517f756bdbfdd41644956ccf
|
|
| MD5 |
6822abd2adb95b4de09a97811af1db08
|
|
| BLAKE2b-256 |
769a975c325f37a4a1fe3bc790b02fbf5edbf83c30246fab45ec450aaee108f4
|
File details
Details for the file dagex-2026.11-cp311-none-win_amd64.whl.
File metadata
- Download URL: dagex-2026.11-cp311-none-win_amd64.whl
- Upload date:
- Size: 189.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3024961dd588ca9681f9336c793fb033ff323799349b56e53a50076d1c813882
|
|
| MD5 |
6154df35ee7ac166dc2940cbad4464b1
|
|
| BLAKE2b-256 |
3e291f577f9807947f93f67d32ddc985701338226a4285bc14d4ee5322dd9d31
|
File details
Details for the file dagex-2026.11-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dagex-2026.11-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 346.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10cf0fa4c1cf1b3813b907573486b470ef76dc54b69923db084d2dc39f7f23ab
|
|
| MD5 |
7c108cd0666a57ba8e20c17e2936d644
|
|
| BLAKE2b-256 |
3050a882c2f6fae21038c24f3a80ec8adec762c156430b55a1851d269cfea81b
|
File details
Details for the file dagex-2026.11-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: dagex-2026.11-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 252.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa56544e42dce21d86c71999a9df1a7798b7063e0719519d7aa6cea0cb48cb33
|
|
| MD5 |
5786f38d4a1a8587f79fcd4851fdd378
|
|
| BLAKE2b-256 |
9c418048b779c5898ce36161dd441c988e3aa71394d86a8e4c2615fb1b49d2b4
|
File details
Details for the file dagex-2026.11-cp310-none-win_amd64.whl.
File metadata
- Download URL: dagex-2026.11-cp310-none-win_amd64.whl
- Upload date:
- Size: 189.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90ee9283c23d8f89c40d06de0bde2eea1160e67cded11e02be890986dfcce178
|
|
| MD5 |
fc4c44dff29215b810cb2e337d362b24
|
|
| BLAKE2b-256 |
c2bc09d28f7acb27f606a65cc74f5560f872bd16e7553d999ea10ea6c9d25153
|
File details
Details for the file dagex-2026.11-cp310-cp310-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dagex-2026.11-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 346.2 kB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19127a9bbd97895f76e915faffbc9dec1e73630bce9d16daa62d24009506adf2
|
|
| MD5 |
fd728b1e5720eda0a09e0623f5f95298
|
|
| BLAKE2b-256 |
4585f23e239a4be6cb3550229291ab9bb8467af9bfba83286d63e984418c28dc
|
File details
Details for the file dagex-2026.11-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: dagex-2026.11-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 252.5 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56fd6d4a179fdea70d64fcf7330073a94da3e4f326937dd07ff93e4cae32d16c
|
|
| MD5 |
97afe84182bac7a96e0d66f7b6463f77
|
|
| BLAKE2b-256 |
f349c9ac37f756706a2417f3b8beac1d547f5702c001e9bd46899c6a1f1e5712
|
File details
Details for the file dagex-2026.11-cp39-none-win_amd64.whl.
File metadata
- Download URL: dagex-2026.11-cp39-none-win_amd64.whl
- Upload date:
- Size: 189.4 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bea8925f75794ab1872e9d51a6186cc6d5d24cdb5a34bc5e7e1cd3bb8246305
|
|
| MD5 |
95ee4ce470f543a3fb5980115969669f
|
|
| BLAKE2b-256 |
a3311f364128c9d831d532153d35dce9d02d4920110a756516a251806676fa08
|
File details
Details for the file dagex-2026.11-cp39-cp39-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dagex-2026.11-cp39-cp39-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 346.2 kB
- Tags: CPython 3.9, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a9870bf31b9ebb758992ce7b96e3144bb9ca5be446df72252b4021bb154f352
|
|
| MD5 |
422baab2d7807b0e714dacec803ab974
|
|
| BLAKE2b-256 |
4cd642c0127fd26e2ee53511d755600cdf507b5f348b61a8f61bf642edf8362c
|
File details
Details for the file dagex-2026.11-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: dagex-2026.11-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 252.7 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a3c46258d06a453d2d49ee7ec2b4ce9b0130b0dfcb6d3c045415743df16e23d
|
|
| MD5 |
eb66f9cf9b9d0da905c28c3cfd0dfd50
|
|
| BLAKE2b-256 |
fc7f9e8a234cf4f0be6430990def3ad8425f77ff291471540c2418a153351d1a
|
File details
Details for the file dagex-2026.11-cp38-none-win_amd64.whl.
File metadata
- Download URL: dagex-2026.11-cp38-none-win_amd64.whl
- Upload date:
- Size: 189.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b091d4d91af8e2cf12adb1689a5cc70ade6b5c8b00505aad8a4a8fcf44b64558
|
|
| MD5 |
8a8bb38a4174fda9dd9f08ae1b78a8b9
|
|
| BLAKE2b-256 |
ae7dfc5d4383ded4295e28d64104672e1504635a01c5efbbc5e99863cc29f156
|
File details
Details for the file dagex-2026.11-cp38-cp38-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dagex-2026.11-cp38-cp38-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 346.4 kB
- Tags: CPython 3.8, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be53b7da70c892dbc5f6c38f784904f6a57735ac56229c5fca0e9e1a1f295bf9
|
|
| MD5 |
8125f3c3505ead3fc2487d0cfaecafca
|
|
| BLAKE2b-256 |
ce29b8b220735d067a649ccedb631bc4709e175bddc3562cb64d2ad495e6a03a
|
File details
Details for the file dagex-2026.11-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: dagex-2026.11-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 252.1 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
848b8963512ebc127efe162295bc2cb26fa2d8d396b54604e449032b64b88f86
|
|
| MD5 |
188439013d84f1ed2fdaab52cd557e7d
|
|
| BLAKE2b-256 |
ed08b196715a805694cf9ccc9d7583328cb10240842689e7e8bb395aa5cf1999
|