Skip to main content

A pure Rust DAG executor supporting implicit node connections, branching, and config sweeps

Project description

Real run (captured from /Users/brian.day/git/graph-sp/.venv/bin/python examples/py/python_demo.py):

======================================================================

Creating graph... Adding source node... Adding processor node... Adding formatter node...

Mermaid (example):

```
graph TD
    0["Source"]
    1["Processor"]
    2["Formatter"]
    0 -->|data → input| 1
    1 -->|final → value| 2
```
```bash
pip install dagex
```

Quick overview:

- Build a graph by adding functions (callables)
- Inputs/outputs are mapped by names (broadcast → function param)
- Branching and variants are supported
- Use `to_mermaid()` to visualize the DAG
- Execution returns a context-like mapping with results

---

## Minimal Python example

```python
import dagex

# Data source
def generate(_):
    return {"n": 7}

# Processor
def double(inputs):
    v = inputs.get("x", 0)
    return {"y": v * 2}

# Build graph
g = dagex.Graph()
g.add(generate, label="Source", inputs=None, outputs=[("n", "x")])
g.add(double, label="Double", inputs=[("x", "x")], outputs=[("y", "out")])

# Visualize and run
dag = g.build()
print('\nMermaid:\n', dag.to_mermaid())
context = dag.execute(parallel=False)
print('Result:', context.get('out'))
```

Expected output:

```
Result: 14
```

---

## Branching & Merging (Python)

```python
import dagex

# source
def src(_):
    return {"base": 50}

# branch functions
def add10(inputs):
    return {"result": inputs.get("x", 0) + 10}

def add20(inputs):
    return {"result": inputs.get("x", 0) + 20}

# graph
g = dagex.Graph()
g.add(src, label='Source', inputs=None, outputs=[('base', 'x')])

b1 = dagex.Graph()
b1.add(add10, label='A', inputs=[('x','x')], outputs=[('result','result')])

b2 = dagex.Graph()
b2.add(add20, label='B', inputs=[('x','x')], outputs=[('result','result')])

id1 = g.branch(b1)
id2 = g.branch(b2)

# merge maps branch-specific result -> local names
g.merge(lambda inputs: {"combined": inputs.get('from_a', 0) + inputs.get('from_b', 0)},
        label='Merge',
        inputs=[(id1, 'result', 'from_a'), (id2, 'result', 'from_b')],
        outputs=[('combined', 'final')])

dag = g.build()
print(dag.to_mermaid())
res = dag.execute(parallel=True)
print('Final:', res.get('final'))
```

Expected output:

```
Final: 130
```

---

## Variants (parameter sweep)

```python
import dagex

# Source
def src(_):
    return {"base": 10}

# Variant function builder (captures factor)
def make_mul(factor):
    def mul(inputs):
        v = inputs.get('x', 0)
        return {'result': v * factor}
    return mul

g = dagex.Graph()
g.add(src, label='Source', inputs=None, outputs=[('base','x')])

factors = [2,3,5]
funcs = [make_mul(f) for f in factors]
# wrap callables appropriately; the Python binding accepts callables directly
g.variants(funcs, label='Multiply', inputs=[('x','x')], outputs=[('result','final')])

dag = g.build()
print(dag.to_mermaid())
ctx = dag.execute(parallel=True)
print('Final:', ctx.get('final'))
```

---

## Notes & Tips

- The Python API mirrors the Rust API closely. When in doubt, consult the Rust README for conceptual diagrams.
- For large data, prefer providing structures that can be shared (e.g. numpy arrays wrapped appropriately) to avoid copies.
- Use `dag.execute(parallel=True, max_threads=4)` to limit thread usage.

---

## Where to get help

- Docs: https://docs.rs/dagex
- Issues / PRs: https://github.com/briday1/graph-sp

---

