python-dag-runner


Namepython-dag-runner JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/jatinlal1994/python-dag-runner
SummaryRun tasks as a DAG
upload_time2024-02-29 22:19:56
maintainer
docs_urlNone
authorJatin Lal
requires_python
license
keywords python dag runner
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Python DAG Runner
![Python](https://img.shields.io/badge/python-3.8-blue.svg)
![Python Style](https://img.shields.io/badge/code%20style-pep8-blue)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![PyPI - Downloads](https://img.shields.io/pypi/dm/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:
```bash
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.
```python
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()
```

## Example of complex dependencies
Multiple internal dependencies can be defined using dependency operator.
```python
task_2 |= {task_1}
task_3 |= {task_2}
task_4 |= {task_2}
task_5 |= {task_2}
task_6 |= {task_3, task_4, task_5}
task_7 |= {task_6}
task_8 |= {task_7}
task_9 |= {task_7}
```

The above steps result in the dependency graph as shown below
```mermaid
%%{init: {'theme': 'neutral'}}%%
stateDiagram
direction LR
    task_one --> task_two
    task_two --> task_three
    task_two --> task_four
    task_two --> task_five
    task_three --> task_six
    task_four --> task_six
    task_five --> task_six
    task_six --> task_seven
    task_seven --> task_eight
    task_seven --> task_nine
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jatinlal1994/python-dag-runner",
    "name": "python-dag-runner",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,dag,runner",
    "author": "Jatin Lal",
    "author_email": "jatinlal1994@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/90/16/9959d91a36a7e8e48795b1465939c306dfe5cac1bb36f01d038d2c511f52/python-dag-runner-0.0.5.tar.gz",
    "platform": null,
    "description": "\n# Python DAG Runner\n![Python](https://img.shields.io/badge/python-3.8-blue.svg)\n![Python Style](https://img.shields.io/badge/code%20style-pep8-blue)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/python-dag-runner)\n\nPython 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.\n\n## Installation\nYou can install python-dag-runner library easily using pip:\n```bash\npip install python-dag-runner\n```\n\n## Usage\nYou 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.\n```python\nfrom python_dag_runner import Dag, Task\n\n# Create an executable function\ndef print_task_1():\n    \"\"\"A sample function\"\"\"\n    print(\"Task 1 called\")\n\ndef print_task_1():\n    \"\"\"A sample function\"\"\"\n    print(\"Task 2 called\")\n\n# Create Task objects\ntask_1 = Task(name=\"task one\", executable=print_task_1)\ntask_2 = Task(name=\"task two\", executable=print_task_2)\n\n# Set dependencies of task using bitwise or operator\ntask_2 |= {task_1}\n\n# Create a DAG by providing name and sequence of tasks\ndag = Dag(\"My first DAG\", tasks=[task_1, task_2])\n\n# Initiate execution of Dag using initialize method\ndag.initiate()\n```\n\n## Example of complex dependencies\nMultiple internal dependencies can be defined using dependency operator.\n```python\ntask_2 |= {task_1}\ntask_3 |= {task_2}\ntask_4 |= {task_2}\ntask_5 |= {task_2}\ntask_6 |= {task_3, task_4, task_5}\ntask_7 |= {task_6}\ntask_8 |= {task_7}\ntask_9 |= {task_7}\n```\n\nThe above steps result in the dependency graph as shown below\n```mermaid\n%%{init: {'theme': 'neutral'}}%%\nstateDiagram\ndirection LR\n    task_one --> task_two\n    task_two --> task_three\n    task_two --> task_four\n    task_two --> task_five\n    task_three --> task_six\n    task_four --> task_six\n    task_five --> task_six\n    task_six --> task_seven\n    task_seven --> task_eight\n    task_seven --> task_nine\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Run tasks as a DAG",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/jatinlal1994/python-dag-runner"
    },
    "split_keywords": [
        "python",
        "dag",
        "runner"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "465092252d061a1c49b9d9c01d3f18631e7b860f4e3aa48102576c38ab8e121f",
                "md5": "f685b8b039025cc966f85129ba1345c6",
                "sha256": "07ca58d732ec2f6c36f8fc8a16d80c58a9b92d4054b2ae390837c9ce960a486b"
            },
            "downloads": -1,
            "filename": "python_dag_runner-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f685b8b039025cc966f85129ba1345c6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6850,
            "upload_time": "2024-02-29T22:19:55",
            "upload_time_iso_8601": "2024-02-29T22:19:55.315290Z",
            "url": "https://files.pythonhosted.org/packages/46/50/92252d061a1c49b9d9c01d3f18631e7b860f4e3aa48102576c38ab8e121f/python_dag_runner-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90169959d91a36a7e8e48795b1465939c306dfe5cac1bb36f01d038d2c511f52",
                "md5": "dc3a63c70db5fdb70d143c0b0790c9a9",
                "sha256": "c1b8a873a39dcc419bebc8ac891572bf27487adb859c60b9315c4b7109b4ad6c"
            },
            "downloads": -1,
            "filename": "python-dag-runner-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "dc3a63c70db5fdb70d143c0b0790c9a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5460,
            "upload_time": "2024-02-29T22:19:56",
            "upload_time_iso_8601": "2024-02-29T22:19:56.779824Z",
            "url": "https://files.pythonhosted.org/packages/90/16/9959d91a36a7e8e48795b1465939c306dfe5cac1bb36f01d038d2c511f52/python-dag-runner-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-29 22:19:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jatinlal1994",
    "github_project": "python-dag-runner",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "python-dag-runner"
}
        
Elapsed time: 4.24154s