Run tasks as a DAG
Project description
Python DAG Runner
Python DAG Runner is a Python library for running Directed Acyclic Graphs (DAGs) efficiently. It provides a simple and intuitive interface for defining and executing complex workflows. It uses networkx library to generate directed acyclic graph from the tasks and it's dependencies.
Installation
You can install python-dag-runner library easily using pip:
pip install python-dag-runner
Usage
You can easily define a dag in python-dag-runner using Dag class. Furthermore, task can be defined using Task class. You can easily define dependencies of tasks using the "|=" operator.
from python_dag_runner import Dag, Task
# Create an executable function
def print_task_1():
"""A sample function"""
print("Task 1 called")
def print_task_1():
"""A sample function"""
print("Task 2 called")
# Create Task objects
task_1 = Task(name="task one", executable=print_task_1)
task_2 = Task(name="task two", executable=print_task_2)
# Set dependencies of task using bitwise or operator
task_2 |= {task_1}
# Create a DAG by providing name and sequence of tasks
dag = Dag("My first DAG", tasks=[task_1, task_2])
# Initiate execution of Dag using initialize method
dag.initiate()
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
Built Distribution
Close
Hashes for python_dag_runner-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5097ba5eef0a394bdbb41cddec6f8e1a92228751599bee8d86d09b22b3dd476 |
|
MD5 | 9c37146b4f19df5db85637360b24fc45 |
|
BLAKE2b-256 | d47f9d6e970a070ff4f5bc37b1ee0c08d3aa461f3c9353deac854b12083702fd |