<p align="center">Built with ❤️ — enjoy composing DAGs!</p>

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.15.tar.gz (67.0 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.15-cp312-none-win_amd64.whl (191.6 kB view details)

Uploaded CPython 3.12Windows x86-64

dagex-2026.15-cp312-cp312-manylinux_2_34_x86_64.whl (347.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

dagex-2026.15-cp312-cp312-macosx_11_0_arm64.whl (253.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

dagex-2026.15-cp311-none-win_amd64.whl (191.6 kB view details)

Uploaded CPython 3.11Windows x86-64

dagex-2026.15-cp311-cp311-manylinux_2_34_x86_64.whl (347.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

dagex-2026.15-cp311-cp311-macosx_11_0_arm64.whl (253.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

dagex-2026.15-cp310-none-win_amd64.whl (191.6 kB view details)

Uploaded CPython 3.10Windows x86-64

dagex-2026.15-cp310-cp310-manylinux_2_34_x86_64.whl (347.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

dagex-2026.15-cp310-cp310-macosx_11_0_arm64.whl (253.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

dagex-2026.15-cp39-none-win_amd64.whl (191.8 kB view details)

Uploaded CPython 3.9Windows x86-64

dagex-2026.15-cp39-cp39-manylinux_2_34_x86_64.whl (347.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

dagex-2026.15-cp39-cp39-macosx_11_0_arm64.whl (253.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

dagex-2026.15-cp38-none-win_amd64.whl (191.6 kB view details)

Uploaded CPython 3.8Windows x86-64

dagex-2026.15-cp38-cp38-manylinux_2_34_x86_64.whl (347.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

dagex-2026.15-cp38-cp38-macosx_11_0_arm64.whl (253.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for dagex-2026.15.tar.gz
Algorithm Hash digest
SHA256 8a09f225245aa3b82669c43281eaa9d9cced3fe02747dd853553b97858cbb110
MD5 41ffc2b7c0b336fe345ba632c511f78f
BLAKE2b-256 dfaba5023a534d09bab7d05d15189598dc12a881db4ef7d89acd531c7c6a7b17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.15-cp312-none-win_amd64.whl
  • Upload date:
  • Size: 191.6 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.15-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 c9c5f0c629b0695b52056b34bad79f20b423b475ce54936248828ace3b72b603
MD5 988b2eb0311141e597c6bab4f0fe4803
BLAKE2b-256 d29178a4f70fb25646a111f31a443d74156db7423131018c9b04b16e9c63e943

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3393e059e025c357a22a2a3a54a468ebba111e1fb845f53adc127112b24a053c
MD5 40f2886fbaf63e6618ab389448ca4461
BLAKE2b-256 64ffe45ecbed631376b9185f6d31a218639014014ebb426b713060172d50a973

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc166d8396ea931c336008ddd725494aaa68063dd6392fd99eb17f963b89999c
MD5 69b587271487c59d24241a43ca492176
BLAKE2b-256 af018654b1d61446264bd3d767944b8f9875d39c6e0e3094ad6eddd5711dd478

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.15-cp311-none-win_amd64.whl
  • Upload date:
  • Size: 191.6 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.15-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 225f2becc711e14ecae5b9ac86bf2bd4b60fd7c89e2f87c5d52500f8779f0a2b
MD5 6b7b0216a66fb1d44c67b7c2d1625e2a
BLAKE2b-256 be34b4cabd36a443f9501b17eb50fde199e01262578a21f900d8652cc43ed1d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 23c64f960e13ed8de7261ebf110e45b5ad4aded21b829aa1122fbfe5425056c6
MD5 2cf4b85063afd20a67063a5d42e45648
BLAKE2b-256 c7b2a2aecbb308c2ba151ce7f3246be4de95e3897d925eaca5d3567095b5523c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 67f80b7528d2b84568bd090dbb72080af679178c6a6a2b058a1e161c238d6847
MD5 9fe32ca678352d2e85dea31d0368a653
BLAKE2b-256 48a7312db5a79430ed90bacd61bc020d91547756705db91e67deff1d0d188d06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.15-cp310-none-win_amd64.whl
  • Upload date:
  • Size: 191.6 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.15-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 f779036ff9d673af45ee382c4b0df1b3434e40a2003563eb5e7aa06502b22c01
MD5 0d9ed1271d9ea390032fad39c245faf8
BLAKE2b-256 4156609cde969cf65464826ce8cab65e2197684527ff7e25d57475bbf8de479a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4ce28376dd07f5ce7f4d8a04f122b01785a436c51316df16c1d77b174a21d1a4
MD5 dfd9a03657c2252e76d78dad1f03ab91
BLAKE2b-256 ba096b9b94f206e0b21fe2d30104dc0156a6d3e90466aa00c7175dc42803fae2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d4c1b513589173f98761feaa0904ecff9afd9bfb1bc712202d82d95f1b2cf4d
MD5 64035610befdd8345133d08321b78abf
BLAKE2b-256 25248977de7095407f32f7723118db195b3a9ce568687f4db0effccd740d3ea9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.15-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 191.8 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.15-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 faed67c418ac72026e806f1eb8b7b67d240d4bbaed975526f1402c5434d1f37e
MD5 50bbf83b71125fa1aa62e250e8c8ad6b
BLAKE2b-256 b1749b6b4798f635564407c5da357008beceedaac4ef27f6ae52926f7ebf5582

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b626415f3575d74882b97e579932045845541012ae6853a309ea16ccce3645d4
MD5 971a774855fe16b0e67ecb5da0a054fd
BLAKE2b-256 66f05c4c12207a1faf195c75a6f461bea9ac40afa031deeb23a4c881d54c84ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f067a6ee881e021f5a0508a187516eb31b799d0197da6ac9e14902112e943a2
MD5 df48df575349eb70b3f062c2be45b388
BLAKE2b-256 9e4ca1af4e574bd4c577bbef5445116c7bccdb65b8d2a4837e632350efff5059

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dagex-2026.15-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 191.6 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.15-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 eb6b1b8b5dcd5eab79f26e62699f11c86b777f4abd7f3948780104d16c525cb1
MD5 19a11b524cea61595c80b2e5686fe075
BLAKE2b-256 6736fd1546b5bc86be0dc0568beb8a206196713dce1247440005b9de741cd44f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8f716e42256f18ad902b6a035c3bb81c5734dcd849db221e79ef84c48397e4b9
MD5 691b59977f1149985678e6d74baf26bb
BLAKE2b-256 e07ef80673bee2a56b016ac09ccac1664b58a2850fec078b3ed7f49ab156d01b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dagex-2026.15-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a1c259f74a70344fa46f1bb01db74643554e43bb6334c0ed0226796f475a07cc
MD5 0eedf8bbf3fe0401be563b73967a22b7
BLAKE2b-256 4a0b0e60672738be0436f5031add24e2c2986602d8f1f43a35079b45c932f540

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