Skip to main content

Mimimal DAG implementation with Python

Project description

Tiny DAG

Bare bones implementation of computation (directed, acyclic) graph for Python.

Requirements

  • Python >= 3.6
  • graphviz

Installation

Binary installers for the latest released version are available at the Python Package Index (PyPI): https://pypi.org/project/tiny-dag/

Install by typing

pip3 install tiny-dag

Usage example

from tinydag.graph import Graph
from tinydag.node import Node

add = lambda a, b: a + b
mul = lambda a, b: a * b
div = lambda a, b: a / b

nodes = [
    Node(["add1", "x"], add, "add2"),
    Node(["add1", "add2"], mul, "mul"),
    Node(["x", "y"], add, "add1"),
    Node(["mul", "z"], div, "div"),
]
graph = Graph(nodes)
graph.render()
data = {"x": 5, "y": 3, "z": 3}
results = graph.calculate(data)

render method produces following figure:

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

tiny_dag-0.0.2.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

tiny_dag-0.0.2-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page