Skip to main content

dagapp

Making apps from DAGs by just snapping your fingers

To install: pip install dagapp

What's a DAG?

What's an app?

This is a beautiful example of a DAG app woven into to an article: rent-or-buy article+app The app serves as an illustration of the article and the article as the documentation of the app. (Note: It was a lot more "beautiful" in 2014, but they changed the graphic now! Boo!)

Here's another example of interactive calculators.

What dagapp wants to become is a framework to generate such effective communication, effortlessly.

Enough theory. Here's how it works...

A simple example

First make a DAG

from meshed.dag import DAG


def b(a):
    return 2**a


def d(c):
    return 10 - (5**c)


def result(b, d):
    return b * d


dag = DAG((b, d, result))

Then make an app

from dagapp.base import dag_app
from functools import partial

dags = [dag]

if __name__ == "__main__":
    app = partial(dag_app, dags=dags)
    app()

Then run the app

>>> streamlit run example.py

... and this is what you get

png

A more complicated example

Let's say we want to create two different DAGs and view them on the same streamlit page, keep all the non-root nodes static and represent the number inputs for one of the DAGs as sliders. We will use functions defined in configs_example.py for this example.

Define the DAGs

To start we can create our DAGs just like in the previous example.

profit_dag = DAG((user_clicks, rev, cost, profit))
revenue_dag = DAG((partners, clicks, revenue))

dags = [profit_dag, revnue_dag]

Define the configs

Next we can define some configs for these DAGs. These configs should be a list of dictionaries, with each dictionary representing the configs for each DAG. Each config must contain a dictionary arg_types that matches each of the root nodes in the DAG to an input type (currently the options are: num, slider, text, list, dict). If arg_types is not explicitly defined, then it will try to infer from type annotations in the function definitions, and then default to num. If slider is defined as the arg_type for any of the root nodes, then another dictionary ranges must be defined that matches each of the nodes designated to be slider with a min and max value for that slider. The configs for this example can be seen below.

configs = [
    dict(
        arg_types=dict(
            a="num",
            b="num",
            cost_per_click="num",
            revenue_per_click="num",
        ),
    ),
    dict(
        arg_types=dict(
            max_partners="slider",
            cost_per_click="slider",
            price_elasticity="slider",
            partners="slider",
            clicks_per_partner="slider",
        ),
        ranges=dict(
            max_partners=[0, 2000],
            cost_per_click=[0.0, 1.0],
            price_elasticity=[0, 200],
            partners=[0, 1500],
            clicks_per_partner=[0.0, 10.0],
        ),
    ),
]

Make the app

We can now make our app in a similar manner as the previous example, this time defining our configs, as well as defining StaticPageFunc as our page factory to keep all non-root nodes static.

from dagapp.page_funcs import StaticPageFunc

if __name__ == "__main__":
    app = partial(dag_app, dags=dags, page_factory=StaticPageFunc, configs=configs)
    app()

Run the app

>>> streamlit run configs_example.py

... and this is what you get

png png

Release files for dagapp 0.1.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dagapp 0.1.23
File Size Uploaded
dagapp-0.1.23.tar.gz 28.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dagapp 0.1.23
File Interpreter ABI Platform
dagapp-0.1.23-py3-none-any.whl Python 3 none any Details

Total release size: 50.7 kB

Release files / dagapp-0.1.23.tar.gz

Download URL dagapp-0.1.23.tar.gz
Size 28.2 kB
Tags Source
SHA-256 checksum
How to use checksums
57c7df2fa2843995a055beff4b1e93d7aeeb97a266823c86d7f3cd5b72af9e1f
BLAKE2b-256 checksum
How to use checksums
5527818796343a956c8e7c5a00cc24cfae97b12397a7241080753ec23a699ee8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / dagapp-0.1.23-py3-none-any.whl

Download URL dagapp-0.1.23-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2091e17573ccf639ba768c9b415b3de9314261f2fb9463db0a0174677e38ac3d
BLAKE2b-256 checksum
How to use checksums
f0a0b42e0ad933e5d6a67efce669b67455578020e61245749022c86dbba67fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.23 This release

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

1 release file

0.1.18

1 release file

0.1.17

1 release file

0.1.16

1 release file

0.1.15

1 release file

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page