I want to write and run a directed acyclic graph (DAG) with several tasks running in serial or parallel. Ideally it would look like:
def task1():
# ...
def task2():
# ...
graph = Sequence([
task1,
task2,
Parallel([
task3,
task4
]),
task5
]
graph.run()
It would run 1 -> 2 -> (3 and 4 concurrently) -> 5. The tasks need to access the global scope to store results, write logs and access command line parameters.
My use case is writing a deployment script. Parallel tasks are IO-bound: typically waiting on a remote server to complete a step.
I looked into threading, asyncio, Airflow, but did not find any simple library that would allow this without some boilerplate code to traverse and control the graph's execution. Does anything like that exist?