DagIO

raw JSON →
0.0.2 verified Mon Apr 27 auth: no python

A Python package for running directed acyclic graphs (DAGs) of asynchronous I/O operations. Current version 0.0.2 (pre-release). Allows decorating functions to define dependencies and execute them concurrently when possible.

pip install dagio
error ModuleNotFoundError: No module named 'dagio'
cause Package not installed.
fix
Run 'pip install dagio'.
error TypeError: 'NoneType' object is not callable
cause A node's function argument is None or not a callable.
fix
Check that all node functions are defined and passed correctly.
gotcha Version 0.0.2 is pre-release; API may change without notice. Not recommended for production.
fix Pin to exact version and test thoroughly before upgrading.
gotcha DAG nodes must be callables; if you pass a non-callable, it will raise an error.
fix Ensure every node is a function or callable object.
deprecated The `run_async` decorator is experimental; its behavior may change in future versions.
fix Avoid relying on internals; use asyncio directly if needed.

Create a DAG with two nodes, where 'fetch_b' depends on 'fetch_a', and run the graph asynchronously.

import asyncio
from dagio import DAG, run_async

def fetch(url):
    # Simulate I/O
    return url

async def main():
    dag = DAG()
    dag.add_node('fetch_a', fetch, kwargs={'url': 'https://a.com'})
    dag.add_node('fetch_b', fetch, kwargs={'url': 'https://b.com'}, dependencies=['fetch_a'])
    results = await dag.run()
    print(results)

asyncio.run(main())