A fast Rust-backed DAG engine for Python
Project description
dagron
A fast, Rust-backed DAG engine for Python.
Build, execute, and analyze directed acyclic graphs with a fluent Python API — powered by Rust and petgraph under the hood.
Installation
pip install dagron
Quick start
Build a DAG
Use the fluent DAGBuilder to construct graphs with payloads, metadata, and weighted edges:
from dagron import DAGBuilder
dag = (
DAGBuilder()
.add_node("a", payload=1)
.add_node("b", payload=2)
.add_node("c", payload=3)
.add_edge("a", "b")
.add_edge("a", "c")
.add_edge("b", "c")
.build() # validates acyclicity at build time
)
dag.node_count() # 3
dag.get_payload("a") # 1
Execute tasks
Map callables to nodes and execute them in dependency order with automatic parallelism:
from dagron import DAGBuilder, DAGExecutor
dag = (
DAGBuilder()
.add_node("extract")
.add_node("transform")
.add_node("load")
.add_edge("extract", "transform")
.add_edge("transform", "load")
.build()
)
tasks = {
"extract": lambda: fetch_data(),
"transform": lambda: clean_data(),
"load": lambda: write_to_db(),
}
result = DAGExecutor(dag, max_workers=4).execute(tasks)
# result.succeeded -> 3
# result.node_results["extract"].result -> return value of fetch_data()
Async execution
Native asyncio support for I/O-bound workflows:
import asyncio
from dagron import DAGBuilder, AsyncDAGExecutor
dag = (
DAGBuilder()
.add_node("fetch_users")
.add_node("fetch_orders")
.add_node("merge")
.add_edge("fetch_users", "merge")
.add_edge("fetch_orders", "merge")
.build()
)
async def main():
tasks = {
"fetch_users": lambda: fetch("/users"),
"fetch_orders": lambda: fetch("/orders"),
"merge": lambda: merge_results(),
}
result = await AsyncDAGExecutor(dag).execute(tasks)
print(result.succeeded) # 3
asyncio.run(main())
Features
Graph Construction
Create DAGs with DAG() or the fluent DAGBuilder. Add nodes with payloads and metadata, weighted edges, and bulk-insert via add_nodes/add_edges. Build graphs from tabular data with from_records.
Cycle Detection & Validation
Cycles are automatically rejected on edge insertion, so every DAG is acyclic by construction. Call validate() for an explicit structural health-check at any time.
Topological Sorting
Multiple algorithms to suit different needs: Kahn's (BFS), DFS, level-based grouping, priority-weighted ordering, and full enumeration of all valid orderings. Lazy iterators are available for memory-efficient traversal of large graphs.
Scheduling & Execution Plans
Generate dependency-aware execution plans with execution_plan and execution_plan_constrained. Identify the critical_path through weighted graphs and produce cost-based schedules for resource-constrained environments.
Execution Engines
DAGExecutor runs tasks in a thread pool with configurable workers, while AsyncDAGExecutor provides native asyncio support for I/O-bound workflows. Both support fail-fast error handling, per-node timeouts, cancellation, on_start/on_complete/on_error callbacks, and optional hook integration.
Incremental Computation
IncrementalExecutor tracks a dirty set and re-executes only the nodes affected by changes. Early cutoff skips downstream work when a node's output hasn't changed, and change provenance records why each node was recomputed.
Graph Transforms
Transform graphs with reverse, collapse, filter, merge, transitive_reduction, transitive_closure, and dominator_tree. Take immutable snapshots with snapshot for safe concurrent reads.
Subgraph & Path Algorithms
Extract subgraphs by node set or by depth from a root. Compute all_paths, shortest_path, and longest_path between any two nodes.
Reachability
ReachabilityIndex precomputes a compressed bitset index for O(1) ancestor/descendant queries. Use is_ancestor for quick relationship checks without repeated traversal.
Introspection
Query predecessors, successors, ancestors, and descendants of any node. Inspect in/out degree, roots, and leaves. Lazy iterators keep memory usage low on large graphs. Full Python protocol support: len, in, [], iter, and bool.
Node Matching
Find nodes by name using regex or glob patterns — useful for selecting groups of related nodes in large graphs.
Statistics & Diffing
GraphStats computes density, depth, width, connectivity metrics, and more. GraphDiff compares two DAGs and reports added, removed, and changed nodes and edges.
Serialization
Export and import graphs as JSON, binary (bincode + memory-mapped files), Graphviz DOT, or Mermaid diagrams. Save to and load from files in any supported format.
Tracing & Profiling
ExecutionTrace records per-node timing and exports to Chrome Tracing format for visualization. profile_execution identifies the critical path and detects bottleneck nodes.
Visualization
ASCII pretty_print renders graphs in vertical or horizontal layout directly in the terminal. Jupyter notebooks get inline SVG rendering via Graphviz, DOT, or a built-in fallback renderer.
DAG Templates
Define parameterized DAG blueprints with DAGTemplate and {{placeholder}} substitution. Render concrete DAGs, builders, or pipelines by supplying parameter values at runtime. Supports type validation, default values, custom validators, and configurable delimiters.
Plugin & Hook System
Extend dagron with DagronPlugin subclasses discovered via entry_points. HookRegistry fires lifecycle events (PRE_EXECUTE, POST_EXECUTE, PRE_NODE, POST_NODE, ON_ERROR, PRE_BUILD, POST_BUILD) with priority ordering. Includes registries for custom serializers, executors, and node types.
Approval Gates
GateController pauses execution at designated nodes and waits for manual approval or rejection. Thread-safe with both sync and async support, configurable timeouts, and integration with execution callbacks and tracing.
Dynamic DAG Modification
DynamicExecutor adds or removes nodes mid-execution based on runtime results. Expander callbacks receive a node's output and return DynamicModification specs. Operates on a runtime snapshot so the original DAG stays immutable.
Resource-Aware Scheduling
Nodes declare ResourceRequirements (GPU, CPU, memory) and ResourcePool enforces capacity constraints. ResourceAwareExecutor and AsyncResourceAwareExecutor use bottom-level priority scheduling to dispatch the highest-value ready node that fits available resources.
Graph Partitioning
Split large DAGs into balanced partitions with three Rust-native algorithms: level-based grouping, cost-balanced assignment, and communication-minimizing Kernighan-Lin refinement. PartitionedDAGExecutor executes partitions in dependency order, each internally parallelized.
Content-Addressable Caching
Merkle-tree cache keys propagate upstream changes automatically: CacheKeyBuilder hashes task source code and predecessor results so any upstream change invalidates all affected downstream nodes. FileSystemCacheBackend stores results as pickle with LRU/TTL/size eviction. CachedDAGExecutor skips unchanged nodes across runs.
Requirements
- Python >= 3.12
License
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 dagron-0.1.1.tar.gz.
File metadata
- Download URL: dagron-0.1.1.tar.gz
- Upload date:
- Size: 172.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3005e3fdf6f7e80c46ff5879a75b24e72f5f7754a781945129aa7b8411ef1cd6
|
|
| MD5 |
c293190be610e9b77c5729a73423cf0c
|
|
| BLAKE2b-256 |
ce7230c2ea9e1811a4d9c93c0043938a397bc64a3aba6301555369d7213454fb
|
Provenance
The following attestation bundles were made for dagron-0.1.1.tar.gz:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1.tar.gz -
Subject digest:
3005e3fdf6f7e80c46ff5879a75b24e72f5f7754a781945129aa7b8411ef1cd6 - Sigstore transparency entry: 1487367185
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45e88c2b83bb89b28c2071cef86a2f1313d9ab68fd1b9c2c77bddccc3a5b74e9
|
|
| MD5 |
54689df3b9eeff860fcad5c60b105d38
|
|
| BLAKE2b-256 |
904c74600e09dba16109ef0257f8a353925ce4cb7baaeafe3d6acd806f91fd25
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-win_amd64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-win_amd64.whl -
Subject digest:
45e88c2b83bb89b28c2071cef86a2f1313d9ab68fd1b9c2c77bddccc3a5b74e9 - Sigstore transparency entry: 1487367269
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff7c667d1aaaf8a3e7e52855acfa22e7982f919465bc8e36532f9c3d51b7debd
|
|
| MD5 |
5a97d5ea7fb715c21c5b1a7716b96722
|
|
| BLAKE2b-256 |
22b396ca702b4a60d007af8f0f00f6ec61894e45f05b85b277b09373e4bf937b
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
ff7c667d1aaaf8a3e7e52855acfa22e7982f919465bc8e36532f9c3d51b7debd - Sigstore transparency entry: 1487367307
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67bd3ff560df63021a2fb980cdbb9dcff0a7e16badcf182e438e35fddb053c7b
|
|
| MD5 |
91f1553e390a9b03c50b93594d7c5f94
|
|
| BLAKE2b-256 |
cc80fbe37a19267b9ab3e4473f44c410f29030c3f25686dd31479e0c70680812
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-musllinux_1_2_aarch64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
67bd3ff560df63021a2fb980cdbb9dcff0a7e16badcf182e438e35fddb053c7b - Sigstore transparency entry: 1487367208
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859162013d119eb8e416e9f281ac5c15e2fbd5a39bae00173adaa53ddc8d3f22
|
|
| MD5 |
320a5f5ca0fc867c2893aa4e23c13f2f
|
|
| BLAKE2b-256 |
9b86675800fc6c6840e6a498f6b7093b4e4bbdb187d5c6f00bc786bd9c13f416
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
859162013d119eb8e416e9f281ac5c15e2fbd5a39bae00173adaa53ddc8d3f22 - Sigstore transparency entry: 1487367279
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dddce765e5316b25fd3875149d4fcec975c1759f315b039afdfbdb8be74c52a7
|
|
| MD5 |
0f8902a2e3fcab4ca4170218904b10ad
|
|
| BLAKE2b-256 |
38222dad3d47dceaa5035b1bc900018ed2648f050d537936876e2ac194c5a3cd
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
dddce765e5316b25fd3875149d4fcec975c1759f315b039afdfbdb8be74c52a7 - Sigstore transparency entry: 1487367328
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
299bb8444dfad658c6f70af59ccaa668f2e21a42eefa887ac0081054dd2094d1
|
|
| MD5 |
7ce8614fb7ba1c4a4d548ab6d5cac455
|
|
| BLAKE2b-256 |
a2c3df5db238453bd776a3bd6a18f129c37a3376c8b2bdb11433e567edb3c86e
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
299bb8444dfad658c6f70af59ccaa668f2e21a42eefa887ac0081054dd2094d1 - Sigstore transparency entry: 1487367236
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dagron-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: dagron-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae29d0d44169ac5ffb52d09ca24afa3599114dfe435fd9f375f1f68c2b6c96e6
|
|
| MD5 |
09bd1861c104e8d2ec69da5581fbf9fc
|
|
| BLAKE2b-256 |
c7aab97bcd97e6d11dd4f573d4bad709581846ff9b3ef1151925a5c3220dec39
|
Provenance
The following attestation bundles were made for dagron-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on ByteVeda/dagron
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dagron-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl -
Subject digest:
ae29d0d44169ac5ffb52d09ca24afa3599114dfe435fd9f375f1f68c2b6c96e6 - Sigstore transparency entry: 1487367246
- Sigstore integration time:
-
Permalink:
ByteVeda/dagron@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ByteVeda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0751d7bdcff3a8b5169b95d82bc663e56899d4c0 -
Trigger Event:
push
-
Statement type: