Lightweight Python DAG implementation using asyncio futures
Project description
PyFutureDAG
A simple, lightweight Python DAG implementation using asyncio futures, in the style of C++ folly FutureDAG.
Installation
pip install pyfuturedag
Demo
"""
1 - 3
/ \
0 4
\ /
2
"""
from pyfuturedag import FutureDAG, Node
# example of a function
def print_func(num):
print("printing", num)
# initialize dag
dag = FutureDAG()
# create nodes - Node(func, args)
node_0 = Node(print_func, "0")
node_0_idx = dag.add(node_0)
node_1 = Node(print_func, "1")
node_1_idx = dag.add(node_1)
node_2 = Node(print_func, "2")
node_2_idx = dag.add(node_2)
node_3 = Node(print_func, "3")
node_3_idx = dag.add(node_3)
node_4 = Node(print_func, "4")
node_4_idx = dag.add(node_4)
# specify dependency
dag.dependency(node_0_idx, node_1_idx)
dag.dependency(node_0_idx, node_2_idx)
dag.dependency(node_1_idx, node_3_idx)
dag.dependency(node_2_idx, node_4_idx)
dag.dependency(node_3_idx, node_4_idx)
# run dag
dag.loop.run_until_complete(dag.go())
Test
Simply run pytest to run tests.
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
pyfuturedag-0.0.1.tar.gz
(4.9 kB
view details)
Built Distribution
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 pyfuturedag-0.0.1.tar.gz.
File metadata
- Download URL: pyfuturedag-0.0.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
483a2d143d4b3b501e1ea57f5bedf03c1545e0b7a59edf554b48dca49788372d
|
|
| MD5 |
186541d0abdcdbf6f5db198359bd0f19
|
|
| BLAKE2b-256 |
ac5a5481794c04dbe86e971c826be1679892fba7d65c10e4302d895481eb0763
|
File details
Details for the file pyfuturedag-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyfuturedag-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbd4c2230c6cef5d8c3933665298d33bdc0fb90a728dc0e78a2e325e8802fcc0
|
|
| MD5 |
17368668d53ac688900b325d7fd77a69
|
|
| BLAKE2b-256 |
d6767a7f4a5f809ae41d19b2091a46df4550091a4f5c214d85ce4abd6c82d772
|